Daemon News Ezine BSD News BSD Mall BSD Support Forum BSD Advocacy BSD Updates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nasty device_delete_child interaction



In message: <200401291050.40458.jhb@xxxxxxxxxxx>
            John Baldwin <jhb@xxxxxxxxxxx> 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