Commit 2a78e421 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

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: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://patch.msgid.link/13969123.uLZWGnKmhe@rafael.j.wysocki
parent 1ae2f435
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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)
+1 −4
Original line number Diff line number Diff line
@@ -18,10 +18,7 @@
#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;
+10 −0
Original line number Diff line number Diff line
@@ -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),
	}
};

+6 −0
Original line number Diff line number Diff line
@@ -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 */