Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Add pmf(9) handler to malo(4) wireless driver
details: https://anonhg.NetBSD.org/src/rev/f7dd8127ec5c
branches: trunk
changeset: 780757:f7dd8127ec5c
user: degroote <degroote%NetBSD.org@localhost>
date: Sun Aug 05 09:16:54 2012 +0000
description:
Add pmf(9) handler to malo(4) wireless driver
diffstat:
sys/dev/ic/malo.c | 10 ++++------
sys/dev/ic/malovar.h | 2 ++
sys/dev/pci/if_malo_pci.c | 42 +++++++++++++++++++++++++++++++++++++-----
3 files changed, 43 insertions(+), 11 deletions(-)
diffs (132 lines):
diff -r 53f64b9e458b -r f7dd8127ec5c sys/dev/ic/malo.c
--- a/sys/dev/ic/malo.c Sun Aug 05 06:34:44 2012 +0000
+++ b/sys/dev/ic/malo.c Sun Aug 05 09:16:54 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: malo.c,v 1.2 2012/07/30 20:30:41 degroote Exp $ */
+/* $NetBSD: malo.c,v 1.3 2012/08/05 09:16:54 degroote Exp $ */
/* $OpenBSD: malo.c,v 1.92 2010/08/27 17:08:00 jsg Exp $ */
/*
@@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: malo.c,v 1.2 2012/07/30 20:30:41 degroote Exp $");
+__KERNEL_RCSID(0, "$NetBSD: malo.c,v 1.3 2012/08/05 09:16:54 degroote Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -246,8 +246,6 @@
#define malo_ctl_barrier(sc, t) \
bus_space_barrier((sc)->sc_mem2_bt, (sc)->sc_mem2_bh, 0x0c00, 0xff, (t))
-static int malo_init(struct ifnet *);
-static void malo_stop(struct ifnet *, int disable);
static int malo_alloc_cmd(struct malo_softc *sc);
static void malo_free_cmd(struct malo_softc *sc);
static void malo_send_cmd(struct malo_softc *sc, bus_addr_t addr);
@@ -832,7 +830,7 @@
}
}
-static int
+int
malo_init(struct ifnet *ifp)
{
struct malo_softc *sc = ifp->if_softc;
@@ -1049,7 +1047,7 @@
}
}
-static void
+void
malo_stop(struct ifnet* ifp, int disable)
{
struct malo_softc *sc = ifp->if_softc;
diff -r 53f64b9e458b -r f7dd8127ec5c sys/dev/ic/malovar.h
--- a/sys/dev/ic/malovar.h Sun Aug 05 06:34:44 2012 +0000
+++ b/sys/dev/ic/malovar.h Sun Aug 05 09:16:54 2012 +0000
@@ -129,3 +129,5 @@
int malo_intr(void *arg);
int malo_attach(struct malo_softc *sc);
int malo_detach(void *arg);
+int malo_init(struct ifnet *);
+void malo_stop(struct ifnet *, int disable);
diff -r 53f64b9e458b -r f7dd8127ec5c sys/dev/pci/if_malo_pci.c
--- a/sys/dev/pci/if_malo_pci.c Sun Aug 05 06:34:44 2012 +0000
+++ b/sys/dev/pci/if_malo_pci.c Sun Aug 05 09:16:54 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_malo_pci.c,v 1.2 2012/07/30 20:30:41 degroote Exp $ */
+/* $NetBSD: if_malo_pci.c,v 1.3 2012/08/05 09:16:54 degroote Exp $ */
/* $OpenBSD: if_malo_pci.c,v 1.6 2010/08/28 23:19:29 deraadt Exp $ */
/*
@@ -22,7 +22,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_malo_pci.c,v 1.2 2012/07/30 20:30:41 degroote Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_malo_pci.c,v 1.3 2012/08/05 09:16:54 degroote Exp $");
#include <sys/param.h>
#include <sys/sockio.h>
@@ -58,7 +58,9 @@
static int malo_pci_match(device_t parent, cfdata_t match, void *aux);
static void malo_pci_attach(device_t, device_t, void *);
-static int malo_pci_detach(struct device *, int);
+static int malo_pci_detach(device_t, int);
+static bool malo_pci_suspend(device_t, const pmf_qual_t *);
+static bool malo_pci_resume(device_t, const pmf_qual_t *);
struct malo_pci_softc {
struct malo_softc sc_malo;
@@ -166,12 +168,17 @@
aprint_normal_dev(self, "interrupting at %s\n", intrstr);
malo_attach(sc);
+
+ if (pmf_device_register(self, malo_pci_suspend, malo_pci_resume))
+ pmf_class_network_register(self, &sc->sc_if);
+ else
+ aprint_error_dev(self, "couldn't establish power handler\n");
}
int
-malo_pci_detach(struct device *self, int flags)
+malo_pci_detach(device_t self, int flags)
{
- struct malo_pci_softc *psc = (struct malo_pci_softc *)self;
+ struct malo_pci_softc *psc = device_private(self);
struct malo_softc *sc = &psc->sc_malo;
malo_detach(sc);
@@ -179,3 +186,28 @@
return (0);
}
+
+static bool
+malo_pci_suspend(device_t self, const pmf_qual_t *qual)
+{
+ struct malo_pci_softc *psc = device_private(self);
+ struct malo_softc *sc = &psc->sc_malo;
+ struct ifnet *ifp = &sc->sc_if;
+
+ malo_stop(ifp, 1);
+
+ return true;
+}
+
+static bool
+malo_pci_resume(device_t self, const pmf_qual_t *qual)
+{
+ struct malo_pci_softc *psc = device_private(self);
+ struct malo_softc *sc = &psc->sc_malo;
+ struct ifnet *ifp = &sc->sc_if;
+
+ if (ifp->if_flags & IFF_UP)
+ malo_init(ifp);
+
+ return true;
+}
Home |
Main Index |
Thread Index |
Old Index