Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Feb 2019 04:32:42 +0000 (UTC)
From:      Andriy Voskoboinyk <avos@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r343892 - in stable/12/sys: dev/rtwn/pci dev/rtwn/usb net80211
Message-ID:  <201902080432.x184Wgj4001734@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avos
Date: Fri Feb  8 04:32:41 2019
New Revision: 343892
URL: https://svnweb.freebsd.org/changeset/base/343892

Log:
  MFC r343417:
  net80211: reuse TICKS_2_MSEC / MSEC_2_TICKS macros from sys/time.h
  
  Replace in-place implementation with system-wide one; since it
  guarantees non-zero result drop all less-than-one checks from
  drivers and net80211.

Modified:
  stable/12/sys/dev/rtwn/pci/rtwn_pci_reg.c
  stable/12/sys/dev/rtwn/usb/rtwn_usb_reg.c
  stable/12/sys/net80211/ieee80211_amrr.c
  stable/12/sys/net80211/ieee80211_freebsd.c
  stable/12/sys/net80211/ieee80211_freebsd.h
  stable/12/sys/net80211/ieee80211_ioctl.c
  stable/12/sys/net80211/ieee80211_rssadapt.c
  stable/12/sys/net80211/ieee80211_scan.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/rtwn/pci/rtwn_pci_reg.c
==============================================================================
--- stable/12/sys/dev/rtwn/pci/rtwn_pci_reg.c	Fri Feb  8 04:18:17 2019	(r343891)
+++ stable/12/sys/dev/rtwn/pci/rtwn_pci_reg.c	Fri Feb  8 04:32:41 2019	(r343892)
@@ -118,6 +118,6 @@ rtwn_pci_delay(struct rtwn_softc *sc, int usec)
 		DELAY(usec);
 	else {
 		(void) mtx_sleep(sc, &sc->sc_mtx, 0, "rtwn_pci",
-		    MAX(msecs_to_ticks(usec / 1000), 1));
+		    msecs_to_ticks(usec / 1000));
 	}
 }

Modified: stable/12/sys/dev/rtwn/usb/rtwn_usb_reg.c
==============================================================================
--- stable/12/sys/dev/rtwn/usb/rtwn_usb_reg.c	Fri Feb  8 04:18:17 2019	(r343891)
+++ stable/12/sys/dev/rtwn/usb/rtwn_usb_reg.c	Fri Feb  8 04:32:41 2019	(r343892)
@@ -172,8 +172,6 @@ rtwn_usb_delay(struct rtwn_softc *sc, int usec)
 	/* 1ms delay as default is too big. */
 	if (usec < 1000)
 		DELAY(usec);
-	else {
-		usb_pause_mtx(&sc->sc_mtx,
-		    MAX(msecs_to_ticks(usec / 1000), 1));
-	}
+	else
+		usb_pause_mtx(&sc->sc_mtx, msecs_to_ticks(usec / 1000));
 }

Modified: stable/12/sys/net80211/ieee80211_amrr.c
==============================================================================
--- stable/12/sys/net80211/ieee80211_amrr.c	Fri Feb  8 04:18:17 2019	(r343891)
+++ stable/12/sys/net80211/ieee80211_amrr.c	Fri Feb  8 04:32:41 2019	(r343892)
@@ -102,15 +102,13 @@ static void
 amrr_setinterval(const struct ieee80211vap *vap, int msecs)
 {
 	struct ieee80211_amrr *amrr = vap->iv_rs;
-	int t;
 
 	if (!amrr)
 		return;
 
 	if (msecs < 100)
 		msecs = 100;
-	t = msecs_to_ticks(msecs);
-	amrr->amrr_interval = (t < 1) ? 1 : t;
+	amrr->amrr_interval = msecs_to_ticks(msecs);
 }
 
 static void

Modified: stable/12/sys/net80211/ieee80211_freebsd.c
==============================================================================
--- stable/12/sys/net80211/ieee80211_freebsd.c	Fri Feb  8 04:18:17 2019	(r343891)
+++ stable/12/sys/net80211/ieee80211_freebsd.c	Fri Feb  8 04:32:41 2019	(r343892)
@@ -134,13 +134,12 @@ int
 ieee80211_sysctl_msecs_ticks(SYSCTL_HANDLER_ARGS)
 {
 	int msecs = ticks_to_msecs(*(int *)arg1);
-	int error, t;
+	int error;
 
 	error = sysctl_handle_int(oidp, &msecs, 0, req);
 	if (error || !req->newptr)
 		return error;
-	t = msecs_to_ticks(msecs);
-	*(int *)arg1 = (t < 1) ? 1 : t;
+	*(int *)arg1 = msecs_to_ticks(msecs);
 	return 0;
 }
 
@@ -345,9 +344,6 @@ ieee80211_com_vdetach(struct ieee80211vap *vap)
 	int sleep_time;
 
 	sleep_time = msecs_to_ticks(250);
