sparc64: stp(4): tsleep(9) -> tsleep_nsec(9)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

sparc64: stp(4): tsleep(9) -> tsleep_nsec(9)

Scott Cheloha
Ticks to microseconds.

The parameter name "ms" is misleading.  All the calling code uses
microseconds.  I think the author's thought process in choosing that
name was roughly: "microseconds" -> "Micro Seconds" -> "ms".

In any case, I've renamed the parameter to the less misleading
"usecs".

This driver is only built on sparc64.  I think this ought to compile.
If someone could confirm that it compiles that would help.

If someone has one of these things that would be even better, though I
have my doubts.

ok?

Index: stp4020.c
===================================================================
RCS file: /cvs/src/sys/dev/sbus/stp4020.c,v
retrieving revision 1.21
diff -u -p -r1.21 stp4020.c
--- stp4020.c 31 Dec 2019 10:05:33 -0000 1.21
+++ stp4020.c 10 Feb 2020 23:20:59 -0000
@@ -832,23 +832,20 @@ stp4020_chip_intr_string(pcmcia_chipset_
  * XXX - assumes a context
  */
 void
-stp4020_delay(unsigned int ms)
+stp4020_delay(unsigned int usecs)
 {
- unsigned int nticks;
+ int chan;
 
- /* Convert to nticks */
- nticks = (ms * hz) / 1000000;
-
- if (cold || nticks == 0) {
- delay(ms);
+ if (cold || usecs < tick) {
+ delay(usecs);
  return;
  }
 
 #ifdef DEBUG
- if (nticks > 60 * hz)
- panic("stp4020: preposterous delay: %u", nticks);
+ if (usecs > 60 * 1000000)
+ panic("stp4020: preposterous delay: %uus", usecs);
 #endif
- tsleep(&nticks, 0, "stp4020_delay", nticks);
+ tsleep_nsec(&chan, 0, "stp4020_delay", USEC_TO_NSEC(usecs));
 }
 
 #ifdef STP4020_DEBUG

Reply | Threaded
Open this post in threaded view
|

Re: sparc64: stp(4): tsleep(9) -> tsleep_nsec(9)

Klemens Nanni-2
On Mon, Feb 10, 2020 at 05:28:43PM -0600, Scott Cheloha wrote:
> The parameter name "ms" is misleading.  All the calling code uses
> microseconds.  I think the author's thought process in choosing that
> name was roughly: "microseconds" -> "Micro Seconds" -> "ms".
>
> In any case, I've renamed the parameter to the less misleading
> "usecs".
Looks good to me.

> This driver is only built on sparc64.  I think this ought to compile.
> If someone could confirm that it compiles that would help.
>
> If someone has one of these things that would be even better, though I
> have my doubts.
Compiles fine, but I have no real hardware to test.

>  #ifdef DEBUG
> - if (nticks > 60 * hz)
> - panic("stp4020: preposterous delay: %u", nticks);
> + if (usecs > 60 * 1000000)
Counting zeroes and lack of names or units on one site always make me
double check, how about the following?  Seems verbose indeed but is
obvious to read, imho.

        if (USEC_TO_NSEC(usecs) > SEC_TO_NSEC(60))