Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/spibus/spibus.c
Context not available. | |||||
static int | static int | ||||
spibus_child_location_str(device_t bus, device_t child, char *buf, | spibus_child_location_str(device_t bus, device_t child, char *buf, | ||||
size_t buflen) | size_t buflen) | ||||
{ | { | ||||
int cs, bus_unit; | |||||
const char * devclass = device_get_name(child); | |||||
struct spibus_ivar *devi = SPIBUS_IVAR(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? */ | ||||
ian: Not necessarily better. Since spibus is the creator/owner of child device info, just using… | |||||
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 | |||||
*/ | |||||
ianUnsubmitted Done Inline ActionsI know it was me who said having the spigen= in the location (kinda like usb ugen does) would be nice, but this is indeed kinda hacky. Let's leave it out for now and just use bus=%d cs=%d in all cases, since that really does provide all the info you need to find the right spigen device anyway. ian: I know it was me who said having the spigen= in the location (kinda like usb ugen does) would… | |||||
bobf_mrp3.comAuthorUnsubmitted Done Inline ActionsI will take the '!strcmp(devclass "spigen")' compare out and just use what's in the 'else' clause. simpler too. bobf_mrp3.com: I will take the '!strcmp(devclass "spigen")' compare out and just use what's in the 'else'… | |||||
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); | return (0); | ||||
} | } | ||||
static int | static int | ||||
spibus_child_pnpinfo_str(device_t bus, device_t child, char *buf, | spibus_child_pnpinfo_str(device_t bus, device_t child, char *buf, | ||||
Context not available. |
Not necessarily better. Since spibus is the creator/owner of child device info, just using devi directly is fine.