Date: Thu, 29 Jan 2004 09:11:09 -0700 (MST) From: "M. Warner Losh" <imp@bsdimp.com> To: jhb@FreeBSD.org Cc: mdodd@FreeBSD.org Subject: Re: nasty device_delete_child interaction Message-ID: <20040129.091109.27780542.imp@bsdimp.com> In-Reply-To: <200401291050.40458.jhb@FreeBSD.org> References: <200401290635.i0T6ZO224579@jwlab.FEITH.COM> <200401291050.40458.jhb@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
In message: <200401291050.40458.jhb@FreeBSD.org> John Baldwin <jhb@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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040129.091109.27780542.imp>