[PATCH v1 0/8] ACPI: x86/rtc-cmos: Bind rtc-cmos to platform devices
From: Rafael J. Wysocki
Date: Mon Feb 23 2026 - 10:41:01 EST
Currently, on x86 the CMOS RTC is represented by a PNP device which
generally works, but the amount of avoidable code entanglement related
to that is a bit over the top.
First of all, in order to create a PNP device for the CMOS RTC, the ACPI
PNP meta-driver needs to be aware of that device, but adding the CMOS
RTC device IDs to acpi_pnp_device_ids[] was not sufficient for this
purpose because of the CMOS RTC ACPI address space driver that added an
ACPI scan handler for the CMOS RTC. That scan handler simply installs
the requisite ACPI address space handler for the CMOS RTC address space,
but it also claims the CMOS RTC device which prevents the ACPI PNP scan
handler from taking care of it. That's why there is is_cmos_rtc_device()
that needs to be additionally called by acpi_is_pnp_device().
Second, add_rtc_cmos() needs to check whether or not the CMOS RTC device
is present so it knows whether or not to create a fallback platform
device for the CMOS RTC. The way it does that is somewhat less than
elegant.
Finally, the rtc-cmos driver carries a PNP driver interface so it can
bind to the CMOS RTC device.
Moreover, on some systems the CMOS RTC device is the only PNP device in
use, so if it is represented by a device of a different type, the PNP
subsystem can be compiled out entirely on those systems.
That can be achieved with the help of the observation that the rtc-cmos
driver actually can work with platform devices already and the only
change that needs to be made to it in order to make that happen on x86
is to add CMOS RTC device IDs to it along with the related
MODULE_DEVICE_TABLE() declaration, which is done in patch [4/8].
However, for the above to work, the requisite platform devices actually
need to be created and patch [3/8] updates the CMOS RTC ACPI scan
handler used by the CMOS RTC ACPI address space handler to do just that.
It also adds a bool variable to be used by add_rtc_cmos() to check
whether or not to add a fallback platform device for the CMOS RTC.
Before that happens, patches [1-2/8] prepare the CMOS RTC ACPI address
space handler for the subsequent changes by rearranging it and fixing
its interactions with the ACPI time and alarm device (TAD) driver.
The next three patches, [5-7/8] simply drop some code that is not
necessary any more. Patch [5/8] drops CMOS RTC support from the ACPI
PNP meta-driver, patch [6/8] drops the walk over PNP devices from
add_rtc_cmos(), and patch [7/8] drops the PNP driver interface from
the rtc-cmos driver.
Patch [8/8] is a bonus cleanup adding the ACPI TAD device ID to the
CMOS RTC ACPI scan handler in the CMOS RTC address space driver, so
it will create an ACPI TAD platform device after installing the CMOS
RTC address space handler. After that change, the ACPI TAD driver
doesn't need to attempt to install the CMOS RTC ACPI address space
handler any more and can be simplified quite a bit.
After all of that, the CMOS RTC device IDs are only used in 2 places
(instead of 5) and well over 100 lines of code that is not super-nice
go away.