]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ACPI: x86/rtc-cmos: Use platform device for driver binding
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 23 Feb 2026 15:30:21 +0000 (16:30 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 26 Feb 2026 17:47:52 +0000 (18:47 +0100)
Modify the rtc-cmos driver to bind to a platform device on systems with
ACPI via acpi_match_table and advertise the CMOST RTC ACPI device IDs
for driver auto-loading.  Note that adding the requisite device IDs to
it and exposing them via MODULE_DEVICE_TABLE() is sufficient for this
purpose.

Since the ACPI device IDs in question are the same as for the CMOS RTC
ACPI scan handler, put them into a common header file and use the
definition from there in both places.

Additionally, to prevent a PNP device from being created for the CMOS
RTC if a platform one is present already, make is_cmos_rtc_device()
check cmos_rtc_platform_device_present introduced previously.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://patch.msgid.link/13969123.uLZWGnKmhe@rafael.j.wysocki
drivers/acpi/acpi_pnp.c
drivers/acpi/x86/cmos_rtc.c
drivers/rtc/rtc-cmos.c
include/linux/acpi.h

index 85d9f78619a2191bce117f319cbba2cd62866bd6..4ad8f56d1a5d060646fdd20a0c8d9109fa2bbf75 100644 (file)
@@ -368,7 +368,7 @@ static int is_cmos_rtc_device(struct acpi_device *adev)
                { "PNP0B02" },
                {""},
        };
-       return !acpi_match_device_ids(adev, ids);
+       return !cmos_rtc_platform_device_present && !acpi_match_device_ids(adev, ids);
 }
 
 bool acpi_is_pnp_device(struct acpi_device *adev)
index bdd66dfd4a4411bbb773be3aba0356d02f2b99fc..a6df5b991c96075c2c5d05d19e64a41cf956e5b2 100644 (file)
 #include "../internal.h"
 
 static const struct acpi_device_id acpi_cmos_rtc_ids[] = {
-       { "PNP0B00" },
-       { "PNP0B01" },
-       { "PNP0B02" },
-       {}
+       ACPI_CMOS_RTC_IDS
 };
 
 bool cmos_rtc_platform_device_present;
index 0743c6acd6e2c11f5838855f5f485168e1302d51..7457f42fd6f083712d1be5174396151fb6501b56 100644 (file)
@@ -27,6 +27,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
+#include <linux/acpi.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -1476,6 +1477,14 @@ static __init void cmos_of_init(struct platform_device *pdev)
 #else
 static inline void cmos_of_init(struct platform_device *pdev) {}
 #endif
+
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id acpi_cmos_rtc_ids[] = {
+       ACPI_CMOS_RTC_IDS
+};
+MODULE_DEVICE_TABLE(acpi, acpi_cmos_rtc_ids);
+#endif
+
 /*----------------------------------------------------------------*/
 
 /* Platform setup should have set up an RTC device, when PNP is
@@ -1530,6 +1539,7 @@ static struct platform_driver cmos_platform_driver = {
                .name           = driver_name,
                .pm             = &cmos_pm_ops,
                .of_match_table = of_match_ptr(of_cmos_match),
+               .acpi_match_table = ACPI_PTR(acpi_cmos_rtc_ids),
        }
 };
 
index 2bdb801cee017b174b2c50ad7e7d95471b7dca2d..5ecdcdaf31aa3ab8f69cc1120c40b05deadd6321 100644 (file)
@@ -791,6 +791,12 @@ const char *acpi_get_subsystem_id(acpi_handle handle);
 int acpi_mrrm_max_mem_region(void);
 #endif
 
+#define ACPI_CMOS_RTC_IDS      \
+       { "PNP0B00", },         \
+       { "PNP0B01", },         \
+       { "PNP0B02", },         \
+       { "", }
+
 extern bool cmos_rtc_platform_device_present;
 
 #else  /* !CONFIG_ACPI */