Re: Panic due to deleting devices twice

From: Peter Jeremy <PeterJeremy_at_optushome.com.au>
Date: Tue, 24 Jan 2006 08:41:51 +1100
On Mon, 2006-Jan-23 16:18:03 -0500, John Baldwin wrote:
>On Saturday 21 January 2006 02:07, Peter Jeremy wrote:
>> Looking at the iicsmb code, it appears that iicbb and iicsmb both
>> cache and explicitly delete child devices and therefore both need
>> bus_child_detached methods.  Is this correct?  Is there a simpler
>> alternative?
>
>Can they just call bus_generic_detach() instead and not call 
>device_delete_child()?

The existing code does both:

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
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);
}

Maybe a better solution in both cases is to just map device_detach to
bus_generic_detach() - in which case my patch in kern/92092 is overly
baroque.  I was hoping that someone might shed some insight into why
it was done that way in the first case.

-- 
Peter Jeremy
Received on Mon Jan 23 2006 - 20:41:57 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:51 UTC