aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorYi Yang <yi.y.yang@intel.com>2007-12-27 22:04:26 -0500
committerLen Brown <len.brown@intel.com>2007-12-27 22:04:26 -0500
commit087980295082ccaa816330bc69c29a2ff53a244c (patch)
tree67a272391cd8c0060dddc2e1c99fdeaaedcd1eb7 /drivers
parentc68cb23dde29fb107575656effa46f7b9440ac04 (diff)
ACPI: /proc/acpi/alarm parsing: handle large numbers properly
In function acpi_system_write_alarm in file drivers/acpi/sleep/proc.c, big sec, min, hr, mo, day and yr are counted twice to get reasonable values, that is very superfluous, we can do that only once. In additon, /proc/acpi/alarm can set a related value which can be specified as YYYY years MM months DD days HH hours MM minutes SS senconds, it isn't a date, so you can specify as +0000-00-00 96:00:00 , that means 3 days later, current code can't handle such a case. This patch removes unnecessary code and does with the aforementioned situation. Before applying this patch: [root@localhost /]# cat /proc/acpi/alarm 2007-12-00 00:00:00 [root@localhost /]# echo "0000-00-00 96:180:180" > /proc/acpi/alarm [root@localhost /]# cat /proc/acpi/alarm 0007-12-02 **:**:** [root@localhost /]# After applying this patch: [root@localhost ~]# echo "2007-12-00 00:00:00" > /proc/acpi/alarm [root@localhost ~]# cat /proc/acpi/alarm 2007-12-00 00:00:00 [root@localhost ~]# echo "0000-00-00 96:180:180" > /proc/acpi/alarm [root@localhost ~]# cat /proc/acpi/alarm 0007-12-04 03:03:00 [root@localhost ~]# Signed-off-by: Yi Yang <yi.y.yang@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/sleep/proc.c41
1 files changed, 10 insertions, 31 deletions
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c
index 1538355c266b..e19eb0c25e62 100644
--- a/drivers/acpi/sleep/proc.c
+++ b/drivers/acpi/sleep/proc.c
@@ -251,27 +251,6 @@ acpi_system_write_alarm(struct file *file,
251 if ((result = get_date_field(&p, &sec))) 251 if ((result = get_date_field(&p, &sec)))
252 goto end; 252 goto end;
253 253
254 if (sec > 59) {
255 min += 1;
256 sec -= 60;
257 }
258 if (min > 59) {
259 hr += 1;
260 min -= 60;
261 }
262 if (hr > 23) {
263 day += 1;
264 hr -= 24;
265 }
266 if (day > 31) {
267 mo += 1;
268 day -= 31;
269 }
270 if (mo > 12) {
271 yr += 1;
272 mo -= 12;
273 }
274
275 spin_lock_irq(&rtc_lock); 254 spin_lock_irq(&rtc_lock);
276 255
277 rtc_control = CMOS_READ(RTC_CONTROL); 256 rtc_control = CMOS_READ(RTC_CONTROL);
@@ -288,24 +267,24 @@ acpi_system_write_alarm(struct file *file,
288 spin_unlock_irq(&rtc_lock); 267 spin_unlock_irq(&rtc_lock);
289 268
290 if (sec > 59) { 269 if (sec > 59) {
291 min++; 270 min += sec/60;
292 sec -= 60; 271 sec = sec%60;
293 } 272 }
294 if (min > 59) { 273 if (min > 59) {
295 hr++; 274 hr += min/60;
296 min -= 60; 275 min = min%60;
297 } 276 }
298 if (hr > 23) { 277 if (hr > 23) {
299 day++; 278 day += hr/24;
300 hr -= 24; 279 hr = hr%24;
301 } 280 }
302 if (day > 31) { 281 if (day > 31) {
303 mo++; 282 mo += day/32;
304 day -= 31; 283 day = day%32;
305 } 284 }
306 if (mo > 12) { 285 if (mo > 12) {
307 yr++; 286 yr += mo/13;
308 mo -= 12; 287 mo = mo%13;
309 } 288 }
310 289
311 spin_lock_irq(&rtc_lock); 290 spin_lock_irq(&rtc_lock);