From owner-svn-src-head@FreeBSD.ORG Thu Nov 4 20:22:08 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 996CF106564A; Thu, 4 Nov 2010 20:22:08 +0000 (UTC) (envelope-from bruce@cran.org.uk) Received: from muon.cran.org.uk (muon.cran.org.uk [IPv6:2a01:348:0:15:5d59:5c40:0:1]) by mx1.freebsd.org (Postfix) with ESMTP id 3125B8FC0A; Thu, 4 Nov 2010 20:22:08 +0000 (UTC) Received: from muon.cran.org.uk (localhost [127.0.0.1]) by muon.cran.org.uk (Postfix) with ESMTP id 459A1E7211; Thu, 4 Nov 2010 20:22:07 +0000 (GMT) Received: from unknown (client-82-26-147-199.pete.adsl.virginmedia.com [82.26.147.199]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by muon.cran.org.uk (Postfix) with ESMTPSA; Thu, 4 Nov 2010 20:22:06 +0000 (GMT) Date: Thu, 4 Nov 2010 20:22:03 +0000 From: Bruce Cran To: Alexander Motin Message-ID: <20101104202203.000043a6@unknown> In-Reply-To: <4CD2F224.1040008@FreeBSD.org> References: <201011041524.oA4FOWd7063812@svn.freebsd.org> <4CD2F224.1040008@FreeBSD.org> X-Mailer: Claws Mail 3.7.6 (GTK+ 2.16.6; i586-pc-mingw32msvc) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Bruce Cran Subject: Re: svn commit: r214781 - head/sbin/camcontrol X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2010 20:22:08 -0000 On Thu, 04 Nov 2010 19:49:24 +0200 Alexander Motin 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; -- Bruce Cran