Linux RTC
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	x86 Maintainers <x86@kernel.org>,
	linux-rtc@vger.kernel.org,
	Alexandre Belloni <alexandre.belloni@bootlin.com>
Subject: [PATCH v1 0/8] ACPI: x86/rtc-cmos: Bind rtc-cmos to platform devices
Date: Mon, 23 Feb 2026 16:27:16 +0100	[thread overview]
Message-ID: <5983325.DvuYhMxLoT@rafael.j.wysocki> (raw)

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.




             reply	other threads:[~2026-02-23 15:34 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-23 15:27 Rafael J. Wysocki [this message]
2026-02-23 15:28 ` [PATCH v1 1/8] ACPI: x86: cmos_rtc: Clean up address space handler driver Rafael J. Wysocki
2026-02-23 15:28 ` [PATCH v1 2/8] ACPI: x86: cmos_rtc: Improve coordination with ACPI TAD driver Rafael J. Wysocki
2026-02-23 15:29 ` [PATCH v1 3/8] ACPI: x86: cmos_rtc: Create a CMOS RTC platform device Rafael J. Wysocki
2026-02-25 18:01   ` Dave Hansen
2026-02-23 15:30 ` [PATCH v1 4/8] ACPI: x86/rtc-cmos: Use platform device for driver binding Rafael J. Wysocki
2026-02-26 13:01   ` Alexandre Belloni
2026-03-03  6:07   ` Nathan Chancellor
2026-03-03 12:51     ` Rafael J. Wysocki
2026-03-03 17:52       ` Nathan Chancellor
2026-03-03 18:47         ` Rafael J. Wysocki
2026-03-03 21:17           ` Nathan Chancellor
2026-03-04 12:42             ` Rafael J. Wysocki
2026-02-23 15:31 ` [PATCH v1 5/8] ACPI: PNP: Drop CMOS RTC PNP device support Rafael J. Wysocki
2026-02-23 15:31 ` [PATCH v1 6/8] x86: rtc: Drop PNP device check Rafael J. Wysocki
2026-02-25 18:01   ` Dave Hansen
2026-02-25 18:10     ` Rafael J. Wysocki
2026-02-23 15:32 ` [PATCH v1 7/8] rtc: cmos: Drop PNP device support Rafael J. Wysocki
2026-02-26 13:02   ` Alexandre Belloni
2026-02-23 15:33 ` [PATCH v1 8/8] ACPI: TAD/x86: cmos_rtc: Consolidate address space handler setup Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5983325.DvuYhMxLoT@rafael.j.wysocki \
    --to=rafael@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox