From owner-freebsd-bugs@FreeBSD.ORG Wed Jan 25 04:52:14 2006 Return-Path: X-Original-To: freebsd-bugs@freebsd.org Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3731D16A41F; Wed, 25 Jan 2006 04:52:14 +0000 (GMT) (envelope-from PeterJeremy@optushome.com.au) Received: from mail28.syd.optusnet.com.au (mail28.syd.optusnet.com.au [211.29.133.169]) by mx1.FreeBSD.org (Postfix) with ESMTP id 571C043D48; Wed, 25 Jan 2006 04:52:13 +0000 (GMT) (envelope-from PeterJeremy@optushome.com.au) Received: from cirb503493.alcatel.com.au (c220-239-19-236.belrs4.nsw.optusnet.com.au [220.239.19.236]) by mail28.syd.optusnet.com.au (8.12.11/8.12.11) with ESMTP id k0P4qAni009721 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Wed, 25 Jan 2006 15:52:11 +1100 Received: from cirb503493.alcatel.com.au (localhost.alcatel.com.au [127.0.0.1]) by cirb503493.alcatel.com.au (8.12.10/8.12.10) with ESMTP id k0P4qAHh039673; Wed, 25 Jan 2006 15:52:10 +1100 (EST) (envelope-from pjeremy@cirb503493.alcatel.com.au) Received: (from pjeremy@localhost) by cirb503493.alcatel.com.au (8.12.10/8.12.9/Submit) id k0P4qAIV039672; Wed, 25 Jan 2006 15:52:10 +1100 (EST) (envelope-from pjeremy) Date: Wed, 25 Jan 2006 15:52:10 +1100 From: Peter Jeremy To: FreeBSD-gnats-submit@freebsd.org, freebsd-bugs@freebsd.org Message-ID: <20060125045209.GA39237@cirb503493.alcatel.com.au> References: <200601211033.k0LAX0Wf000865@server.vk2pj.dyndns.org> <200601211040.k0LAe7wT090838@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="9amGYk9869ThD9tj" Content-Disposition: inline In-Reply-To: <200601211040.k0LAe7wT090838@freefall.freebsd.org> X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc User-Agent: Mutt/1.5.11 Cc: Subject: Re: kern/92092: [PATCH] Panic if device with iicbus child is detached X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Jan 2006 04:52:14 -0000 --9amGYk9869ThD9tj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Following further investigating and comments from jhb@, I believe that my previous patch was overly complicated: Both detach methods already use bus_generic_detach() and this includes device_delete_child(), making the device_delete_child() calls superfluous. This makes both detach methods collapse down to bus_generic_detach(). The iicbb softc is now also superfluous since it was only used to cache the child device. The iicbus part of the following patch has been tested by detaching and re-attaching an iicbus parent device. Unfortunately, I don't think I've got anything that uses iicbb so I can't easily test that. An updated patch is attached. -- Peter Jeremy --9amGYk9869ThD9tj Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="iic.patch" Index: iicbb.c =================================================================== RCS file: /usr/ncvs/src/sys/dev/iicbus/iicbb.c,v retrieving revision 1.13 diff -u -r1.13 iicbb.c --- iicbb.c 24 Aug 2003 17:49:13 -0000 1.13 +++ iicbb.c 24 Jan 2006 08:36:10 -0000 @@ -59,13 +59,8 @@ #include "iicbus_if.h" #include "iicbb_if.h" -struct iicbb_softc { - device_t iicbus; -}; - static int iicbb_probe(device_t); static int iicbb_attach(device_t); -static int iicbb_detach(device_t); static int iicbb_print_child(device_t, device_t); static int iicbb_callback(device_t, int, caddr_t); @@ -79,7 +74,7 @@ /* device interface */ DEVMETHOD(device_probe, iicbb_probe), DEVMETHOD(device_attach, iicbb_attach), - DEVMETHOD(device_detach, iicbb_detach), + DEVMETHOD(device_detach, bus_generic_detach), /* bus interface */ DEVMETHOD(bus_print_child, iicbb_print_child), @@ -99,7 +94,7 @@ driver_t iicbb_driver = { "iicbb", iicbb_methods, - sizeof(struct iicbb_softc), + 0, }; devclass_t iicbb_devclass; @@ -113,13 +108,7 @@ static int iicbb_attach(device_t dev) { - struct iicbb_softc *sc = (struct iicbb_softc *)device_get_softc(dev); - - bzero(sc, sizeof(struct iicbb_softc)); - - sc->iicbus = device_add_child(dev, "iicbus", -1); - - if (!sc->iicbus) + if (device_add_child(dev, "iicbus", -1) == NULL) return (ENXIO); bus_generic_attach(dev); @@ -127,18 +116,6 @@ return (0); } -static int iicbb_detach(device_t dev) -{ - struct iicbb_softc *sc = (struct iicbb_softc *)device_get_softc(dev); - - if (sc->iicbus) { - bus_generic_detach(dev); - device_delete_child(dev, sc->iicbus); - } - - return (0); -} - static int iicbb_print_child(device_t bus, device_t dev) { Index: iicsmb.c =================================================================== RCS file: /usr/ncvs/src/sys/dev/iicbus/iicsmb.c,v retrieving revision 1.12 diff -u -r1.12 iicsmb.c --- iicsmb.c 10 Aug 2003 14:28:24 -0000 1.12 +++ iicsmb.c 24 Jan 2006 08:36:10 -0000 @@ -79,7 +79,6 @@ static int iicsmb_probe(device_t); static int iicsmb_attach(device_t); -static int iicsmb_detach(device_t); static void iicsmb_identify(driver_t *driver, device_t parent); static void iicsmb_intr(device_t dev, int event, char *buf); @@ -102,7 +101,7 @@ DEVMETHOD(device_identify, iicsmb_identify), DEVMETHOD(device_probe, iicsmb_probe), DEVMETHOD(device_attach, iicsmb_attach), - DEVMETHOD(device_detach, iicsmb_detach), + DEVMETHOD(device_detach, bus_generic_detach), /* bus interface */ DEVMETHOD(bus_driver_added, bus_generic_driver_added), @@ -163,19 +162,6 @@ return (0); } -static int -iicsmb_detach(device_t dev) -{ - struct iicsmb_softc *sc = (struct iicsmb_softc *)device_get_softc(dev); - - bus_generic_detach(dev); - if (sc->smbus) { - device_delete_child(dev, sc->smbus); - } - - return (0); -} - /* * iicsmb_intr() * --9amGYk9869ThD9tj--