LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Yi Yang <yi.y.yang@intel.com>
To: linux-acpi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, lenb@kernel.org,
acpi-bugzilla@lists.sourceforge.net
Subject: [PATCH linux-acpi] Remove superfluous code and correct counting error in function acpi_system_write_alarm
Date: Thu, 27 Dec 2007 16:41:39 +0800 [thread overview]
Message-ID: <1198744900.3640.4.camel@yangyi-dev.bj.intel.com> (raw)
In-Reply-To: <1198738022.8950.3.camel@yangyi-dev.bj.intel.com>
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>
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c
index fce78fb..f8df521 100644
--- a/drivers/acpi/sleep/proc.c
+++ b/drivers/acpi/sleep/proc.c
@@ -256,27 +256,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);
@@ -293,24 +272,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);
next prev parent reply other threads:[~2007-12-27 8:42 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-27 6:47 [PATCH linux-acpi] Fix /proc/acpi/alarm set error Yi Yang
2007-12-27 8:41 ` Yi Yang [this message]
2007-12-29 8:22 ` [PATCH linux-acpi] Correct wakeup set error and append a new column PCI ID Yi Yang
2008-01-01 23:20 ` Pavel Machek
2008-01-02 2:03 ` Yi Yang
2008-01-02 16:09 ` Pavel Machek
2008-01-03 2:02 ` Yi Yang
2008-01-03 2:11 ` Yi Yang
2008-01-04 8:16 ` [PATCH linux-acpi] fix acpi fan state set error Yi Yang
2008-01-07 6:56 ` [PATCH] ACPI: fix processor throttling " Yi Yang
2008-01-08 3:21 ` [PATCH] ACPI: fix processor limit " Yi Yang
2008-01-24 0:45 ` [PATCH] ACPI: create proc entry 'power' only if C2 or C3 is supported Yi Yang
2008-01-24 14:43 ` Mark Lord
2008-01-09 22:21 ` [PATCH] ACPI: Add sysfs interface for acpi device wakeup Yi Yang
2008-01-10 7:43 ` Maxim Levitsky
2008-01-09 23:59 ` Yi Yang
2008-01-10 10:30 ` Matthew Garrett
2008-01-13 18:16 ` Pavel Machek
2008-01-11 8:16 ` Zhang Rui
2008-01-10 23:55 ` Yi Yang
2008-03-19 13:06 ` Thomas Renninger
2008-03-19 14:37 ` Yi Yang
2008-03-20 4:32 ` Zhao Yakui
2008-03-19 18:52 ` David Brownell
2008-03-20 5:12 ` Zhao Yakui
2008-03-20 6:12 ` David Brownell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1198744900.3640.4.camel@yangyi-dev.bj.intel.com \
--to=yi.y.yang@intel.com \
--cc=acpi-bugzilla@lists.sourceforge.net \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--subject='Re: [PATCH linux-acpi] Remove superfluous code and correct counting error in function acpi_system_write_alarm' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).