Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=087980295082ccaa816330bc69c29a2ff53a244c
Commit:     087980295082ccaa816330bc69c29a2ff53a244c
Parent:     c68cb23dde29fb107575656effa46f7b9440ac04
Author:     Yi Yang <[EMAIL PROTECTED]>
AuthorDate: Thu Dec 27 22:04:26 2007 -0500
Committer:  Len Brown <[EMAIL PROTECTED]>
CommitDate: Thu Dec 27 22:04:26 2007 -0500

    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:
    
    [EMAIL PROTECTED] /]# cat /proc/acpi/alarm
    2007-12-00 00:00:00
    [EMAIL PROTECTED] /]# echo "0000-00-00 96:180:180" > /proc/acpi/alarm
    [EMAIL PROTECTED] /]# cat /proc/acpi/alarm
    0007-12-02 **:**:**
    [EMAIL PROTECTED] /]#
    
    After applying this patch:
    
    [EMAIL PROTECTED] ~]# echo "2007-12-00 00:00:00" > /proc/acpi/alarm
    [EMAIL PROTECTED] ~]# cat /proc/acpi/alarm
    2007-12-00 00:00:00
    [EMAIL PROTECTED] ~]# echo "0000-00-00 96:180:180" > /proc/acpi/alarm
    [EMAIL PROTECTED] ~]# cat /proc/acpi/alarm
    0007-12-04 03:03:00
    [EMAIL PROTECTED] ~]#
    
    Signed-off-by: Yi Yang <[EMAIL PROTECTED]>
    Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 drivers/acpi/sleep/proc.c |   41 ++++++++++-------------------------------
 1 files changed, 10 insertions(+), 31 deletions(-)

diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c
index 1538355..e19eb0c 100644
--- a/drivers/acpi/sleep/proc.c
+++ b/drivers/acpi/sleep/proc.c
@@ -251,27 +251,6 @@ acpi_system_write_alarm(struct file *file,
        if ((result = get_date_field(&p, &sec)))
                goto end;
 
-       if (sec > 59) {
-               min += 1;
-               sec -= 60;
-       }
-       if (min > 59) {
-               hr += 1;
-               min -= 60;
-       }
-       if (hr > 23) {
-               day += 1;
-               hr -= 24;
-       }
-       if (day > 31) {
-               mo += 1;
-               day -= 31;
-       }
-       if (mo > 12) {
-               yr += 1;
-               mo -= 12;
-       }
-
        spin_lock_irq(&rtc_lock);
 
        rtc_control = CMOS_READ(RTC_CONTROL);
@@ -288,24 +267,24 @@ acpi_system_write_alarm(struct file *file,
        spin_unlock_irq(&rtc_lock);
 
        if (sec > 59) {
-               min++;
-               sec -= 60;
+               min += sec/60;
+               sec = sec%60;
        }
        if (min > 59) {
-               hr++;
-               min -= 60;
+               hr += min/60;
+               min = min%60;
        }
        if (hr > 23) {
-               day++;
-               hr -= 24;
+               day += hr/24;
+               hr = hr%24;
        }
        if (day > 31) {
-               mo++;
-               day -= 31;
+               mo += day/32;
+               day = day%32;
        }
        if (mo > 12) {
-               yr++;
-               mo -= 12;
+               yr += mo/13;
+               mo = mo%13;
        }
 
        spin_lock_irq(&rtc_lock);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to