PERFORCE change 154040 for review

Kevin Lo kevlo at FreeBSD.org
Thu Dec 4 01:36:47 PST 2008


http://perforce.freebsd.org/chv.cgi?CH=154040

Change 154040 by kevlo at kevlo_wsl on 2008/12/04 09:35:59

	Use usbd_delay_ms() instead of rolling our own

Affected files ...

.. //depot/projects/vap/sys/dev/usb/if_urtw.c#5 edit

Differences ...

==== //depot/projects/vap/sys/dev/usb/if_urtw.c#5 (text+ko) ====

@@ -924,13 +924,6 @@
 	return (error);
 }
 
-static void
-urtw_delay_ms(int t)
-{
-
-	DELAY(t * 1000);
-}
-
 static usbd_status
 urtw_8225_write_c(struct urtw_softc *sc, uint8_t addr, uint16_t data)
 {
@@ -959,7 +952,7 @@
 	DELAY(10);
 	urtw_write16_m(sc, URTW_RF_PINS_OUTPUT, d80 | URTW_BB_HOST_BANG_EN);
 	urtw_write16_m(sc, URTW_RF_PINS_SELECT, d84);
-	urtw_delay_ms(2);
+	usbd_delay_ms(sc->sc_udev, 2);
 fail:
 	return (error);
 }
@@ -975,7 +968,7 @@
 	urtw_write16_m(sc, URTW_RF_PINS_OUTPUT, 0x0080);
 	urtw_write16_m(sc, URTW_RF_PINS_SELECT, 0x0080);
 	urtw_write16_m(sc, URTW_RF_PINS_ENABLE, 0x0080);
-	urtw_delay_ms(1100);
+	usbd_delay_ms(sc->sc_udev, 1100);
 
 	urtw_8225_write(sc, 0x0, 0x1b7);
 
@@ -1538,7 +1531,7 @@
 	error = urtw_intr_disable(sc);
 	if (error)
 		goto fail;
-	urtw_delay_ms(200);
+	usbd_delay_ms(sc->sc_udev, 200);
 
 	error = urtw_write8e(sc, 0x18, 0x10);
 	if (error != 0)
@@ -1549,12 +1542,12 @@
 	error = urtw_write8e(sc, 0x18, 0x00);
 	if (error != 0)
 		goto fail;
-	urtw_delay_ms(200);
+	usbd_delay_ms(sc->sc_udev, 200);
 
 	urtw_read8_m(sc, URTW_CMD, &data);
 	data = (data & 2) | URTW_CMD_RST;
 	urtw_write8_m(sc, URTW_CMD, data);
-	urtw_delay_ms(200);
+	usbd_delay_ms(sc->sc_udev, 200);
 
 	urtw_read8_m(sc, URTW_CMD, &data);
 	if (data & URTW_CMD_RST) {
@@ -1565,7 +1558,7 @@
 	error = urtw_set_mode(sc, URTW_EPROM_CMD_LOAD);
 	if (error)
 		goto fail;
-	urtw_delay_ms(200);
+	usbd_delay_ms(sc->sc_udev, 200);
 
 	error = urtw_8180_set_anaparam(sc, URTW_8225_ANAPARAM_ON);
 	if (error)
@@ -1669,7 +1662,7 @@
 		break;
 	case URTW_LED_POWER_ON_BLINK:
 		urtw_led_on(sc, URTW_LED_GPIO);
-		urtw_delay_ms(100);
+		usbd_delay_ms(sc->sc_udev, 100);
 		urtw_led_off(sc, URTW_LED_GPIO);
 		break;
 	default:
@@ -2538,8 +2531,8 @@
 	urtw_write16_m(sc, URTW_RF_PINS_SELECT, 0x80);
 	urtw_write16_m(sc, URTW_RF_PINS_ENABLE, 0x80);
 
-	urtw_delay_ms(100);
-	urtw_delay_ms(1000);
+	usbd_delay_ms(sc->sc_udev, 100);
+	usbd_delay_ms(sc->sc_udev, 1000);
 fail:
 	return (error);
 }
@@ -2565,7 +2558,7 @@
 	urtw_write8_m(sc, 0x7e, ((phyw & 0x00ff0000) >> 16));
 	urtw_write8_m(sc, 0x7d, ((phyw & 0x0000ff00) >> 8));
 	urtw_write8_m(sc, 0x7c, ((phyw & 0x000000ff)));
