Subject: Re: detach() function in struct cfdata and child devices
To: Gary Thorpe <gathorpe79@yahoo.com>
From: Jared D. McNeill <jmcneill@invisible.ca>
List: tech-kern
Date: 10/23/2002 16:35:12
On Wed, 23 Oct 2002, Gary Thorpe wrote:
> Hi,
> When the detach function is called for a device that has children, it
> should probably detach all of its children before it detachs(yes or
> no?). Is information regarding children devices stored in the
> autoconfiguration framework, so that a parent can locate and detach
> it's children without any additional code or is this something that
> each device has to implement itself?

The driver should take care of it itself, and store references to its
children in its softc structure.

Example from sys/dev/pcmcia/esl_pcmcia.c:

int
esl_pcmcia_detach(struct device *self, int flags)
{
        struct esl_pcmcia_softc *esc = (void *)self;
        int rv = 0;

        if (esc->sc_io_window == -1)
                /* Nothing to detach */
                return (0);

        if (esc->sc_opldev != NULL)
                config_detach(esc->sc_opldev, flags);
        if (esc->sc_audiodev != NULL)
                rv = config_detach(esc->sc_audiodev, flags);
        if (rv)
                return (rv);

        /* unmap i/o window and i/o space */
        pcmcia_io_unmap(esc->sc_pf, esc->sc_io_window);
        pcmcia_io_free(esc->sc_pf, &esc->sc_pcioh);

        return (rv);
}


Hope this answers your question.

Cheers,
Jared

-
Jared D. McNeill -- jmcneillATinvisibleDOTca
                    jmcneillATnetbsdDOTorg