Skip to content

Commit 2a78e42

Browse files
committed
ACPI: x86/rtc-cmos: Use platform device for driver binding
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
1 parent 1ae2f43 commit 2a78e42

4 files changed

Lines changed: 18 additions & 5 deletions

File tree

drivers/acpi/acpi_pnp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ static int is_cmos_rtc_device(struct acpi_device *adev)
368368
{ "PNP0B02" },
369369
{""},
370370
};
371-
return !acpi_match_device_ids(adev, ids);
371+
return !cmos_rtc_platform_device_present && !acpi_match_device_ids(adev, ids);
372372
}
373373

374374
bool acpi_is_pnp_device(struct acpi_device *adev)

drivers/acpi/x86/cmos_rtc.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
#include "../internal.h"
1919

2020
static const struct acpi_device_id acpi_cmos_rtc_ids[] = {
21-
{ "PNP0B00" },
22-
{ "PNP0B01" },
23-
{ "PNP0B02" },
24-
{}
21+
ACPI_CMOS_RTC_IDS
2522
};
2623

2724
bool cmos_rtc_platform_device_present;

drivers/rtc/rtc-cmos.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
2929

30+
#include <linux/acpi.h>
3031
#include <linux/kernel.h>
3132
#include <linux/module.h>
3233
#include <linux/init.h>
@@ -1476,6 +1477,14 @@ static __init void cmos_of_init(struct platform_device *pdev)
14761477
#else
14771478
static inline void cmos_of_init(struct platform_device *pdev) {}
14781479
#endif
1480+
1481+
#ifdef CONFIG_ACPI
1482+
static const struct acpi_device_id acpi_cmos_rtc_ids[] = {
1483+
ACPI_CMOS_RTC_IDS
1484+
};
1485+
MODULE_DEVICE_TABLE(acpi, acpi_cmos_rtc_ids);
1486+
#endif
1487+
14791488
/*----------------------------------------------------------------*/
14801489

14811490
/* Platform setup should have set up an RTC device, when PNP is
@@ -1530,6 +1539,7 @@ static struct platform_driver cmos_platform_driver = {
15301539
.name = driver_name,
15311540
.pm = &cmos_pm_ops,
15321541
.of_match_table = of_match_ptr(of_cmos_match),
1542+
.acpi_match_table = ACPI_PTR(acpi_cmos_rtc_ids),
15331543
}
15341544
};
15351545

include/linux/acpi.h

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

794+
#define ACPI_CMOS_RTC_IDS \
795+
{ "PNP0B00", }, \
796+
{ "PNP0B01", }, \
797+
{ "PNP0B02", }, \
798+
{ "", }
799+
794800
extern bool cmos_rtc_platform_device_present;
795801

796802
#else /* !CONFIG_ACPI */

0 commit comments

Comments
 (0)