-	if (sleep_time == 0)
-		sleep_time = 1;
-
 	atomic_set_32(&vap->iv_com_state, IEEE80211_COM_DETACHED);
 	while (MS(atomic_load_32(&vap->iv_com_state), IEEE80211_COM_REF) != 0)
 		pause("comref", sleep_time);

Modified: stable/12/sys/net80211/ieee80211_freebsd.h
==============================================================================
--- stable/12/sys/net80211/ieee80211_freebsd.h	Fri Feb  8 04:18:17 2019	(r343891)
+++ stable/12/sys/net80211/ieee80211_freebsd.h	Fri Feb  8 04:32:41 2019	(r343892)
@@ -38,6 +38,7 @@
 #include <sys/rwlock.h>
 #include <sys/sysctl.h>
 #include <sys/taskqueue.h>
+#include <sys/time.h>
 
 /*
  * Common state locking definitions.
@@ -249,9 +250,8 @@ void	ieee80211_vap_destroy(struct ieee80211vap *);
 	(((_ifp)->if_flags & IFF_UP) && \
 	 ((_ifp)->if_drv_flags & IFF_DRV_RUNNING))
 
-/* XXX TODO: cap these at 1, as hz may not be 1000 */
-#define	msecs_to_ticks(ms)	(((ms)*hz)/1000)
-#define	ticks_to_msecs(t)	(1000*(t) / hz)
+#define	msecs_to_ticks(ms)	MSEC_2_TICKS(ms)
+#define	ticks_to_msecs(t)	TICKS_2_MSEC(t)
 #define	ticks_to_secs(t)	((t) / hz)
 
 #define ieee80211_time_after(a,b) 	((long)(b) - (long)(a) < 0)

Modified: stable/12/sys/net80211/ieee80211_ioctl.c
==============================================================================
--- stable/12/sys/net80211/ieee80211_ioctl.c	Fri Feb  8 04:18:17 2019	(r343891)
+++ stable/12/sys/net80211/ieee80211_ioctl.c	Fri Feb  8 04:32:41 2019	(r343892)
@@ -2515,20 +2515,12 @@ ieee80211_scanreq(struct ieee80211vap *vap, struct iee
 		    sr->sr_duration > IEEE80211_IOC_SCAN_DURATION_MAX)
 			return EINVAL;
 		sr->sr_duration = msecs_to_ticks(sr->sr_duration);
-		if (sr->sr_duration < 1)
-			sr->sr_duration = 1;
 	}
 	/* convert min/max channel dwell */
-	if (sr->sr_mindwell != 0) {
+	if (sr->sr_mindwell != 0)
 		sr->sr_mindwell = msecs_to_ticks(sr->sr_mindwell);
-		if (sr->sr_mindwell < 1)
-			sr->sr_mindwell = 1;
-	}
-	if (sr->sr_maxdwell != 0) {
+	if (sr->sr_maxdwell != 0)
 		sr->sr_maxdwell = msecs_to_ticks(sr->sr_maxdwell);
-		if (sr->sr_maxdwell < 1)
-			sr->sr_maxdwell = 1;
-	}
 	/* NB: silently reduce ssid count to what is supported */
 	if (sr->sr_nssid > IEEE80211_SCAN_MAX_SSID)
 		sr->sr_nssid = IEEE80211_SCAN_MAX_SSID;

Modified: stable/12/sys/net80211/ieee80211_rssadapt.c
==============================================================================
--- stable/12/sys/net80211/ieee80211_rssadapt.c	Fri Feb  8 04:18:17 2019	(r343891)
+++ stable/12/sys/net80211/ieee80211_rssadapt.c	Fri Feb  8 04:32:41 2019	(r343892)
@@ -117,15 +117,13 @@ static void
 rssadapt_setinterval(const struct ieee80211vap *vap, int msecs)
 {
 	struct ieee80211_rssadapt *rs = vap->iv_rs;
-	int t;
 
 	if (!rs)
 		return;
 
 	if (msecs < 100)
 		msecs = 100;
-	t = msecs_to_ticks(msecs);
-	rs->interval = (t < 1) ? 1 : t;
+	rs->interval = msecs_to_ticks(msecs);
 }
 
 static void

Modified: stable/12/sys/net80211/ieee80211_scan.c
==============================================================================
--- stable/12/sys/net80211/ieee80211_scan.c	Fri Feb  8 04:18:17 2019	(r343891)
+++ stable/12/sys/net80211/ieee80211_scan.c	Fri Feb  8 04:32:41 2019	(r343892)
@@ -294,7 +294,7 @@ ieee80211_scan_dump(struct ieee80211_scan_state *ss)
 
 	if_printf(vap->iv_ifp, "scan set ");
 	ieee80211_scan_dump_channels(ss);
-	printf(" dwell min %lums max %lums\n",
+	printf(" dwell min %ums max %ums\n",
 	    ticks_to_msecs(ss->ss_mindwell), ticks_to_msecs(ss->ss_maxdwell));
 }
 #endif /* IEEE80211_DEBUG */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902080432.x184Wgj4001734>