Skip to content

Commit 83ebb7b

Browse files
rafaeljwalexandrebelloni
authored andcommitted
rtc: cmos: Disable ACPI RTC event on removal
Make cmos_do_remove() drop the ACPI RTC fixed event handler so as to prevent it from operating on stale data in case the event triggers after driver removal. Fixes: 311ee9c ("rtc: cmos: allow using ACPI for RTC alarm instead of HPET") Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Zhang Rui <[email protected]> Tested-by: Zhang Rui <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/2224609.iZASKD2KPV@kreacher Signed-off-by: Alexandre Belloni <[email protected]>
1 parent d13e9ad commit 83ebb7b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/rtc/rtc-cmos.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,14 @@ static void acpi_rtc_event_setup(struct device *dev)
798798
acpi_disable_event(ACPI_EVENT_RTC, 0);
799799
}
800800

801+
static void acpi_rtc_event_cleanup(void)
802+
{
803+
if (acpi_disabled)
804+
return;
805+
806+
acpi_remove_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler);
807+
}
808+
801809
static void rtc_wake_on(struct device *dev)
802810
{
803811
acpi_clear_event(ACPI_EVENT_RTC);
@@ -884,6 +892,10 @@ static inline void acpi_rtc_event_setup(struct device *dev)
884892
{
885893
}
886894

895+
static inline void acpi_rtc_event_cleanup(void)
896+
{
897+
}
898+
887899
static inline void acpi_cmos_wake_setup(struct device *dev)
888900
{
889901
}
@@ -1138,6 +1150,9 @@ static void cmos_do_remove(struct device *dev)
11381150
hpet_unregister_irq_handler(cmos_interrupt);
11391151
}
11401152

1153+
if (!dev_get_platdata(dev))
1154+
acpi_rtc_event_cleanup();
1155+
11411156
cmos->rtc = NULL;
11421157

11431158
ports = cmos->iomem;

0 commit comments

Comments
 (0)