kern/92092: [PATCH] Panic if device with iicbus child is detached

Peter Jeremy PeterJeremy at optushome.com.au
Tue Jan 24 21:00:20 PST 2006


The following reply was made to PR kern/92092; it has been noted by GNATS.

From: Peter Jeremy <PeterJeremy at optushome.com.au>
To: FreeBSD-gnats-submit at freebsd.org, freebsd-bugs at 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--


More information about the freebsd-bugs mailing list