tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Attaching to an attribute
Devices can be attached to an attribute, e.g.
wsmouse* at wsmousedev?
where potential parents declare to have that attribute, e.g.
device ums: hid, wsmousedev
and the autoconf code knows how to attach to the attribute only:
static int
cfparent_match(const device_t parent, const struct cfparent *cfp)
{
/* ... */
/*
* If no specific parent device instance was specified (i.e.
* we're attaching to the attribute only), we're done!
*/
if (cfp->cfp_parent == NULL)
return 1;
/*
* Check the parent device's name.
*/
if (STREQ(pcd->cd_name, cfp->cfp_parent) == 0)
return 0; /* not the same parent */
/*
* Make sure the unit number matches.
*/
if (cfp->cfp_unit == DVUNIT_ANY || /* wildcard */
cfp->cfp_unit == parent->dv_unit)
return 1;
/* Unit numbers don't match. */
return 0;
}
However config(1) instead of providing single wildcard parent spec
seems to instantiate parent specs for all parents it's seen that carry
the attribute. Check ioconf.c of your kernel: instead of single
static const struct cfparent pspecXXX = {
"wsmousedev", NULL, DVUNIT_ANY
};
struct cfdata cfdata[] = {
...
{ "wsmouse", "wsmouse", 0, STAR, loc+XXX, 0, &pspecXXX },
...
};
it emits
static const struct cfparent pspec15 = {
"wsmousedev", "spic", DVUNIT_ANY
};
/* ... */
/*238: wsmouse* at spic? mux 0 */
{ "wsmouse", "wsmouse", 0, STAR, loc+1423, 0, &pspec15 },
/*239: wsmouse* at pms? mux 0 */
{ "wsmouse", "wsmouse", 0, STAR, loc+1424, 0, &pspec49 },
/*240: wsmouse* at ums? mux 0 */
{ "wsmouse", "wsmouse", 0, STAR, loc+1425, 0, &pspec108 },
/* ... */
for each device with wsmousedev attribute.
This wastes a bit of memory in the static config, but that's not much
of a problem.
However if you want to attach such device to an attribute on another
device you load as a module, you can't, at least naively, b/c there's
no wildcard pspec for the wsmouse.
In existing code only uatp(4) module attaches wsmouse(4). I don't
have one, but my prediction is that it will fail with "device not
configured". Can someone with the device try and verify that?
You can add
wsmouse* at wsmousedev?
to the module's ioconf. Surprisingly, that generates wildcard parent
spec for wsmouse! But it also adds wsmouse to cfdriver and cfattach
arrays and loading the module will fail with EEXIST.
The workaround seems to be to manually hack the ioconf.c so that the
module has the wildcard pspec line for wsmouse in cfdata only.
Anyone with enough config clue to comment (or better yet, fix :)?
-uwe
Home |
Main Index |
Thread Index |
Old Index