rtc: don't write RTC century when setting a wake alarm
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 20 lines · David Brownell
Quoted 6 lines · Mark Lord
David Brownell wrote:
..Quoted 3 lines
While you're fixing goofs in this general area, you might make that
/proc/acpi/alarmfile not write the century when it changes the alarm. That field isn't relevant to the alarm triggering.You mean like this?
Yes, but you found another little nest of bugs. I'm surprised this little bit of ACPI code is so buggy!!
I Cc'd Len Brown; ACPI patches should be submitted through the ACPI team, as a rule. Even for code they are slowly getting rid of. ;)
Quoted 5 lines
This patch (against 2.6.24-rc1-git12) fixes
/proc/acpi/alarmto not overwrite the RTC century field when setting a wake alarm. The alarm hardware doesn't have a century field, and we really should not be fiddling with the RTC century field here.
Quoted 12 lines
drivers/acpi/sleep/proc.c line 271
Quoted 9 lines
Signed-off-by Mark Lord <[email protected]>---
drivers/acpi/sleep/proc.c +0
-1@@ -268,7 +268,6 @@ day -=31 ; }if (mo >12 ) { - yr +=1 ;This is an unrelated nest of bugs; I'd not change that with this patch. I think that whole block of code trying to fix
..
I'm not trying to fix anything other than removing the write to the century register (near the bottom). However, once that write has been removed, there is no other use for the "yr", so the rest of the patch is simply getting rid of it everywhere where it looked safe to do so.
..
Quoted 59 lines
broken alarm times is dubious, and I can't see why broken values shouldn't just cause an "
-EINVAL" return. Notice it accepts illegal dates like November 31 (or February 30) too..Quoted 12 lines
drivers/acpi/sleep/proc.c +0
-1mo -=12 ; }@@ -277,7 +276,6 @@ rtc_control =CMOS_READ (RTC_CONTROL );if (adjust) { - 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);drivers/acpi/sleep/proc.c line 307
Quoted 4 lines
drivers/acpi/sleep/proc.c +0
-1@@ -304,7 +302,6 @@ day -=31 ; }if (mo >12 ) { - yr++;Not the same. This block of code would make more sense if it were in that "if (adjust) ..." block. If the preceding block returns an error, this one will become a NOP unless the alarm was adjusted; it's more just ugly code than a set of bugs.
However ... this code is missing range validation checks.
If I try to set an alarm two days in the future, and this chip only supports 24 hour alarms (FADT.day_alarm is zero), that would seem to be a case where this legacy code should report an error. Likewise with two months in the future (with FADT.month_alarm or FADT.day_alarm zero) ... or over one year from now, in every case.
drivers/acpi/sleep/proc.c line 335
Quoted 9 lines
drivers/acpi/sleep/proc.c +0
-2mo -=12 ; }@@ -331,8 +328,6 @@cmos_bcd_write (day, acpi_gbl_FADT.day_alarm, rtc_control);if (acpi_gbl_FADT.month_alarm)cmos_bcd_write (mo, acpi_gbl_FADT.month_alarm, rtc_control); -if (acpi_gbl_FADT.century) -cmos_bcd_write (yr /100 , acpi_gbl_FADT.century, rtc_control);This is what I was referring to, and that change is correct.
You're right to strip out use of the "year" field entirely, unless range validation gets added.
Quoted 4 lines
drivers/acpi/sleep/proc.c +0
-0/* enable the rtc alarm interrupt */ rtc_control |=RTC_AIE ;CMOS_WRITE (rtc_control,RTC_CONTROL );