Re: wi(4): tsleep(9) -> tsleep_nsec(9)

2020-04-06 Thread Stefan Sperling
On Mon, Apr 06, 2020 at 02:03:36PM -0500, Scott Cheloha wrote:
> Ticks to seconds.  Trivial.
> 
> ok?

ok stsp@

> Index: if_wi.c
> ===
> RCS file: /cvs/src/sys/dev/ic/if_wi.c,v
> retrieving revision 1.171
> diff -u -p -r1.171 if_wi.c
> --- if_wi.c   31 Dec 2019 10:05:32 -  1.171
> +++ if_wi.c   6 Apr 2020 18:29:33 -
> @@ -1865,8 +1865,8 @@ wi_ioctl(struct ifnet *ifp, u_long comma
>   timeout_add(>wi_scan_timeout, len);
>  
>   /* Let the userspace process wait for completion */
> - error = tsleep(>wi_scan_lock, PCATCH, "wiscan",
> - hz * IEEE80211_SCAN_TIMEOUT);
> + error = tsleep_nsec(>wi_scan_lock, PCATCH, "wiscan",
> + SEC_TO_NSEC(IEEE80211_SCAN_TIMEOUT));
>   break;
>   case SIOCG80211ALLNODES:
>   {
> 



wi(4): tsleep(9) -> tsleep_nsec(9)

2020-04-06 Thread Scott Cheloha
Ticks to seconds.  Trivial.

ok?

Index: if_wi.c
===
RCS file: /cvs/src/sys/dev/ic/if_wi.c,v
retrieving revision 1.171
diff -u -p -r1.171 if_wi.c
--- if_wi.c 31 Dec 2019 10:05:32 -  1.171
+++ if_wi.c 6 Apr 2020 18:29:33 -
@@ -1865,8 +1865,8 @@ wi_ioctl(struct ifnet *ifp, u_long comma
timeout_add(>wi_scan_timeout, len);
 
/* Let the userspace process wait for completion */
-   error = tsleep(>wi_scan_lock, PCATCH, "wiscan",
-   hz * IEEE80211_SCAN_TIMEOUT);
+   error = tsleep_nsec(>wi_scan_lock, PCATCH, "wiscan",
+   SEC_TO_NSEC(IEEE80211_SCAN_TIMEOUT));
break;
case SIOCG80211ALLNODES:
{



wi(4): tsleep(9) -> tsleep_nsec(9), timeout_add(9) -> timeout_add_msec(9)

2020-02-17 Thread Scott Cheloha
Convert WI_WAVELAN_RES_TIMEOUT from ticks to milliseconds and use
timeout_add_msec(9) directly.

We can also easily use tsleep_nsec(9) here instead of tsleep(9).

ok?

Index: if_wi.c
===
RCS file: /cvs/src/sys/dev/ic/if_wi.c,v
retrieving revision 1.171
diff -u -p -r1.171 if_wi.c
--- if_wi.c 31 Dec 2019 10:05:32 -  1.171
+++ if_wi.c 18 Feb 2020 00:39:16 -
@@ -1519,7 +1519,7 @@ wi_setdef(struct wi_softc *sc, struct wi
 STATIC int
 wi_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
 {
-   int s, error = 0, i, j, len;
+   int s, error = 0, i, j, len, msecs;
struct wi_softc *sc = ifp->if_softc;
struct ifreq*ifr = (struct ifreq *)data;
struct proc *p = curproc;
@@ -1857,16 +1857,16 @@ wi_ioctl(struct ifnet *ifp, u_long comma
}
sc->wi_scan_lock = 0;
timeout_set(>wi_scan_timeout, wi_scan_timeout, sc);
-   len = WI_WAVELAN_RES_TIMEOUT;
+   msecs = WI_WAVELAN_RES_TIMEOUT;
if (sc->wi_flags & WI_FLAGS_BUS_USB) {
/* Use a longer timeout for wi@usb */
-   len = WI_WAVELAN_RES_TIMEOUT * 4;
+   msecs = WI_WAVELAN_RES_TIMEOUT * 4;
}
-   timeout_add(>wi_scan_timeout, len);
+   timeout_add_msec(>wi_scan_timeout, msecs);
 
/* Let the userspace process wait for completion */
-   error = tsleep(>wi_scan_lock, PCATCH, "wiscan",
-   hz * IEEE80211_SCAN_TIMEOUT);
+   error = tsleep_nsec(>wi_scan_lock, PCATCH, "wiscan",
+   SEC_TO_NSEC(IEEE80211_SCAN_TIMEOUT));
break;
case SIOCG80211ALLNODES:
{
@@ -2036,7 +2036,8 @@ wi_scan_timeout(void *arg)
if (wi_read_record(sc, (struct wi_ltv_gen *)) == 0 &&
((struct wi_scan_p2_hdr *)wreq.wi_val)->wi_reason == 0) {
/* Wait some more time for scan completion */
-   timeout_add(>wi_scan_timeout, 
WI_WAVELAN_RES_TIMEOUT);
+   timeout_add_msec(>wi_scan_timeout,
+   WI_WAVELAN_RES_TIMEOUT);
return;
}
}
Index: if_wi_hostap.c
===
RCS file: /cvs/src/sys/dev/ic/if_wi_hostap.c,v
retrieving revision 1.52
diff -u -p -r1.52 if_wi_hostap.c
--- if_wi_hostap.c  19 Feb 2018 08:59:52 -  1.52
+++ if_wi_hostap.c  18 Feb 2020 00:39:16 -
@@ -410,7 +410,7 @@ wihap_sta_timeout(void *v)
 
/* Add wihap timeout if we have not already done so. */
if (!timeout_pending(>tmo))
-   timeout_add(>tmo, hz / 10);
+   timeout_add_msec(>tmo, 100);
 
splx(s);
 }
Index: if_wi_ieee.h
===
RCS file: /cvs/src/sys/dev/ic/if_wi_ieee.h,v
retrieving revision 1.30
diff -u -p -r1.30 if_wi_ieee.h
--- if_wi_ieee.h24 Aug 2014 18:01:27 -  1.30
+++ if_wi_ieee.h18 Feb 2020 00:39:16 -
@@ -674,7 +674,7 @@ struct wi_scan_res {
 #define WI_WAVELAN_RES_11M 0x6e
 
 #define WI_WAVELAN_RES_SIZE50
-#define WI_WAVELAN_RES_TIMEOUT ((hz / 10) * 2) /* 200ms */
+#define WI_WAVELAN_RES_TIMEOUT 200 /* ms */
 #define WI_WAVELAN_RES_TRIES   100
 
 struct wi_scan_p2_hdr {