diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2010-08-27 18:25:48 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2010-08-27 18:25:48 +0000 |
commit | ff6aa40db64e877db2d485a113deb8a70e151916 (patch) | |
tree | 61b5b25b2739e20cb5f0a6c62bef5b491b6b222f /sys | |
parent | e8ad753752758c2cfa85f8c08dd41f982b096c56 (diff) |
Since the pci-specific activate function does nothing, move it to fxp.c.
Then it is possible for fxp_powerhook to use it.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/cardbus/if_fxp_cardbus.c | 3 | ||||
-rw-r--r-- | sys/dev/ic/fxp.c | 57 | ||||
-rw-r--r-- | sys/dev/ic/fxpvar.h | 5 | ||||
-rw-r--r-- | sys/dev/pci/if_fxp_pci.c | 38 |
4 files changed, 43 insertions, 60 deletions
diff --git a/sys/dev/cardbus/if_fxp_cardbus.c b/sys/dev/cardbus/if_fxp_cardbus.c index 39d3a96dc29..da4aad49462 100644 --- a/sys/dev/cardbus/if_fxp_cardbus.c +++ b/sys/dev/cardbus/if_fxp_cardbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_fxp_cardbus.c,v 1.27 2010/03/27 21:40:13 jsg Exp $ */ +/* $OpenBSD: if_fxp_cardbus.c,v 1.28 2010/08/27 18:25:46 deraadt Exp $ */ /* $NetBSD: if_fxp_cardbus.c,v 1.12 2000/05/08 18:23:36 thorpej Exp $ */ /* @@ -46,6 +46,7 @@ #include <sys/kernel.h> #include <sys/timeout.h> #include <sys/device.h> +#include <sys/workq.h> #include <net/if.h> #include <net/if_dl.h> diff --git a/sys/dev/ic/fxp.c b/sys/dev/ic/fxp.c index 76e5c073d88..415531efa63 100644 --- a/sys/dev/ic/fxp.c +++ b/sys/dev/ic/fxp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fxp.c,v 1.102 2010/08/06 14:11:42 deraadt Exp $ */ +/* $OpenBSD: fxp.c,v 1.103 2010/08/27 18:25:47 deraadt Exp $ */ /* $NetBSD: if_fxp.c,v 1.2 1997/06/05 02:01:55 thorpej Exp $ */ /* @@ -47,6 +47,7 @@ #include <sys/socket.h> #include <sys/syslog.h> #include <sys/timeout.h> +#include <sys/workq.h> #include <net/if.h> #include <net/if_dl.h> @@ -282,34 +283,46 @@ fxp_write_eeprom(struct fxp_softc *sc, u_short *data, int offset, int words) * Operating system-specific autoconfiguration glue *************************************************************/ -void fxp_power(int, void *); - struct cfdriver fxp_cd = { NULL, "fxp", DV_IFNET }; -/* - * Power handler routine. Called when the system is transitioning - * into/out of power save modes. The main purpose of this routine - * is to shut off receiver DMA so it doesn't clobber kernel memory - * at the wrong time. - */ -void -fxp_power(int why, void *arg) +void fxp_powerhook(int, void *); + +int +fxp_activate(struct device *self, int act) { - struct fxp_softc *sc = arg; - struct ifnet *ifp; - int s; + struct fxp_softc *sc = (struct fxp_softc *)self; + struct ifnet *ifp = &sc->sc_arpcom.ac_if; - s = splnet(); - if (why != PWR_RESUME) - fxp_stop(sc, 0, 0); - else { - ifp = &sc->sc_arpcom.ac_if; + switch (act) { + case DVACT_SUSPEND: + if (ifp->if_flags & IFF_RUNNING) + fxp_stop(sc, 1, 0); + config_activate_children(self, act); + break; + case DVACT_RESUME: + config_activate_children(self, act); if (ifp->if_flags & IFF_UP) - fxp_init(sc); + workq_queue_task(NULL, &sc->sc_resume_wqt, 0, + fxp_resume, sc, NULL); + break; } - splx(s); + return 0; +} + +void +fxp_resume(void *arg1, void *arg2) +{ + struct fxp_softc *sc = arg1; + + fxp_init(sc); +} + +void +fxp_powerhook(int why, void *arg) +{ + fxp_activate(arg, why); } /************************************************************* @@ -500,7 +513,7 @@ fxp_attach(struct fxp_softc *sc, const char *intrstr) * doing so could allow DMA to corrupt kernel memory during the * reboot before the driver initializes. */ - sc->sc_powerhook = powerhook_establish(fxp_power, sc); + sc->sc_powerhook = powerhook_establish(fxp_powerhook, sc); /* * Initialize timeout for statistics update. diff --git a/sys/dev/ic/fxpvar.h b/sys/dev/ic/fxpvar.h index 66ddb3ca3f1..bc78a626d70 100644 --- a/sys/dev/ic/fxpvar.h +++ b/sys/dev/ic/fxpvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fxpvar.h,v 1.32 2010/08/06 14:11:43 deraadt Exp $ */ +/* $OpenBSD: fxpvar.h,v 1.33 2010/08/27 18:25:47 deraadt Exp $ */ /* $NetBSD: if_fxpvar.h,v 1.1 1997/06/05 02:01:58 thorpej Exp $ */ /* @@ -142,6 +142,7 @@ struct fxp_softc { u_int16_t sc_bundle_max; /* max # frames per interrupt (ucode) */ u_int16_t sc_min_size_mask; /* bit-mask describing the minimum * size of frame that will be bundled */ + struct workq_task sc_resume_wqt; }; /* Macros to ease CSR access. */ @@ -159,6 +160,8 @@ extern int fxp_attach(struct fxp_softc *, const char *); void fxp_detach(struct fxp_softc *); void fxp_init(void *); void fxp_stop(struct fxp_softc *, int, int); +int fxp_activate(struct device *, int); +void fxp_resume(void *, void *); #define FXP_RXMAP_GET(sc) ((sc)->sc_rxmaps[(sc)->sc_rxfree++]) #define FXP_RXMAP_PUT(sc,map) ((sc)->sc_rxmaps[--(sc)->sc_rxfree] = (map)) diff --git a/sys/dev/pci/if_fxp_pci.c b/sys/dev/pci/if_fxp_pci.c index 6c7d4a9ba3d..048d357087c 100644 --- a/sys/dev/pci/if_fxp_pci.c +++ b/sys/dev/pci/if_fxp_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_fxp_pci.c,v 1.55 2010/08/07 07:08:34 deraadt Exp $ */ +/* $OpenBSD: if_fxp_pci.c,v 1.56 2010/08/27 18:25:47 deraadt Exp $ */ /* * Copyright (c) 1995, David Greenman @@ -82,19 +82,16 @@ int fxp_pci_match(struct device *, void *, void *); void fxp_pci_attach(struct device *, struct device *, void *); int fxp_pci_detach(struct device *, int); -int fxp_pci_activate(struct device *, int); -void fxp_pci_resume(void *, void *); struct fxp_pci_softc { struct fxp_softc psc_softc; pci_chipset_tag_t psc_pc; bus_size_t psc_mapsize; - struct workq_task psc_resume_wqt; }; struct cfattach fxp_pci_ca = { sizeof(struct fxp_pci_softc), fxp_pci_match, fxp_pci_attach, - fxp_pci_detach, fxp_pci_activate + fxp_pci_detach, fxp_activate }; const struct pci_matchid fxp_pci_devices[] = { @@ -280,34 +277,3 @@ fxp_pci_detach(struct device *self, int flags) return (0); } - -int -fxp_pci_activate(struct device *self, int act) -{ - struct fxp_pci_softc *psc = (void *)self; - struct fxp_softc *sc = &psc->psc_softc; - struct ifnet *ifp = &sc->sc_arpcom.ac_if; - - switch (act) { - case DVACT_SUSPEND: - if (ifp->if_flags & IFF_RUNNING) - fxp_stop(sc, 1, 0); - config_activate_children(self, act); - break; - case DVACT_RESUME: - config_activate_children(self, act); - if (ifp->if_flags & IFF_UP) - workq_queue_task(NULL, &psc->psc_resume_wqt, 0, - fxp_pci_resume, sc, NULL); - break; - } - return (0); -} - -void -fxp_pci_resume(void *arg1, void *arg2) -{ - struct fxp_softc *sc = arg1; - - fxp_init(sc); -} |