Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Jan 2019 01:05:18 +0000 (UTC)
From:      Andriy Voskoboinyk <avos@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r343417 - in head/sys: dev/rtwn/pci dev/rtwn/usb net80211
Message-ID:  <201901250105.x0P15IQ8093240@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avos
Date: Fri Jan 25 01:05:18 2019
New Revision: 343417
URL: https://svnweb.freebsd.org/changeset/base/343417

Log:
  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.
  
  MFC after:	2 weeks

Modified:
  head/sys/dev/rtwn/pci/rtwn_pci_reg.c
  head/sys/dev/rtwn/usb/rtwn_usb_reg.c
  head/sys/net80211/ieee80211_amrr.c
  head/sys/net80211/ieee80211_freebsd.c
  head/sys/net80211/ieee80211_freebsd.h
  head/sys/net80211/ieee80211_ioctl.c
  head/sys/net80211/ieee80211_rssadapt.c
  head/sys/net80211/ieee80211_scan.c

Modified: head/sys/dev/rtwn/pci/rtwn_pci_reg.c
==============================================================================
--- head/sys/dev/rtwn/pci/rtwn_pci_reg.c	Thu Jan 24 23:34:51 2019	(r343416)
+++ head/sys/dev/rtwn/pci/rtwn_pci_reg.c	Fri Jan 25 01:05:18 2019	(r343417)
@@ -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: head/sys/dev/rtwn/usb/rtwn_usb_reg.c
==============================================================================
--- head/sys/dev/rtwn/usb/rtwn_usb_reg.c	Thu Jan 24 23:34:51 2019	(r343416)
+++ head/sys/dev/rtwn/usb/rtwn_usb_reg.c	Fri Jan 25 01:05:18 2019	(r343417)
@@ -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: head/sys/net80211/ieee80211_amrr.c
==============================================================================
--- head/sys/net80211/ieee80211_amrr.c	Thu Jan 24 23:34:51 2019	(r343416)
+++ head/sys/net80211/ieee80211_amrr.c	Fri Jan 25 01:05:18 2019	(r343417)
@@ -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: head/sys/net80211/ieee80211_freebsd.c
==============================================================================
--- head/sys/net80211/ieee80211_freebsd.c	Thu Jan 24 23:34:51 2019	(r343416)
+++ head/sys/net80211/ieee80211_freebsd.c	Fri Jan 25 01:05:18 2019	(r343417)
@@ -136,13 +136,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;
 }
 
@@ -347,9 +346,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: head/sys/net80211/ieee80211_freebsd.h
==============================================================================
--- head/sys/net80211/ieee80211_freebsd.h	Thu Jan 24 23:34:51 2019	(r343416)
+++ head/sys/net80211/ieee80211_freebsd.h	Fri Jan 25 01:05:18 2019	(r343417)
@@ -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: head/sys/net80211/ieee80211_ioctl.c
==============================================================================
--- head/sys/net80211/ieee80211_ioctl.c	Thu Jan 24 23:34:51 2019	(r343416)
+++ head/sys/net80211/ieee80211_ioctl.c	Fri Jan 25 01:05:18 2019	(r343417)
@@ -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: head/sys/net80211/ieee80211_rssadapt.c
==============================================================================
--- head/sys/net80211/ieee80211_rssadapt.c	Thu Jan 24 23:34:51 2019	(r343416)
+++ head/sys/net80211/ieee80211_rssadapt.c	Fri Jan 25 01:05:18 2019	(r343417)
@@ -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: head/sys/net80211/ieee80211_scan.c
==============================================================================
--- head/sys/net80211/ieee80211_scan.c	Thu Jan 24 23:34:51 2019	(r343416)
+++ head/sys/net80211/ieee80211_scan.c	Fri Jan 25 01:05:18 2019	(r343417)
@@ -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?201901250105.x0P15IQ8093240>