Module Name:    src
Committed By:   snj
Date:           Tue Aug  1 23:10:00 UTC 2017

Modified Files:
        src/sys/dev/ic [netbsd-8]: rt2860.c rt2860var.h
        src/sys/dev/pci [netbsd-8]: if_ral_pci.c

Log Message:
Pull up following revision(s) (requested by maya in ticket #162):
        sys/dev/pci/if_ral_pci.c: revision 1.24
        sys/dev/ic/rt2860.c: revision 1.28
        sys/dev/ic/rt2860var.h: revision 1.5
enable rt2860 power management code
adjust to fit netbsd:
make suspend,resume functions match desired pmf* prototypes
remove wakeup/activate wrapper functions
avoid jumping to NULL on resume by initializing if_stop
the problem machine has other issues on resume, so there might be further
issues, but it's an improvement over a jump to NULL.
tested by Riccardo Mottola


To generate a diff of this commit:
cvs rdiff -u -r1.26.2.1 -r1.26.2.2 src/sys/dev/ic/rt2860.c
cvs rdiff -u -r1.4 -r1.4.6.1 src/sys/dev/ic/rt2860var.h
cvs rdiff -u -r1.23 -r1.23.10.1 src/sys/dev/pci/if_ral_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/rt2860.c
diff -u src/sys/dev/ic/rt2860.c:1.26.2.1 src/sys/dev/ic/rt2860.c:1.26.2.2
--- src/sys/dev/ic/rt2860.c:1.26.2.1	Tue Jul 25 02:08:31 2017
+++ src/sys/dev/ic/rt2860.c	Tue Aug  1 23:10:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rt2860.c,v 1.26.2.1 2017/07/25 02:08:31 snj Exp $	*/
+/*	$NetBSD: rt2860.c,v 1.26.2.2 2017/08/01 23:10:00 snj Exp $	*/
 /*	$OpenBSD: rt2860.c,v 1.90 2016/04/13 10:49:26 mpi Exp $	*/
 /*	$FreeBSD: head/sys/dev/ral/rt2860.c 306591 2016-10-02 20:35:55Z avos $ */
 
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rt2860.c,v 1.26.2.1 2017/07/25 02:08:31 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rt2860.c,v 1.26.2.2 2017/08/01 23:10:00 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/sockio.h>
@@ -74,6 +74,8 @@ int rt2860_debug = 0;
 #define MAXQS	6 /* Tx (4 EDCAs + HCCA + Mgt) and Rx rings */
 
 static void	rt2860_attachhook(device_t);
+static bool	rt2860_suspend(device_t self, const pmf_qual_t *qual);
+static bool	rt2860_wakeup(device_t self, const pmf_qual_t *qual);
 static int	rt2860_alloc_tx_ring(struct rt2860_softc *,
 		    struct rt2860_tx_ring *);
 static void	rt2860_reset_tx_ring(struct rt2860_softc *,
@@ -394,6 +396,7 @@ rt2860_attachhook(device_t self)
 	ifp->if_init = rt2860_init;
 	ifp->if_ioctl = rt2860_ioctl;
 	ifp->if_start = rt2860_start;
+	ifp->if_stop = rt2860_stop;
 	ifp->if_watchdog = rt2860_watchdog;
 	IFQ_SET_READY(&ifp->if_snd);
 	memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
@@ -434,7 +437,7 @@ rt2860_attachhook(device_t self)
 
 	ieee80211_announce(ic);
 
-	if (pmf_device_register(sc->sc_dev, NULL, NULL))
+	if (pmf_device_register(sc->sc_dev, rt2860_wakeup, rt2860_suspend))
 		pmf_class_network_register(sc->sc_dev, ifp);
 	else
 		aprint_error_dev(sc->sc_dev,
@@ -471,24 +474,31 @@ rt2860_detach(void *xsc)
 	return 0;
 }
 
-void
-rt2860_suspend(void *xsc)
+static bool
+rt2860_suspend(device_t self, const pmf_qual_t *qual)
 {
-	struct rt2860_softc *sc = xsc;
+	struct rt2860_softc *sc = device_private(self);
 	struct ifnet *ifp = &sc->sc_if;
 
 	if (ifp->if_flags & IFF_RUNNING)
 		rt2860_stop(ifp, 1);
+
+	return true;
 }
 
-void
-rt2860_wakeup(void *xsc)
+static bool
+rt2860_wakeup(device_t self, const pmf_qual_t *qual)
 {
-	struct rt2860_softc *sc = xsc;
+	struct rt2860_softc *sc = device_private(self);
 	struct ifnet *ifp = &sc->sc_if;
+	int s;
 
+	s = splnet();
 	if (ifp->if_flags & IFF_UP)
 		rt2860_init(ifp);
+	splx(s);
+
+	return true;
 }
 
 static int

Index: src/sys/dev/ic/rt2860var.h
diff -u src/sys/dev/ic/rt2860var.h:1.4 src/sys/dev/ic/rt2860var.h:1.4.6.1
--- src/sys/dev/ic/rt2860var.h:1.4	Thu Feb  2 10:05:35 2017
+++ src/sys/dev/ic/rt2860var.h	Tue Aug  1 23:10:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rt2860var.h,v 1.4 2017/02/02 10:05:35 nonaka Exp $	*/
+/*	$NetBSD: rt2860var.h,v 1.4.6.1 2017/08/01 23:10:00 snj Exp $	*/
 /*	$OpenBSD: rt2860var.h,v 1.23 2016/03/21 21:16:30 stsp Exp $	*/
 
 /*-
@@ -212,6 +212,4 @@ struct rt2860_softc {
 
 int	rt2860_attach(void *, int);
 int	rt2860_detach(void *);
-void	rt2860_suspend(void *);
-void	rt2860_wakeup(void *);
 int	rt2860_intr(void *);

Index: src/sys/dev/pci/if_ral_pci.c
diff -u src/sys/dev/pci/if_ral_pci.c:1.23 src/sys/dev/pci/if_ral_pci.c:1.23.10.1
--- src/sys/dev/pci/if_ral_pci.c:1.23	Wed Jul  6 14:28:51 2016
+++ src/sys/dev/pci/if_ral_pci.c	Tue Aug  1 23:10:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ral_pci.c,v 1.23 2016/07/06 14:28:51 christos Exp $	*/
+/*	$NetBSD: if_ral_pci.c,v 1.23.10.1 2017/08/01 23:10:00 snj Exp $	*/
 /*	$OpenBSD: if_ral_pci.c,v 1.24 2015/11/24 17:11:39 mpi Exp $  */
 
 /*-
@@ -21,7 +21,7 @@
  * PCI front-end for the Ralink RT2560/RT2561/RT2860/RT3090 driver.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ral_pci.c,v 1.23 2016/07/06 14:28:51 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ral_pci.c,v 1.23.10.1 2017/08/01 23:10:00 snj Exp $");
 
 
 #include <sys/param.h>
@@ -56,42 +56,24 @@ __KERNEL_RCSID(0, "$NetBSD: if_ral_pci.c
 #include <dev/pci/pcivar.h>
 #include <dev/pci/pcidevs.h>
 
-#define RAL_POWER_MANAGEMENT 0	/* Disabled for now */
-
 static struct ral_opns {
 	int	(*attach)(void *, int);
 	int	(*detach)(void *);
-#if RAL_POWER_MANAGEMENT
-	void	(*suspend)(void *);
-	void	(*wakeup)(void *);
-#endif
 	int	(*intr)(void *);
 
 }  ral_rt2560_opns = {
 	rt2560_attach,
 	rt2560_detach,
-#if RAL_POWER_MANAGEMENT
-	rt2560_suspend,
-	rt2560_wakeup,
-#endif
 	rt2560_intr
 
 }, ral_rt2661_opns = {
 	rt2661_attach,
 	rt2661_detach,
-#if RAL_POWER_MANAGEMENT
-	rt2661_suspend,
-	rt2661_wakeup,
-#endif
 	rt2661_intr
 
 }, ral_rt2860_opns = {
 	rt2860_attach,
 	rt2860_detach,
-#if RAL_POWER_MANAGEMENT
-	rt2860_suspend,
-	rt2860_wakeup,
-#endif
 	rt2860_intr
 };
 
@@ -116,15 +98,9 @@ struct ral_pci_softc {
 int	ral_pci_match(device_t, cfdata_t, void *);
 void	ral_pci_attach(device_t, device_t, void *);
 int	ral_pci_detach(device_t, int);
-#if RAL_POWER_MANAGEMENT
-int	ral_pci_activate(struct device *, devact_t);
-void	ral_pci_wakeup(struct ral_pci_softc *);
-#else
-#define ral_pci_activate NULL
-#endif
 
 CFATTACH_DECL_NEW(ral_pci, sizeof (struct ral_pci_softc),
-	ral_pci_match, ral_pci_attach, ral_pci_detach, ral_pci_activate);
+	ral_pci_match, ral_pci_attach, ral_pci_detach, NULL);
 
 static const struct ral_pci_matchid {
 	pci_vendor_id_t         ral_vendor;
@@ -276,33 +252,3 @@ ral_pci_detach(device_t self, int flags)
 
 	return 0;
 }
-
-#if RAL_POWER_MANAGEMENT
-int
-ral_pci_activate(struct device *self, devact_t act)
-{
-	struct ral_pci_softc *psc = (struct ral_pci_softc *)self;
-	struct rt2560_softc *sc = &psc->sc_sc;
-
-	switch (act) {
-	case DVACT_SUSPEND:
-		(*psc->sc_opns->suspend)(sc);
-		break;
-	case DVACT_WAKEUP:
-		ral_pci_wakeup(psc);
-		break;
-	}
-	return 0;
-}
-
-void
-ral_pci_wakeup(struct ral_pci_softc *psc)
-{
-	struct rt2560_softc *sc = &psc->sc_sc;
-	int s;
-
-	s = splnet();
-	(*psc->sc_opns->wakeup)(sc);
-	splx(s);
-}
-#endif

Reply via email to