From f974f3ffa1cdefec4f1ee8d41337a2cbbe361497 Mon Sep 17 00:00:00 2001 From: Rebecca Cran Date: Thu, 4 Nov 2010 20:31:12 +0000 Subject: [PATCH] r214781 caused the timer value to be rounded down, so that if the user asked for 59 minutes 30 was sent to the drive. The timer value is now always rounded up. Reported by: mav --- sbin/camcontrol/camcontrol.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sbin/camcontrol/camcontrol.c b/sbin/camcontrol/camcontrol.c index bedd035fe85..25f8777f66b 100644 --- a/sbin/camcontrol/camcontrol.c +++ b/sbin/camcontrol/camcontrol.c @@ -4312,18 +4312,16 @@ atapm(struct cam_device *device, int argc, char **argv, 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;