Date: Thu, 04 Nov 2010 22:24:12 +0200 From: Alexander Motin <mav@FreeBSD.org> To: Bruce Cran <bruce@cran.org.uk> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Bruce Cran <brucec@FreeBSD.org> Subject: Re: svn commit: r214781 - head/sbin/camcontrol Message-ID: <4CD3166C.4030003@FreeBSD.org> In-Reply-To: <20101104202203.000043a6@unknown> References: <201011041524.oA4FOWd7063812@svn.freebsd.org> <4CD2F224.1040008@FreeBSD.org> <20101104202203.000043a6@unknown>
next in thread | previous in thread | raw e-mail | index | archive | help
Bruce Cran wrote: > On Thu, 04 Nov 2010 19:49:24 +0200 > Alexander Motin <mav@FreeBSD.org> wrote: > >> This will round period down. You will get 30 minutes instead of 59. In >> this case rounding up IMHO more appropriate. I agree that previous >> rounding up was over aggressive. I would prefer something like: >> sc = (t - 1) / (30 * 60) + 241; >> or at least >> sc = (t + 15 * 60) / (30 * 60) + 240; >> This will also make previous range unneeded. >> >> Range "t <= (240 * 5)" probably also should be corrected to round up >> or at least closest. >> > > Of course rounding up is more suitable. Would the following patch be > ok: > > Index: camcontrol.c > =================================================================== > --- camcontrol.c (revision 214793) > +++ camcontrol.c (working copy) > @@ -4312,18 +4312,16 @@ > cmd = ATA_SLEEP; > t = -1; > } > + > if (t < 0) > sc = 0; > else if (t <= (240 * 5)) > - sc = t / 5; > - else if (t == (252 * 5)) > + sc = (t + 4) / 5; > + else if (t <= (252 * 5)) > /* special encoding for 21 minutes */ > sc = 252; > - else if (t < (30 * 60)) > - /* no encoding exists for 22-29 minutes, so set to 30 > mins */ > - sc = 241; > else if (t <= (11 * 30 * 60)) > - sc = t / (30 * 60) + 240; > + sc = (t - 1) / (30 * 60) + 241; > else > sc = 253; It seems so. Thank you. -- Alexander Motin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4CD3166C.4030003>