-	urtw_delay_ms(1);
+	usbd_delay_ms(sc->sc_udev, 1);
 fail:
 	return (error);
 }
@@ -2626,7 +2619,7 @@
 		urtw_8187_write_phy_cck(sc, 0x44 + i,
 		    cck_pwltable[idx * 8 + i]);
 	}
-	urtw_delay_ms(1);
+	usbd_delay_ms(sc->sc_udev, 1);
 	
 	/* OFDM power setting */
 	ofdm_pwrlvl = (ofdm_pwrlvl > (ofdm_pwrlvl_max - ofdm_pwrlvl_min)) ?
@@ -2647,7 +2640,7 @@
 	    urtw_8225_tx_gain_cck_ofdm[set] >> 1);
 	urtw_8187_write_phy_ofdm(sc, 0x5, urtw_8225_txpwr_ofdm[idx]);
 	urtw_8187_write_phy_ofdm(sc, 0x7, urtw_8225_txpwr_ofdm[idx]);
-	urtw_delay_ms(1);
+	usbd_delay_ms(sc->sc_udev, 1);
 fail:
 	return (error);
 }
@@ -2658,7 +2651,7 @@
 	usbd_status error;
 
 	urtw_write8_m(sc, URTW_TX_ANTENNA, ant);
-	urtw_delay_ms(1);
+	usbd_delay_ms(sc->sc_udev, 1);
 fail:
 	return (error);
 }
@@ -2695,18 +2688,18 @@
 	error = urtw_8185_rf_pins_enable(sc);
 	if (error)
 		goto fail;
-	urtw_delay_ms(1000);
+	usbd_delay_ms(sc->sc_udev, 1000);
 
 	for (i = 0; i < N(urtw_8225_rf_part1); i++) {
 		urtw_8225_write(sc, urtw_8225_rf_part1[i].reg,
 		    urtw_8225_rf_part1[i].val);
-		urtw_delay_ms(1);
+		usbd_delay_ms(sc->sc_udev, 1);
 	}
-	urtw_delay_ms(100);
+	usbd_delay_ms(sc->sc_udev, 100);
 	urtw_8225_write(sc, 0x2, 0xc4d);
-	urtw_delay_ms(200);
+	usbd_delay_ms(sc->sc_udev, 200);
 	urtw_8225_write(sc, 0x2, 0x44d);
-	urtw_delay_ms(200);
+	usbd_delay_ms(sc->sc_udev, 200);
 	urtw_8225_write(sc, 0x0, 0x127);
 	
 	for (i = 0; i < 95; i++) {
@@ -2719,15 +2712,15 @@
 	
 	for (i = 0; i < 128; i++) {
 		urtw_8187_write_phy_ofdm(sc, 0xb, urtw_8225_agc[i]);
-		urtw_delay_ms(1);
+		usbd_delay_ms(sc->sc_udev, 1);
 		urtw_8187_write_phy_ofdm(sc, 0xa, (uint8_t)i + 0x80);
-		urtw_delay_ms(1);
+		usbd_delay_ms(sc->sc_udev, 1);
 	}
 
 	for (i = 0; i < N(urtw_8225_rf_part2); i++) {
 		urtw_8187_write_phy_ofdm(sc, urtw_8225_rf_part2[i].reg,
 		    urtw_8225_rf_part2[i].val);
-		urtw_delay_ms(1);
+		usbd_delay_ms(sc->sc_udev, 1);
 	}
 	
 	error = urtw_8225_setgain(sc, 4);
@@ -2737,7 +2730,7 @@
 	for (i = 0; i < N(urtw_8225_rf_part3); i++) {
 		urtw_8187_write_phy_cck(sc, urtw_8225_rf_part3[i].reg,
 		    urtw_8225_rf_part3[i].val);
-		urtw_delay_ms(1);
+		usbd_delay_ms(sc->sc_udev, 1);
 	}
 
 	urtw_write8_m(sc, 0x5b, 0x0d);
@@ -2747,9 +2740,9 @@
 		goto fail;
 	
 	urtw_8187_write_phy_cck(sc, 0x10, 0x9b);
-	urtw_delay_ms(1);
+	usbd_delay_ms(sc->sc_udev, 1);
 	urtw_8187_write_phy_ofdm(sc, 0x26, 0x90);
-	urtw_delay_ms(1);
+	usbd_delay_ms(sc->sc_udev, 1);
 
 	/* TX ant A, 0x0 for B */
 	error = urtw_8185_tx_antenna(sc, 0x3);
@@ -2775,7 +2768,7 @@
 	if (error)
 		goto fail;
 	urtw_8225_write(sc, 0x7, urtw_8225_channel[chan]);
-	urtw_delay_ms(10);
+	usbd_delay_ms(sc->sc_udev, 10);
 
 	urtw_write8_m(sc, URTW_SIFS, 0x22);
 
@@ -2984,13 +2977,13 @@
 	/* XXX for A?  */
 	gainp = urtw_8225v2_gain_bg;
 	urtw_8187_write_phy_ofdm(sc, 0x0d, gainp[gain * 3]);
-	urtw_delay_ms(1);
+	usbd_delay_ms(sc->sc_udev, 1);
 	urtw_8187_write_phy_ofdm(sc, 0x1b, gainp[gain * 3 + 1]);
-	urtw_delay_ms(1);
+	usbd_delay_ms(sc->sc_udev, 1);
 	urtw_8187_write_phy_ofdm(sc, 0x1d, gainp[gain * 3 + 2]);
-	urtw_delay_ms(1);
+	usbd_delay_ms(sc->sc_udev, 1);
 	urtw_8187_write_phy_ofdm(sc, 0x21, 0x17);
-	urtw_delay_ms(1);
+	usbd_delay_ms(sc->sc_udev, 1);
 fail:
 	return (error);
 }
@@ -3017,7 +3010,7 @@
 	}
 	urtw_write8_m(sc, URTW_TX_GAIN_CCK,
 	    urtw_8225v2_tx_gain_cck_ofdm[cck_pwrlvl]);
-	urtw_delay_ms(1);
+	usbd_delay_ms(sc->sc_udev, 1);
 	
 	/* OFDM power setting */
 	ofdm_pwrlvl = (ofdm_pwrlvl > (ofdm_pwrlvl_max - ofdm_pwrlvl_min)) ?
@@ -3037,7 +3030,7 @@
 
 	urtw_write8_m(sc, URTW_TX_GAIN_OFDM,
 	    urtw_8225v2_tx_gain_cck_ofdm[ofdm_pwrlvl]);
-	urtw_delay_ms(1);
+	usbd_delay_ms(sc->sc_udev, 1);
 fail:
 	return (error);
 }
@@ -3076,34 +3069,34 @@
 	if (error)
 		goto fail;
 
-	urtw_delay_ms(1000);
+	usbd_delay_ms(sc->sc_udev, 1000);
 
 	for (i = 0; i < N(urtw_8225v2_rf_part1); i++) {
 		urtw_8225_write(sc, urtw_8225v2_rf_part1[i].reg,
 		    urtw_8225v2_rf_part1[i].val);
-		urtw_delay_ms(1);
+		usbd_delay_ms(sc->sc_udev, 1);
 	}
-	urtw_delay_ms(100);
+	usbd_delay_ms(sc->sc_udev, 100);
 
 	urtw_8225_write(sc, 0x0, 0x1b7);
 
 	for (i = 0; i < 95; i++) {
 		urtw_8225_write(sc, 0x1, (uint8_t)(i + 1));
-		urtw_delay_ms(1);
+		usbd_delay_ms(sc->sc_udev, 1);
 		urtw_8225_write(sc, 0x2, urtw_8225v2_rxgain[i]);
-		urtw_delay_ms(1);
+		usbd_delay_ms(sc->sc_udev, 1);
 	}
 
 	urtw_8225_write(sc, 0x3, 0x2);
-	urtw_delay_ms(1);
+	usbd_delay_ms(sc->sc_udev, 1);
 	urtw_8225_write(sc, 0x5, 0x4);
-	urtw_delay_ms(1);
+	usbd_delay_ms(sc->sc_udev, 1);
 	urtw_8225_write(sc, 0x0, 0xb7);
