From 72d14235f902d9cadbd7249570c53f4cb4113b14 Mon Sep 17 00:00:00 2001 From: deraadt Date: Thu, 5 Aug 2010 07:57:04 +0000 Subject: [PATCH] ca_activate function for suspend/resume; tested by mlarkin on a Davicom DM9102. (bit of noise on suspend or resume, but that can be dealt with later) --- sys/dev/ic/dc.c | 4 +--- sys/dev/ic/dcreg.h | 6 +++++- sys/dev/pci/if_dc_pci.c | 28 ++++++++++++++++++++++++++-- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/sys/dev/ic/dc.c b/sys/dev/ic/dc.c index c2f3e462a97..705e0dda779 100644 --- a/sys/dev/ic/dc.c +++ b/sys/dev/ic/dc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dc.c,v 1.115 2010/07/02 15:47:54 blambert Exp $ */ +/* $OpenBSD: dc.c,v 1.116 2010/08/05 07:57:04 deraadt Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -144,8 +144,6 @@ void dc_tick(void *); void dc_tx_underrun(struct dc_softc *); void dc_start(struct ifnet *); int dc_ioctl(struct ifnet *, u_long, caddr_t); -void dc_init(void *); -void dc_stop(struct dc_softc *, int); void dc_watchdog(struct ifnet *); int dc_ifmedia_upd(struct ifnet *); void dc_ifmedia_sts(struct ifnet *, struct ifmediareq *); diff --git a/sys/dev/ic/dcreg.h b/sys/dev/ic/dcreg.h index 81f840dfbfe..79b84e8c5f8 100644 --- a/sys/dev/ic/dcreg.h +++ b/sys/dev/ic/dcreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dcreg.h,v 1.45 2009/08/10 20:29:54 deraadt Exp $ */ +/* $OpenBSD: dcreg.h,v 1.46 2010/08/05 07:57:04 deraadt Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -1049,6 +1049,10 @@ struct dc_eblock_reset { extern void dc_attach(struct dc_softc *); extern int dc_detach(struct dc_softc *); extern int dc_intr(void *); + +void dc_init(void *); +void dc_stop(struct dc_softc *, int); + extern void dc_reset(struct dc_softc *); extern void dc_eeprom_width(struct dc_softc *); extern void dc_read_srom(struct dc_softc *, int); diff --git a/sys/dev/pci/if_dc_pci.c b/sys/dev/pci/if_dc_pci.c index 76ab92df416..5c485a2a51d 100644 --- a/sys/dev/pci/if_dc_pci.c +++ b/sys/dev/pci/if_dc_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_dc_pci.c,v 1.65 2009/10/15 17:54:56 deraadt Exp $ */ +/* $OpenBSD: if_dc_pci.c,v 1.66 2010/08/05 07:57:05 deraadt Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -125,6 +125,7 @@ struct dc_type dc_devs[] = { int dc_pci_match(struct device *, void *, void *); void dc_pci_attach(struct device *, struct device *, void *); int dc_pci_detach(struct device *, int); +int dc_pci_activate(struct device *, int); void dc_pci_acpi(struct device *, void *); struct dc_pci_softc { @@ -573,6 +574,29 @@ dc_pci_detach(struct device *self, int flags) return (0); } +int +dc_pci_activate(struct device *self, int act) +{ + struct dc_pci_softc *psc = (void *)self; + struct dc_softc *sc = &psc->psc_softc; + struct ifnet *ifp = &sc->sc_arpcom.ac_if; + + switch (act) { + case DVACT_SUSPEND: + if (ifp->if_flags & IFF_RUNNING) + dc_stop(sc, 0); + config_activate_children(self, act); + break; + case DVACT_RESUME: + config_activate_children(self, act); + if (ifp->if_flags & IFF_UP) + dc_init(sc); + break; + } + return (0); +} + struct cfattach dc_pci_ca = { - sizeof(struct dc_softc), dc_pci_match, dc_pci_attach, dc_pci_detach + sizeof(struct dc_softc), dc_pci_match, dc_pci_attach, dc_pci_detach, + dc_pci_activate }; -- 2.20.1