Re: [PATCH] Fix /proc/acpi/alarm BCD alarm encodings

Previous thread: [PATCH] Simplify /proc/cgroups by Paul Menage on Wednesday, October 17, 2007 - 10:56 pm. (2 messages)

Next thread: [Patch 000/002](memory hotplug) Rearrange notifier of memory hotplug (take 2) by Yasunori Goto on Wednesday, October 17, 2007 - 11:20 pm. (4 messages)
To: Andrew Morton <akpm@...>, Linus Torvalds <torvalds@...>
Cc: Linux Kernel <linux-kernel@...>
Date: Wednesday, October 17, 2007 - 11:18 pm

Linus, this is your patch from a few weeks ago.
It (still) solves problems for me here.
This should go into 2.6.24.

Fix BIN_TO_BCD()/BCD_TO_BIN() handling when setting the real-time alarm clock.

Signed-off-by: Mark Lord <mlord@pobox.com>

---
drivers/acpi/sleep/proc.c | 66 +++++++++++++++++++-------------------------
1 files changed, 29 insertions(+), 37 deletions(-)

diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c
index 3839efd..1538355 100644
--- a/drivers/acpi/sleep/proc.c
+++ b/drivers/acpi/sleep/proc.c
@@ -194,6 +194,23 @@ static int get_date_field(char **p, u32 * value)
return result;
}

+/* Read a possibly BCD register, always return binary */
+static u32 cmos_bcd_read(int offset, int rtc_control)
+{
+ u32 val = CMOS_READ(offset);
+ if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
+ BCD_TO_BIN(val);
+ return val;
+}
+
+/* Write binary value into possibly BCD register */
+static void cmos_bcd_write(u32 val, int offset, int rtc_control)
+{
+ if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
+ BIN_TO_BCD(val);
+ CMOS_WRITE(val, offset);
+}
+
static ssize_t
acpi_system_write_alarm(struct file *file,
const char __user * buffer, size_t count, loff_t * ppos)
@@ -258,35 +275,18 @@ acpi_system_write_alarm(struct file *file,
spin_lock_irq(&rtc_lock);

rtc_control = CMOS_READ(RTC_CONTROL);
- if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
- BIN_TO_BCD(yr);
- BIN_TO_BCD(mo);
- BIN_TO_BCD(day);
- BIN_TO_BCD(hr);
- BIN_TO_BCD(min);
- BIN_TO_BCD(sec);
- }

if (adjust) {
- yr += CMOS_READ(RTC_YEAR);
- mo += CMOS_READ(RTC_MONTH);
- day += CMOS_READ(RTC_DAY_OF_MONTH);
- hr += CMOS_READ(RTC_HOURS);
- min += CMOS_READ(RTC_MINUTES);
- sec += CMOS_READ(RTC_SECONDS);
+ yr += cmos_bcd_read(RTC_YEAR, rtc_control);
+ mo += cmos_bcd_read(RTC_MONTH, rtc_control);
+ day += cmos_bcd_read(RTC_DAY_OF_MONTH, rtc_control);
+ hr += cmos_bcd_read(RTC_HOURS, rtc_control);
+ min ...

To: Mark Lord <lkml@...>
Cc: <torvalds@...>, <linux-kernel@...>
Date: Thursday, October 18, 2007 - 6:11 pm

On Wed, 17 Oct 2007 23:18:32 -0400

This patch is presently (stuck) in -mm. I'll move it to my
must-be-in-2.6.24-even-if-the-maintainer-fluffs-it queue.
-

To: Andrew Morton <akpm@...>
Cc: Mark Lord <lkml@...>, <linux-kernel@...>
Date: Thursday, October 25, 2007 - 6:04 pm

I noticed that apparently this never happened, and it didn't go into -rc1.

I'll put it there myself, since I'm the author and Mark tested it, and the
old code was definitely totally buggy. The earlier it gets in, the better,
in case there are cleanups and/or other issues.

Linus
-

To: Linus Torvalds <torvalds@...>
Cc: <lkml@...>, <linux-kernel@...>, Len Brown <lenb@...>
Date: Thursday, October 25, 2007 - 6:13 pm

On Thu, 25 Oct 2007 15:04:18 -0700 (PDT)

I'll send over my copy. I don't think it changed.
-

Previous thread: [PATCH] Simplify /proc/cgroups by Paul Menage on Wednesday, October 17, 2007 - 10:56 pm. (2 messages)

Next thread: [Patch 000/002](memory hotplug) Rearrange notifier of memory hotplug (take 2) by Yasunori Goto on Wednesday, October 17, 2007 - 11:20 pm. (4 messages)