ppbus probe problem
Doug Rabson
dfr at nlsystems.com
Thu Mar 18 01:13:47 PST 2004
On Thursday 18 March 2004 08:02, Guido van Rooij wrote:
> As the newbus gurus, I hope you can shed a light on the following:
> I am trying to resurrect tw.c into current. While modifying it,
> I came across a weird problem. If you load/unload a ppbus
> driver (if at all possible), each additional load/unload
> leads to an additional probe the next time you load that driver.
> E.g, if you add a printf to the probe function in vpo.c, you see:
>
> command: dmesg
> beck# kldload ./vpo.ko vpo probe called
> beck# kldunload ./vpo.ko
> beck# kldload ./vpo.ko vpo probe called
> vpo probe called
> beck# kldunload ./vpo.ko
> beck# kldload ./vpo.ko vpo probe called
> vpo probe called
> vpo probe called
>
> etc.
>
> Someone suggested that the identify function was responsible for
> this:
> static void
> vpo_identify(driver_t *driver, device_t parent)
> {
>
> BUS_ADD_CHILD(parent, 0, "vpo", -1);
> }
>
> Nowhere is the child removed from the parent at detach (also there is
> no BUS_REMOVE_CHILD method).
You can use device_delete_child(). The reason BUS_ADD_CHILD exists is to
give the parent a chance to initialise child instance variables.
>
> What is the correct way to fix the probe call incrementing problem?
I would use something like:
static void
vpo_identify(driver_t *driver, device_t parent)
{
device_t dev;
dev = device_find_child(parent, "vpo", 0);
if (!dev)
BUS_ADD_CHILD(parent, 0, "vpo", -1);
}
More information about the freebsd-new-bus
mailing list