Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F141195809
D15301.id42387.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D15301.id42387.diff
View Options
Index: sys/dev/spibus/spibus.c
===================================================================
--- sys/dev/spibus/spibus.c
+++ sys/dev/spibus/spibus.c
@@ -121,9 +121,29 @@
spibus_child_location_str(device_t bus, device_t child, char *buf,
size_t buflen)
{
+ int cs, bus_unit;
+ const char * devclass = device_get_name(child);
struct spibus_ivar *devi = SPIBUS_IVAR(child);
- snprintf(buf, buflen, "cs=%d", devi->cs);
+// spibus_get_cs(child, &cs); /* TODO: is this better or not? */
+ cs = devi->cs & (~SPIBUS_CS_HIGH); /* trim 'cs high' bit */
+
+ bus_unit = device_get_unit(bus);
+
+// snprintf(buf, buflen, "cs=%d", devi->cs);
+
+ if (devclass && !strcmp(devclass, "spigen")) { /* spigen device only */
+ /*
+ * this hack required due to the fact that there's no canonical
+ * way to have spigen do an overload of the %location sysctl
+ */
+ snprintf(buf, buflen, "bus=%d cs=%d spigen=spigen%d.%d",
+ bus_unit, cs, bus_unit, cs);
+ }
+ else {
+ snprintf(buf, buflen, "bus=%d cs=%d",
+ bus_unit, cs);
+ }
return (0);
}
Index: sys/dev/spibus/spigen.c
===================================================================
--- sys/dev/spibus/spigen.c
+++ sys/dev/spibus/spigen.c
@@ -64,6 +64,7 @@
struct spigen_softc {
device_t sc_dev;
struct cdev *sc_cdev;
+ struct cdev *sc_adev; /* alias device */
struct mtx sc_mtx;
uint32_t sc_command_length_max; /* cannot change while mmapped */
uint32_t sc_data_length_max; /* cannot change while mmapped */
@@ -186,11 +187,42 @@
{
struct spigen_softc *sc;
const int unit = device_get_unit(dev);
+ int cs, res;
+ struct make_dev_args mda;
+
+ spibus_get_cs(dev, &cs);
+ cs &= ~SPIBUS_CS_HIGH; /* trim 'cs high' bit */
sc = device_get_softc(dev);
sc->sc_dev = dev;
- sc->sc_cdev = make_dev(&spigen_cdevsw, unit,
- UID_ROOT, GID_OPERATOR, 0660, "spigen%d", unit);
+
+ make_dev_args_init(&mda);
+ mda.mda_flags = 0; /* see make_dev in kern_conf.c */
+ mda.mda_devsw = &spigen_cdevsw;
+ mda.mda_cr = NULL; /* see make_dev in kern_conf.c */
+ mda.mda_uid = UID_ROOT;
+ mda.mda_gid = GID_OPERATOR;
+ mda.mda_mode = 0660;
+ mda.mda_unit = unit;
+
+// res = make_dev_s(&mda, &(sc->sc_cdev), "spigen%d", unit);
+ res = make_dev_s(&mda, &(sc->sc_cdev), "spigen%d.%d",
+ device_get_unit(device_get_parent(dev)), cs);
+ if (res) {
+ return res;
+ }
+
+// res = make_dev_alias_p(0, &(sc->sc_adev), sc->sc_cdev, "spigen%d.%d",
+// device_get_unit(device_get_parent(dev)), cs);
+ res = make_dev_alias_p(0, &(sc->sc_adev), sc->sc_cdev, "spigen%d", unit);
+ if (res) {
+ if (sc->sc_cdev) { /* TODO: should I just rely on 'detach' to do this? */
+ destroy_dev(sc->sc_cdev);
+ sc->sc_cdev = NULL;
+ }
+ return res;
+ }
+
sc->sc_cdev->si_drv1 = dev;
sc->sc_command_length_max = PAGE_SIZE;
sc->sc_data_length_max = PAGE_SIZE;
@@ -429,8 +461,11 @@
mtx_destroy(&sc->sc_mtx);
- if (sc->sc_cdev)
- destroy_dev(sc->sc_cdev);
+ if (sc->sc_adev)
+ destroy_dev(sc->sc_adev);
+
+ if (sc->sc_cdev)
+ destroy_dev(sc->sc_cdev);
return (0);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 3, 5:38 AM (7 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27468220
Default Alt Text
D15301.id42387.diff (3 KB)
Attached To
Mode
D15301: alter spigen device name to indicate cs as sub-unit
Attached
Detach File
Event Timeline
Log In to Comment