Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys/dev/pci



On Sat, Sep 05, 2009 at 02:13:50PM +0000, Izumi Tsutsui wrote:
> Module Name:  src
> Committed By: tsutsui
> Date:         Sat Sep  5 14:13:50 UTC 2009
> 
> Modified Files:
>       src/sys/dev/pci: if_an_pci.c if_ath_pci.c if_fxp_pci.c if_gem_pci.c
>           if_rtk_pci.c if_rtw_pci.c if_wi_pci.c
> 
> Log Message:
> Invert logic around nested pmf(9) registrations for readability.
> 
> XXX: should these pmf(9) calls be moved into MI attach functions
> XXX: using function pointers for suspend and resume passed via softc?

I think that we would add callbacks to many, many softc's, like we did
with the enable/disable routines.  Lots of code would be duplicated.  I
am gradually replacing those routines with self-suspension.  PMF should
handle bus-independent/bus-dependent suspend/resume, too.

Let the programmer of drivers add a bus-dependent PMF hook in the bus
attachment routine, and a bus-independent PMF hook in the generic attach
routine.  Something like this, for example,

static bool
rtw_pci_suspend(device_t self ...)
{
        /* ... */
        /* no call to rtw_suspend, here! */
        /* ... */
        return true;
}

static bool
rtw_pci_resume(device_t self ...)
{
        /* ... */
        /* no call to rtw_resume, here! */
        /* ... */
        return true;
}

static void
rtw_pci_attach(device_t parent, device_t self, void *aux)
{
        /* ... */
        pmf_device_register_for_bus(self, rtw_pci_suspend, rtw_pci_resume);
        /* ... */
}

void
rtw_attach(struct rtw_softc *sc)
{
        /* ... */
        if (pmf_device_register(self, rtw_suspend, rtw_resume)) {
                pmf_class_network_register(self, &sc->sc_if);
                /* ... */
        }
        /* ... */
}

Dave

-- 
David Young             OJC Technologies
dyoung%ojctech.com@localhost      Urbana, IL * (217) 278-3933


Home | Main Index | Thread Index | Old Index