On Tue, Jan 07, 2020 at 08:03:27AM -0000, Miod Vallat wrote:
>
> > Convert ticks to milliseconds.
> >
> > The 33 milliseconds in the timeout_add_msec(9) call will be truncated
> > to 3 ticks, but that was already the case with the current (hz / 30)
> > code so this is no worse.
>
> [...]
>
> > /* allow 1/30 second for heads to settle */
> > - timeout_add(&fdc->fdcpseudointr_to, hz / 30);
> > + timeout_add_msec(&fdc->fdcpseudointr_to, 33);
>
> Why not simply write `1000 / 30' rather than 33, to match the comment?
Eh, sometimes when I see that stuff I wish I didn't have to do the
integer division in my head.
Not that big of a deal though. Sure.
Index: dev/isa/fd.c
===================================================================
RCS file: /cvs/src/sys/dev/isa/fd.c,v
retrieving revision 1.106
diff -u -p -r1.106 fd.c
--- dev/isa/fd.c 30 Dec 2017 23:08:29 -0000 1.106
+++ dev/isa/fd.c 10 Jan 2020 03:21:35 -0000
@@ -210,11 +210,11 @@ fdprobe(struct device *parent, void *mat
/* select drive and turn on motor */
bus_space_write_1(iot, ioh, fdout, drive | FDO_FRST | FDO_MOEN(drive));
/* wait for motor to spin up */
- tsleep(fdc, 0, "fdprobe", 250 * hz / 1000);
+ tsleep_nsec(fdc, 0, "fdprobe", MSEC_TO_NSEC(250));
out_fdc(iot, ioh, NE7CMD_RECAL);
out_fdc(iot, ioh, drive);
/* wait for recalibrate */
- tsleep(fdc, 0, "fdprobe", 2000 * hz / 1000);
+ tsleep_nsec(fdc, 0, "fdprobe", MSEC_TO_NSEC(2000));
out_fdc(iot, ioh, NE7CMD_SENSEI);
n = fdcresult(fdc);
#ifdef FD_DEBUG
@@ -228,7 +228,7 @@ fdprobe(struct device *parent, void *mat
#endif
/* turn off motor */
- tsleep(fdc, 0, "fdprobe", 250 * hz / 1000);
+ tsleep_nsec(fdc, 0, "fdprobe", MSEC_TO_NSEC(250));
bus_space_write_1(iot, ioh, fdout, FDO_FRST);
/* flags & 0x20 forces the drive to be found even if it won't probe */
@@ -900,7 +900,7 @@ loop:
timeout_del(&fd->fdtimeout_to);
fdc->sc_state = RECALCOMPLETE;
/* allow 1/30 second for heads to settle */
- timeout_add(&fdc->fdcpseudointr_to, hz / 30);
+ timeout_add_msec(&fdc->fdcpseudointr_to, 1000 / 30);
return 1; /* will return later */
case RECALCOMPLETE: