nasty device_delete_child interaction
M. Warner Losh
imp at bsdimp.com
Thu Jan 29 08:11:22 PST 2004
In message: <200401291050.40458.jhb at FreeBSD.org>
John Baldwin <jhb at FreeBSD.org> writes:
: On Thursday 29 January 2004 01:35 am, John Wehle wrote:
: > device_delete_child works by starting with the grandchildren
: > working back towards the immediate child. Several drivers
: > (i.e. if_xl.c, if_wx.c, iicbb.c) have code similar to:
: >
: > xxx_attach()
: > {
: >
: > ...
: > sc->child_dev = device_add_child ...
: > }
: >
: > xxx_detach()
: > {
: >
: > bus_generic_detach ();
: > if (sc->child_dev)
: > device_delete_child ...
: > }
Don't do that. You are duplicating the storage of children in two
places. If you need to cache a copy of a child, that's fine.
However, don't delete it explicitly in xxx_detach.
I'd say that these drivers are wrong and should be fixed.
: > It seems to me that any driver which calls device_delete_child
: > as part of detaching must also implement something like:
No. They should avoid the problem by using newbus correctly. This
sort of solution just adds code to no good purpose.
Warner
More information about the freebsd-new-bus
mailing list