From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>,
linux-rtc@vger.kernel.org
Cc: Linux ACPI <linux-acpi@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Linux PM <linux-pm@vger.kernel.org>,
Zhang Rui <rui.zhang@intel.com>,
Alessandro Zummo <a.zummo@towertech.it>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 5/5] rtc: rtc-cmos: Disable ACPI RTC event on removal
Date: Mon, 07 Nov 2022 21:03:06 +0100 [thread overview]
Message-ID: <2219830.iZASKD2KPV@kreacher> (raw)
In-Reply-To: <2276401.ElGaqSPkdT@kreacher>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
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.
While at it, make cmos_do_remove() also clear the driver data pointer
of the device and make cmos_acpi_wake_setup() do that in the error path
too.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/rtc/rtc-cmos.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
Index: linux-pm/drivers/rtc/rtc-cmos.c
===================================================================
--- linux-pm.orig/drivers/rtc/rtc-cmos.c
+++ linux-pm/drivers/rtc/rtc-cmos.c
@@ -798,6 +798,12 @@ static inline void acpi_rtc_event_setup(
acpi_disable_event(ACPI_EVENT_RTC, 0);
}
+static inline void acpi_rtc_event_cleanup(void)
+{
+ if (!acpi_disabled)
+ acpi_remove_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler);
+}
+
static void rtc_wake_on(struct device *dev)
{
acpi_clear_event(ACPI_EVENT_RTC);
@@ -884,6 +890,10 @@ static inline void acpi_rtc_event_setup(
{
}
+static inline void acpi_rtc_event_cleanup(void)
+{
+}
+
static inline void cmos_acpi_wake_setup(struct device *dev)
{
}
@@ -1109,6 +1119,7 @@ cleanup2:
free_irq(rtc_irq, cmos_rtc.rtc);
cleanup1:
cmos_rtc.dev = NULL;
+ dev_set_drvdata(dev, NULL);
cleanup0:
if (RTC_IOMAPPED)
release_region(ports->start, resource_size(ports));
@@ -1138,6 +1149,9 @@ static void cmos_do_remove(struct device
hpet_unregister_irq_handler(cmos_interrupt);
}
+ if (!dev_get_platdata(dev))
+ acpi_rtc_event_cleanup();
+
cmos->rtc = NULL;
ports = cmos->iomem;
@@ -1148,6 +1162,7 @@ static void cmos_do_remove(struct device
cmos->iomem = NULL;
cmos->dev = NULL;
+ dev_set_drvdata(dev, NULL);
}
static int cmos_aie_poweroff(struct device *dev)
next prev parent reply other threads:[~2022-11-07 20:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-07 19:58 [PATCH v1 0/5] rtc: rtc-cmos: Assorted ACPI-related cleanups and fixes Rafael J. Wysocki
2022-11-07 19:59 ` [PATCH v1 1/5] rtc: rtc-cmos: Call cmos_wake_setup() from cmos_do_probe() Rafael J. Wysocki
2022-11-08 2:30 ` Zhang Rui
2022-11-08 13:09 ` Rafael J. Wysocki
2022-11-08 15:41 ` Zhang Rui
2022-11-07 20:00 ` [PATCH v1 2/5] rtc: rtc-cmos: Call rtc_wake_setup() " Rafael J. Wysocki
2022-11-07 20:00 ` [PATCH v1 3/5] rtc: rtc-cmos: Eliminate forward declarations of some functions Rafael J. Wysocki
2022-11-07 20:01 ` [PATCH v1 4/5] rtc: rtc-cmos: Rename ACPI-related functions Rafael J. Wysocki
2022-11-07 21:21 ` Andy Shevchenko
2022-11-08 14:43 ` Rafael J. Wysocki
2022-11-07 20:03 ` Rafael J. Wysocki [this message]
2022-11-07 21:20 ` [PATCH v1 5/5] rtc: rtc-cmos: Disable ACPI RTC event on removal Andy Shevchenko
2022-11-08 14:54 ` Rafael J. Wysocki
2022-11-07 21:28 ` Andy Shevchenko
2022-11-08 14:54 ` Rafael J. Wysocki
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=2219830.iZASKD2KPV@kreacher \
--to=rjw@rjwysocki.net \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@bootlin.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=rui.zhang@intel.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox