Module Name:    src
Committed By:   degroote
Date:           Sun Aug  5 09:16:54 UTC 2012

Modified Files:
        src/sys/dev/ic: malo.c malovar.h
        src/sys/dev/pci: if_malo_pci.c

Log Message:
Add pmf(9) handler to malo(4) wireless driver


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/malo.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/ic/malovar.h
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/pci/if_malo_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/malo.c
diff -u src/sys/dev/ic/malo.c:1.2 src/sys/dev/ic/malo.c:1.3
--- src/sys/dev/ic/malo.c:1.2	Mon Jul 30 20:30:41 2012
+++ src/sys/dev/ic/malo.c	Sun Aug  5 09:16:54 2012
@@ -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 @@ struct malo_cmd_slot {
 #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 @@ malo_free_tx_ring(struct malo_softc *sc,
 	}
 }
 
-static int
+int
 malo_init(struct ifnet *ifp)
 {
 	struct malo_softc *sc = ifp->if_softc;
@@ -1049,7 +1047,7 @@ malo_start(struct ifnet *ifp)
 	}
 }
 
-static void
+void
 malo_stop(struct ifnet* ifp, int disable)
 {
 	struct malo_softc *sc = ifp->if_softc;

Index: src/sys/dev/ic/malovar.h
diff -u src/sys/dev/ic/malovar.h:1.1 src/sys/dev/ic/malovar.h:1.2
--- src/sys/dev/ic/malovar.h:1.1	Mon Jul 30 18:57:19 2012
+++ src/sys/dev/ic/malovar.h	Sun Aug  5 09:16:54 2012
@@ -129,3 +129,5 @@ struct malo_softc {
 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);

Index: src/sys/dev/pci/if_malo_pci.c
diff -u src/sys/dev/pci/if_malo_pci.c:1.2 src/sys/dev/pci/if_malo_pci.c:1.3
--- src/sys/dev/pci/if_malo_pci.c:1.2	Mon Jul 30 20:30:41 2012
+++ src/sys/dev/pci/if_malo_pci.c	Sun Aug  5 09:16:54 2012
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: if_malo_pci.
 
 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 @@ malo_pci_attach(device_t parent, device_
 	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 @@ malo_pci_detach(struct device *self, int
 
 	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;
+}

Reply via email to