svn commit: r288502 - head/sys/dev/usb/wlan

Adrian Chadd adrian at FreeBSD.org
Fri Oct 2 15:26:34 UTC 2015


Author: adrian
Date: Fri Oct  2 15:26:33 2015
New Revision: 288502
URL: https://svnweb.freebsd.org/changeset/base/288502

Log:
  rum(4): move common part of rum_bbp_write() and rum_bbp_read() into rum_bbp_busy().
  
  Submitted by:	<s3erios at gmail.com>
  Differential Revision:	https://reviews.freebsd.org/D3608

Modified:
  head/sys/dev/usb/wlan/if_rum.c

Modified: head/sys/dev/usb/wlan/if_rum.c
==============================================================================
--- head/sys/dev/usb/wlan/if_rum.c	Fri Oct  2 15:22:00 2015	(r288501)
+++ head/sys/dev/usb/wlan/if_rum.c	Fri Oct  2 15:26:33 2015	(r288502)
@@ -186,6 +186,7 @@ static void		rum_read_multi(struct rum_s
 static usb_error_t	rum_write(struct rum_softc *, uint16_t, uint32_t);
 static usb_error_t	rum_write_multi(struct rum_softc *, uint16_t, void *,
 			    size_t);
+static int		rum_bbp_busy(struct rum_softc *);
 static void		rum_bbp_write(struct rum_softc *, uint8_t, uint8_t);
 static uint8_t		rum_bbp_read(struct rum_softc *, uint8_t);
 static void		rum_rf_write(struct rum_softc *, uint8_t, uint32_t);
@@ -1410,21 +1411,31 @@ rum_write_multi(struct rum_softc *sc, ui
 	return (USB_ERR_NORMAL_COMPLETION);
 }
 
-static void
-rum_bbp_write(struct rum_softc *sc, uint8_t reg, uint8_t val)
+static int
+rum_bbp_busy(struct rum_softc *sc)
 {
-	uint32_t tmp;
 	int ntries;
 
-	DPRINTFN(2, "reg=0x%08x\n", reg);
-
 	for (ntries = 0; ntries < 100; ntries++) {
 		if (!(rum_read(sc, RT2573_PHY_CSR3) & RT2573_BBP_BUSY))
 			break;
 		if (rum_pause(sc, hz / 100))
 			break;
 	}
-	if (ntries == 100) {
+	if (ntries == 100)
+		return (ETIMEDOUT);
+
+	return (0);
+}
+
+static void
+rum_bbp_write(struct rum_softc *sc, uint8_t reg, uint8_t val)
+{
+	uint32_t tmp;
+
+	DPRINTFN(2, "reg=0x%08x\n", reg);
+
+	if (rum_bbp_busy(sc) != 0) {
 		device_printf(sc->sc_dev, "could not write to BBP\n");
 		return;
 	}
@@ -1441,13 +1452,7 @@ rum_bbp_read(struct rum_softc *sc, uint8
 
 	DPRINTFN(2, "reg=0x%08x\n", reg);
 
-	for (ntries = 0; ntries < 100; ntries++) {
-		if (!(rum_read(sc, RT2573_PHY_CSR3) & RT2573_BBP_BUSY))
-			break;
-		if (rum_pause(sc, hz / 100))
-			break;
-	}
-	if (ntries == 100) {
+	if (rum_bbp_busy(sc) != 0) {
 		device_printf(sc->sc_dev, "could not read BBP\n");
 		return 0;
 	}


More information about the svn-src-all mailing list