]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ACPI: x86: cmos_rtc: Create a CMOS RTC platform device
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 23 Feb 2026 15:29:37 +0000 (16:29 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 26 Feb 2026 17:46:04 +0000 (18:46 +0100)
Make the CMOS RTC ACPI scan handler create a platform device that will
be used subsequently by rtc-cmos for driver binding on x86 systems with
ACPI and update add_rtc_cmos() to skip registering a fallback platform
device for the CMOS RTC when the above one has been registered.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com> # x86
Link: https://patch.msgid.link/1962427.tdWV9SEqCh@rafael.j.wysocki
arch/x86/kernel/rtc.c
drivers/acpi/x86/cmos_rtc.c
include/linux/acpi.h

index 51a849a79c985cb1781509b42315311c3ba26233..b112178e8185080587e4ba0951d3548f8c1a731b 100644 (file)
@@ -2,6 +2,7 @@
 /*
  * RTC related functions
  */
+#include <linux/acpi.h>
 #include <linux/platform_device.h>
 #include <linux/mc146818rtc.h>
 #include <linux/export.h>
@@ -146,6 +147,9 @@ static __init int add_rtc_cmos(void)
                }
        }
 #endif
+       if (cmos_rtc_platform_device_present)
+               return 0;
+
        if (!x86_platform.legacy.rtc)
                return -ENODEV;
 
index 45db7e51cbe6078a6baec9f883410ad9492cf9e2..bdd66dfd4a4411bbb773be3aba0356d02f2b99fc 100644 (file)
@@ -24,6 +24,8 @@ static const struct acpi_device_id acpi_cmos_rtc_ids[] = {
        {}
 };
 
+bool cmos_rtc_platform_device_present;
+
 static bool cmos_rtc_space_handler_present __read_mostly;
 
 static acpi_status acpi_cmos_rtc_space_handler(u32 function,
@@ -103,6 +105,12 @@ static int acpi_cmos_rtc_attach(struct acpi_device *adev,
        if (ret < 0)
                return ret;
 
+       if (IS_ERR_OR_NULL(acpi_create_platform_device(adev, NULL))) {
+               pr_err("Failed to create CMOS-RTC platform device\n");
+               return 0;
+       } else {
+               cmos_rtc_platform_device_present = true;
+       }
        return 1;
 }
 
index 4d2f0bed7a06da31aa63193bb969169aceb3c961..2bdb801cee017b174b2c50ad7e7d95471b7dca2d 100644 (file)
@@ -791,6 +791,8 @@ const char *acpi_get_subsystem_id(acpi_handle handle);
 int acpi_mrrm_max_mem_region(void);
 #endif
 
+extern bool cmos_rtc_platform_device_present;
+
 #else  /* !CONFIG_ACPI */
 
 #define acpi_disabled 1
@@ -1116,6 +1118,8 @@ static inline int acpi_mrrm_max_mem_region(void)
        return 1;
 }
 
+#define cmos_rtc_platform_device_present       false
+
 #endif /* !CONFIG_ACPI */
 
 #ifdef CONFIG_ACPI_HMAT