-	urtw_delay_ms(1);
+	usbd_delay_ms(sc->sc_udev, 1);
 	urtw_8225_write(sc, 0x2, 0xc4d);
-	urtw_delay_ms(200);
+	usbd_delay_ms(sc->sc_udev, 200);
 	urtw_8225_write(sc, 0x2, 0x44d);
-	urtw_delay_ms(200);
+	usbd_delay_ms(sc->sc_udev, 200);
 
 	error = urtw_8225_read(sc, 0x6, &data32);
 	if (error != 0)
@@ -3112,30 +3105,30 @@
 		device_printf(sc->sc_dev, "expect 0xe6!! (0x%x)\n", data32);
 	if (!(data32 & 0x80)) {
 		urtw_8225_write(sc, 0x02, 0x0c4d);
-		urtw_delay_ms(200);
+		usbd_delay_ms(sc->sc_udev, 200);
 		urtw_8225_write(sc, 0x02, 0x044d);
-		urtw_delay_ms(100);
+		usbd_delay_ms(sc->sc_udev, 100);
 		error = urtw_8225_read(sc, 0x6, &data32);
 		if (error != 0)
 			goto fail;
 		if (!(data32 & 0x80))
 			device_printf(sc->sc_dev, "RF calibration failed\n");
 	}
-	urtw_delay_ms(200);
+	usbd_delay_ms(sc->sc_udev, 200);
 
 	urtw_8225_write(sc, 0x0, 0x2bf);
 	for (i = 0; i < 128; i++) {
 		urtw_8187_write_phy_ofdm(sc, 0xb, urtw_8225_agc[i]);
-		urtw_delay_ms(1);
+		usbd_delay_ms(sc->sc_udev, 1);
 		urtw_8187_write_phy_ofdm(sc, 0xa, (uint8_t)i + 0x80);
-		urtw_delay_ms(1);
+		usbd_delay_ms(sc->sc_udev, 1);
 	}
-	urtw_delay_ms(1);
+	usbd_delay_ms(sc->sc_udev, 1);
 
 	for (i = 0; i < N(urtw_8225v2_rf_part2); i++) {
 		urtw_8187_write_phy_ofdm(sc, urtw_8225v2_rf_part2[i].reg,
 		    urtw_8225v2_rf_part2[i].val);
-		urtw_delay_ms(1);
+		usbd_delay_ms(sc->sc_udev, 1);
 	}
 	
 	error = urtw_8225v2_setgain(sc, 4);
@@ -3145,7 +3138,7 @@
 	for (i = 0; i < N(urtw_8225v2_rf_part3); i++) {
 		urtw_8187_write_phy_cck(sc, urtw_8225v2_rf_part3[i].reg,
 		    urtw_8225v2_rf_part3[i].val);
-		urtw_delay_ms(1);
+		usbd_delay_ms(sc->sc_udev, 1);
 	}
 
 	urtw_write8_m(sc, 0x5b, 0x0d);
@@ -3155,9 +3148,9 @@
 		goto fail;
 	
 	urtw_8187_write_phy_cck(sc, 0x10, 0x9b);
-	urtw_delay_ms(1);
+	usbd_delay_ms(sc->sc_udev, 1);
 	urtw_8187_write_phy_ofdm(sc, 0x26, 0x90);
-	urtw_delay_ms(1);
+	usbd_delay_ms(sc->sc_udev, 1);
 
 	/* TX ant A, 0x0 for B */
 	error = urtw_8185_tx_antenna(sc, 0x3);
@@ -3184,7 +3177,7 @@
 		goto fail;
 
 	urtw_8225_write(sc, 0x7, urtw_8225_channel[chan]);
-	urtw_delay_ms(10);
+	usbd_delay_ms(sc->sc_udev, 10);
 
 	urtw_write8_m(sc, URTW_SIFS, 0x22);
 
@@ -3232,7 +3225,7 @@
 		    ieee80211_chan2ieee(ic, ic->ic_curchan));
 		if (error != 0)
 			goto fail;
-		urtw_delay_ms(10);
+		usbd_delay_ms(sc->sc_udev, 10);
 		urtw_write32_m(sc, URTW_TX_CONF, data | URTW_TX_LOOPBACK_NONE);
 		break;
 	default:


More information about the p4-projects mailing list