From owner-freebsd-bugs@FreeBSD.ORG Wed Jan 25 05:00:20 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9DE4116A474 for ; Wed, 25 Jan 2006 05:00:20 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 61F4543D49 for ; Wed, 25 Jan 2006 05:00:20 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k0P50JNV036962 for ; Wed, 25 Jan 2006 05:00:19 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k0P50Jsn036961; Wed, 25 Jan 2006 05:00:19 GMT (envelope-from gnats) Date: Wed, 25 Jan 2006 05:00:19 GMT Message-Id: <200601250500.k0P50Jsn036961@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Peter Jeremy 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 Reply-To: Peter Jeremy List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Jan 2006 05:00:20 -0000 The following reply was made to PR kern/92092; it has been noted by GNATS. From: Peter Jeremy To: FreeBSD-gnats-submit@freebsd.org, freebsd-bugs@freebsd.org Cc: Subject: Re: kern/92092: [PATCH] Panic if device with iicbus child is detached Date: Wed, 25 Jan 2006 15:52:10 +1100 --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--