Skip to content

Commit 6cee29a

Browse files
committed
ACPI: x86: cmos_rtc: Improve coordination with ACPI TAD driver
If a CMOS RTC (PNP0B00/PNP0B01/PNP0B02) device coexists with an ACPI TAD (timer and event alarm device, ACPI000E), the ACPI TAD driver will attempt to install the CMOS RTC address space hanlder that has been installed already and the TAD probing will fail. Avoid that by changing acpi_install_cmos_rtc_space_handler() to return zero and acpi_remove_cmos_rtc_space_handler() to do nothing if the CMOS RTC address space handler has been installed already. Fixes: 596ca52 ("ACPI: TAD: Install SystemCMOS address space handler for ACPI000E") Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/2415111.ElGaqSPkdT@rafael.j.wysocki
1 parent ba0b236 commit 6cee29a

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

drivers/acpi/x86/cmos_rtc.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ static const struct acpi_device_id acpi_cmos_rtc_ids[] = {
2424
{}
2525
};
2626

27+
static bool cmos_rtc_space_handler_present __read_mostly;
28+
2729
static acpi_status acpi_cmos_rtc_space_handler(u32 function,
2830
acpi_physical_address address,
2931
u32 bits, u64 *value64,
@@ -59,6 +61,9 @@ int acpi_install_cmos_rtc_space_handler(acpi_handle handle)
5961
{
6062
acpi_status status;
6163

64+
if (cmos_rtc_space_handler_present)
65+
return 0;
66+
6267
status = acpi_install_address_space_handler(handle,
6368
ACPI_ADR_SPACE_CMOS,
6469
acpi_cmos_rtc_space_handler,
@@ -68,6 +73,8 @@ int acpi_install_cmos_rtc_space_handler(acpi_handle handle)
6873
return -ENODEV;
6974
}
7075

76+
cmos_rtc_space_handler_present = true;
77+
7178
return 1;
7279
}
7380
EXPORT_SYMBOL_GPL(acpi_install_cmos_rtc_space_handler);
@@ -76,6 +83,9 @@ void acpi_remove_cmos_rtc_space_handler(acpi_handle handle)
7683
{
7784
acpi_status status;
7885

86+
if (cmos_rtc_space_handler_present)
87+
return;
88+
7989
status = acpi_remove_address_space_handler(handle,
8090
ACPI_ADR_SPACE_CMOS,
8191
acpi_cmos_rtc_space_handler);
@@ -87,7 +97,13 @@ EXPORT_SYMBOL_GPL(acpi_remove_cmos_rtc_space_handler);
8797
static int acpi_cmos_rtc_attach(struct acpi_device *adev,
8898
const struct acpi_device_id *id)
8999
{
90-
return acpi_install_cmos_rtc_space_handler(adev->handle);
100+
int ret;
101+
102+
ret = acpi_install_cmos_rtc_space_handler(adev->handle);
103+
if (ret < 0)
104+
return ret;
105+
106+
return 1;
91107
}
92108

93109
static struct acpi_scan_handler cmos_rtc_handler = {

0 commit comments

Comments
 (0)