Date: Thu, 18 Mar 2004 09:13:33 +0000 From: Doug Rabson <dfr@nlsystems.com> To: freebsd-new-bus@freebsd.org Cc: new-bus@freebsd.org Subject: Re: ppbus probe problem Message-ID: <200403180913.33873.dfr@nlsystems.com> In-Reply-To: <20040318080230.GA87270@gvr.gvr.org> References: <20040318080230.GA87270@gvr.gvr.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403180913.33873.dfr>