All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Linux ACPI <linux-acpi@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	x86 Maintainers <x86@kernel.org>,
	linux-rtc@vger.kernel.org
Subject: Re: [PATCH v1 4/8] ACPI: x86/rtc-cmos: Use platform device for driver binding
Date: Thu, 26 Feb 2026 14:01:34 +0100	[thread overview]
Message-ID: <20260226130134aa75696e@mail.local> (raw)
In-Reply-To: <13969123.uLZWGnKmhe@rafael.j.wysocki>

On 23/02/2026 16:30:21+0100, Rafael J. Wysocki wrote:
> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
> 
> 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>

> ---
>  drivers/acpi/acpi_pnp.c     |  2 +-
>  drivers/acpi/x86/cmos_rtc.c |  5 +----
>  drivers/rtc/rtc-cmos.c      | 10 ++++++++++
>  include/linux/acpi.h        |  6 ++++++
>  4 files changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
> index 85d9f78619a2..4ad8f56d1a5d 100644
> --- a/drivers/acpi/acpi_pnp.c
> +++ b/drivers/acpi/acpi_pnp.c
> @@ -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)
> diff --git a/drivers/acpi/x86/cmos_rtc.c b/drivers/acpi/x86/cmos_rtc.c
> index bdd66dfd4a44..a6df5b991c96 100644
> --- a/drivers/acpi/x86/cmos_rtc.c
> +++ b/drivers/acpi/x86/cmos_rtc.c
> @@ -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;
> diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
> index 0743c6acd6e2..7457f42fd6f0 100644
> --- a/drivers/rtc/rtc-cmos.c
> +++ b/drivers/rtc/rtc-cmos.c
> @@ -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),
>  	}
>  };
>  
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 2bdb801cee01..5ecdcdaf31aa 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -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 */
> -- 
> 2.51.0
> 
> 
> 
> 

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  reply	other threads:[~2026-02-26 13:01 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-23 15:27 [PATCH v1 0/8] ACPI: x86/rtc-cmos: Bind rtc-cmos to platform devices Rafael J. Wysocki
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 [this message]
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=20260226130134aa75696e@mail.local \
    --to=alexandre.belloni@bootlin.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=rafael@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.