Skip to content

Commit 1ae2f43

Browse files
committed
ACPI: x86: cmos_rtc: Create a CMOS RTC platform device
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
1 parent 6cee29a commit 1ae2f43

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

arch/x86/kernel/rtc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/*
33
* RTC related functions
44
*/
5+
#include <linux/acpi.h>
56
#include <linux/platform_device.h>
67
#include <linux/mc146818rtc.h>
78
#include <linux/export.h>
@@ -146,6 +147,9 @@ static __init int add_rtc_cmos(void)
146147
}
147148
}
148149
#endif
150+
if (cmos_rtc_platform_device_present)
151+
return 0;
152+
149153
if (!x86_platform.legacy.rtc)
150154
return -ENODEV;
151155

drivers/acpi/x86/cmos_rtc.c

Lines changed: 8 additions & 0 deletions
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+
bool cmos_rtc_platform_device_present;
28+
2729
static bool cmos_rtc_space_handler_present __read_mostly;
2830

2931
static acpi_status acpi_cmos_rtc_space_handler(u32 function,
@@ -103,6 +105,12 @@ static int acpi_cmos_rtc_attach(struct acpi_device *adev,
103105
if (ret < 0)
104106
return ret;
105107

108+
if (IS_ERR_OR_NULL(acpi_create_platform_device(adev, NULL))) {
109+
pr_err("Failed to create CMOS-RTC platform device\n");
110+
return 0;
111+
} else {
112+
cmos_rtc_platform_device_present = true;
113+
}
106114
return 1;
107115
}
108116

include/linux/acpi.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,8 @@ const char *acpi_get_subsystem_id(acpi_handle handle);
791791
int acpi_mrrm_max_mem_region(void);
792792
#endif
793793

794+
extern bool cmos_rtc_platform_device_present;
795+
794796
#else /* !CONFIG_ACPI */
795797

796798
#define acpi_disabled 1
@@ -1116,6 +1118,8 @@ static inline int acpi_mrrm_max_mem_region(void)
11161118
return 1;
11171119
}
11181120

1121+
#define cmos_rtc_platform_device_present false
1122+
11191123
#endif /* !CONFIG_ACPI */
11201124

11211125
#ifdef CONFIG_ACPI_HMAT

0 commit comments

Comments
 (0)