* [PATCH] rtc: cmos: Remove redundant include of linux/acpi.h
From: Chen Ni @ 2026-03-04 2:35 UTC (permalink / raw)
To: alexandre.belloni; +Cc: linux-rtc, Chen Ni
The header file <linux/acpi.h> is already included globally at the top
of the file. The second inclusion inside the #ifdef CONFIG_ACPI block is
redundant because the header uses include guards to prevent multiple
inclusions.
Remove the duplicate line to clean up the code and slightly reduce
preprocessing overhead.
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
drivers/rtc/rtc-cmos.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index 9ac5bab846c1..7c06b9d19273 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -743,8 +743,6 @@ static irqreturn_t cmos_interrupt(int irq, void *p)
#ifdef CONFIG_ACPI
-#include <linux/acpi.h>
-
static u32 rtc_handler(void *context)
{
struct device *dev = context;
--
2.25.1
^ permalink raw reply related
* Re: [PATCH v1] dt-bindings: rtc: mpfs-rtc: permit resets
From: Krzysztof Kozlowski @ 2026-03-04 8:34 UTC (permalink / raw)
To: Conor Dooley
Cc: linux-rtc, Conor Dooley, Alexandre Belloni, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Daire McNamara, devicetree,
linux-kernel
In-Reply-To: <20260303-flounder-slate-dd69766990ce@spud>
On Tue, Mar 03, 2026 at 04:36:33PM +0000, Conor Dooley wrote:
> From: Conor Dooley <conor.dooley@microchip.com>
>
> The RTC on mpfs and pic64gx has a reset pin, but until now this has been
> undocumented because platform firmware takes the RTC out of reset on
> first-party boards (or those using modified versions of the vendor
> firmware), but not all boards may take this approach. Permit providing a
> reset in devicetree for Linux, or other devicetree-consuming software,
> to use.
>
> Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Best regards,
Krzysztof
^ permalink raw reply
* Re: [PATCH 1/3] optee: simplify OP-TEE context match
From: Jens Wiklander @ 2026-03-04 9:34 UTC (permalink / raw)
To: Sumit Garg
Cc: rouven.czerwinski, Olivia Mackall, Herbert Xu,
Clément Léger, Alexandre Belloni, op-tee, linux-kernel,
linux-crypto, linux-rtc
In-Reply-To: <aYrAeEiqG7iwXm_w@sumit-xelite>
On Tue, Feb 10, 2026 at 6:22 AM Sumit Garg <sumit.garg@kernel.org> wrote:
>
> On Mon, Jan 26, 2026 at 11:11:24AM +0100, Rouven Czerwinski via B4 Relay wrote:
> > From: Rouven Czerwinski <rouven.czerwinski@linaro.org>
> >
> > Simplify the TEE implementor ID match by returning the boolean
> > expression directly instead of going through an if/else.
> >
> > Signed-off-by: Rouven Czerwinski <rouven.czerwinski@linaro.org>
> > ---
> > drivers/tee/optee/device.c | 5 +----
> > 1 file changed, 1 insertion(+), 4 deletions(-)
> >
>
> Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
I'm picking up this.
Thanks,
Jens
>
> -Sumit
>
> > diff --git a/drivers/tee/optee/device.c b/drivers/tee/optee/device.c
> > index 950b4661d5df..4c85b04d6004 100644
> > --- a/drivers/tee/optee/device.c
> > +++ b/drivers/tee/optee/device.c
> > @@ -13,10 +13,7 @@
> >
> > static int optee_ctx_match(struct tee_ioctl_version_data *ver, const void *data)
> > {
> > - if (ver->impl_id == TEE_IMPL_ID_OPTEE)
> > - return 1;
> > - else
> > - return 0;
> > + return (ver->impl_id == TEE_IMPL_ID_OPTEE);
> > }
> >
> > static int get_devices(struct tee_context *ctx, u32 session,
> >
> > --
> > 2.52.0
> >
> >
> >
^ permalink raw reply
* Re: [PATCH v1 4/8] ACPI: x86/rtc-cmos: Use platform device for driver binding
From: Rafael J. Wysocki @ 2026-03-04 12:42 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Rafael J. Wysocki, Linux ACPI, LKML, x86 Maintainers, linux-rtc,
Alexandre Belloni
In-Reply-To: <20260303211725.GA2374171@ax162>
On Tue, Mar 3, 2026 at 10:17 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> On Tue, Mar 03, 2026 at 07:47:54PM +0100, Rafael J. Wysocki wrote:
> > On Tue, Mar 3, 2026 at 6:52 PM Nathan Chancellor <nathan@kernel.org> wrote:
> > >
> > > On Tue, Mar 03, 2026 at 01:51:37PM +0100, Rafael J. Wysocki wrote:
> > > > On Tuesday, March 3, 2026 7:07:52 AM CET Nathan Chancellor wrote:
> > > > > After this change in -next as commit 2a78e4210444 ("ACPI: x86/rtc-cmos:
> > > > > Use platform device for driver binding"), I am seeing
> > > > >
> > > > > rtc_cmos PNP0B00:00: error -ENXIO: IRQ index 0 not found
> > > > >
> > > > > on a few of my test machines. Is this expected?
> > > >
> > > > Not really, thanks for reporting!
> > > >
> > > > Please send me a dmesg boot log from one of the affected systems.
> > >
> > > Attached.
> > >
> > > > The patch below should make the message go away.
> > >
> > > Can confirm, thanks! If it is helpful:
> > >
> > > Tested-by: Nathan Chancellor <nathan@kernel.org>
> >
> > Thank you!
> >
> > Can you please also send me a dmesg boot log from the same system with
> > this patch applied?
>
> Attached. Let me know if you need anything else.
All is fine now AFAICS, thanks!
^ permalink raw reply
* [PATCH v2] rtc: cmos: Use platform_get_irq_optional() in cmos_platform_probe()
From: Rafael J. Wysocki @ 2026-03-04 12:55 UTC (permalink / raw)
To: Linux ACPI; +Cc: LKML, Nathan Chancellor, Alexandre Belloni, linux-rtc
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
The rtc-cmos driver can live without an IRQ and returning an error
code from platform_get_irq() is not a problem for it in general, so
make it call platform_get_irq_optional() in cmos_platform_probe()
instead of platform_get_irq() to avoid a confusing error message
printed by the latter if an IRQ cannot be found for index 0, which
is possible on x86 platforms.
Additionally, on x86, if the IRQ is not defined and the system has
a legacy PIC, hardcode it to RTC_IRQ, which should be safe then (and
which is what the dropped PNP code did).
Fixes: d15f1c2e413e ("ACPI: PNP: Drop CMOS RTC PNP device support")
Reported-by: Nathan Chancellor <nathan@kernel.org>
Closes: https://lore.kernel.org/linux-acpi/20260303060752.GA2749263@ax162/
Tested-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
v1 -> v2: Added tags, edited changelog
This is linux-next material.
---
drivers/rtc/rtc-cmos.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -1423,9 +1423,18 @@ static int __init cmos_platform_probe(st
resource = platform_get_resource(pdev, IORESOURCE_IO, 0);
else
resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- irq = platform_get_irq(pdev, 0);
- if (irq < 0)
+ irq = platform_get_irq_optional(pdev, 0);
+ if (irq < 0) {
irq = -1;
+#ifdef CONFIG_X86
+ /*
+ * On some x86 systems, the IRQ is not defined, but it should
+ * always be safe to hardcode it on systems with a legacy PIC.
+ */
+ if (nr_legacy_irqs())
+ irq = RTC_IRQ;
+#endif
+ }
return cmos_do_probe(&pdev->dev, resource, irq);
}
^ permalink raw reply
* [PATCH v1 7/7] ACPI: TAD: Update the driver description comment
From: Rafael J. Wysocki @ 2026-03-04 18:16 UTC (permalink / raw)
To: Linux ACPI; +Cc: Alexandre Belloni, LKML, linux-rtc, Linux PM
In-Reply-To: <5092662.31r3eYUQgx@rafael.j.wysocki>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Update the preamble comment describing the driver to match the code
after previous changes along with the copyright information.
No functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/acpi_tad.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
--- a/drivers/acpi/acpi_tad.c
+++ b/drivers/acpi/acpi_tad.c
@@ -2,12 +2,10 @@
/*
* ACPI Time and Alarm (TAD) Device Driver
*
- * Copyright (C) 2018 Intel Corporation
+ * Copyright (C) 2018 - 2026 Intel Corporation
* Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
*
- * This driver is based on Section 9.18 of the ACPI 6.2 specification revision.
- *
- * It only supports the system wakeup capabilities of the TAD.
+ * This driver is based on ACPI 6.6, Section 9.17.
*
* Provided are sysfs attributes, available under the TAD platform device,
* allowing user space to manage the AC and DC wakeup timers of the TAD:
@@ -18,6 +16,11 @@
*
* The wakeup events handling and power management of the TAD is expected to
* be taken care of by the ACPI PM domain attached to its platform device.
+ *
+ * If the TAD supports the get/set real time features, as indicated by the
+ * capability mask returned by _GCP under the TAD object, additional sysfs
+ * attributes are created allowing the real time to be set and read and an RTC
+ * class device is registered under the TAD platform device.
*/
#include <linux/acpi.h>
@@ -32,7 +35,7 @@ MODULE_DESCRIPTION("ACPI Time and Alarm
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Rafael J. Wysocki");
-/* ACPI TAD capability flags (ACPI 6.2, Section 9.18.2) */
+/* ACPI TAD capability flags (ACPI 6.6, Section 9.17.2) */
#define ACPI_TAD_AC_WAKE BIT(0)
#define ACPI_TAD_DC_WAKE BIT(1)
#define ACPI_TAD_RT BIT(2)
^ permalink raw reply
* [PATCH v1 6/7] ACPI: TAD: Add RTC class device interface
From: Rafael J. Wysocki @ 2026-03-04 18:16 UTC (permalink / raw)
To: Linux ACPI; +Cc: Alexandre Belloni, LKML, linux-rtc, Linux PM
In-Reply-To: <5092662.31r3eYUQgx@rafael.j.wysocki>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Add an RTC class device interface allowing to read and set the real time
value to the ACPI TAD driver.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/acpi_tad.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 76 insertions(+), 2 deletions(-)
--- a/drivers/acpi/acpi_tad.c
+++ b/drivers/acpi/acpi_tad.c
@@ -25,6 +25,7 @@
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
+#include <linux/rtc.h>
#include <linux/suspend.h>
MODULE_DESCRIPTION("ACPI Time and Alarm (TAD) Device Driver");
@@ -51,6 +52,7 @@ MODULE_AUTHOR("Rafael J. Wysocki");
/* ACPI TAD RTC */
#define ACPI_TAD_TZ_UNSPEC 2047
+#define ACPI_TAD_TIME_ISDST 3
struct acpi_tad_driver_data {
u32 capabilities;
@@ -164,6 +166,8 @@ static int acpi_tad_get_real_time(struct
return 0;
}
+/* sysfs interface */
+
static char *acpi_tad_rt_next_field(char *s, int *val)
{
char *p;
@@ -579,6 +583,71 @@ static const struct attribute_group acpi
.is_visible = acpi_tad_attr_is_visible,
};
+#ifdef CONFIG_RTC_CLASS
+/* RTC class device interface */
+
+static int acpi_tad_rtc_set_time(struct device *dev, struct rtc_time *tm)
+{
+ struct acpi_tad_rt rt;
+
+ rt.year = tm->tm_year + 1900;
+ rt.month = tm->tm_mon + 1;
+ rt.day = tm->tm_mday;
+ rt.hour = tm->tm_hour;
+ rt.minute = tm->tm_min;
+ rt.second = tm->tm_sec;
+ rt.tz = ACPI_TAD_TZ_UNSPEC;
+ rt.daylight = ACPI_TAD_TIME_ISDST * !!tm->tm_isdst;
+
+ return acpi_tad_set_real_time(dev, &rt);
+}
+
+static int acpi_tad_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+ struct acpi_tad_rt rt;
+ int ret;
+
+ ret = acpi_tad_get_real_time(dev, &rt);
+ if (ret)
+ return ret;
+
+ tm->tm_year = rt.year - 1900;
+ tm->tm_mon = rt.month - 1;
+ tm->tm_mday = rt.day;
+ tm->tm_hour = rt.hour;
+ tm->tm_min = rt.minute;
+ tm->tm_sec = rt.second;
+ tm->tm_isdst = rt.daylight == ACPI_TAD_TIME_ISDST;
+
+ return 0;
+}
+
+static const struct rtc_class_ops acpi_tad_rtc_ops = {
+ .read_time = acpi_tad_rtc_read_time,
+ .set_time = acpi_tad_rtc_set_time,
+};
+
+static void acpi_tad_register_rtc(struct device *dev)
+{
+ struct rtc_device *rtc;
+
+ rtc = devm_rtc_allocate_device(dev);
+ if (IS_ERR(rtc))
+ return;
+
+ rtc->range_min = mktime64(1900, 1, 1, 0, 0, 0);
+ rtc->range_max = mktime64(9999, 12, 31, 23, 59, 59);
+
+ rtc->ops = &acpi_tad_rtc_ops;
+
+ devm_rtc_register_device(rtc);
+}
+#else /* !CONFIG_RTC_CLASS */
+static inline void acpi_tad_register_rtc(struct device *dev) {}
+#endif /* !CONFIG_RTC_CLASS */
+
+/* Platform driver interface */
+
static int acpi_tad_disable_timer(struct device *dev, u32 timer_id)
{
return acpi_tad_wake_set(dev, "_STV", timer_id, ACPI_TAD_WAKE_DISABLED);
@@ -660,10 +729,15 @@ static int acpi_tad_probe(struct platfor
pm_runtime_suspend(dev);
ret = sysfs_create_group(&dev->kobj, &acpi_tad_attr_group);
- if (ret)
+ if (ret) {
acpi_tad_remove(pdev);
+ return ret;
+ }
- return ret;
+ if (caps & ACPI_TAD_RT)
+ acpi_tad_register_rtc(dev);
+
+ return 0;
}
static const struct acpi_device_id acpi_tad_ids[] = {
^ permalink raw reply
* [PATCH v1 5/7] ACPI: TAD: Clear unused RT data in acpi_tad_set_real_time()
From: Rafael J. Wysocki @ 2026-03-04 18:15 UTC (permalink / raw)
To: Linux ACPI; +Cc: Alexandre Belloni, LKML, linux-rtc, Linux PM
In-Reply-To: <5092662.31r3eYUQgx@rafael.j.wysocki>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Move the clearing of the fields in struct acpi_tad_rt that are not used
on the real time setting side to acpi_tad_set_real_time().
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/acpi_tad.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- a/drivers/acpi/acpi_tad.c
+++ b/drivers/acpi/acpi_tad.c
@@ -96,6 +96,10 @@ static int acpi_tad_set_real_time(struct
if (acpi_tad_rt_is_invalid(rt))
return -EINVAL;
+ rt->valid = 0;
+ rt->msec = 0;
+ memset(rt->padding, 0, 3);
+
args[0].buffer.pointer = (u8 *)rt;
args[0].buffer.length = sizeof(*rt);
@@ -233,10 +237,6 @@ static ssize_t time_store(struct device
rt.daylight = val;
- rt.valid = 0;
- rt.msec = 0;
- memset(rt.padding, 0, 3);
-
ret = acpi_tad_set_real_time(dev, &rt);
if (ret)
return ret;
^ permalink raw reply
* [PATCH v1 4/7] ACPI: TAD: Rearrange RT data validation checking
From: Rafael J. Wysocki @ 2026-03-04 18:14 UTC (permalink / raw)
To: Linux ACPI; +Cc: Alexandre Belloni, LKML, linux-rtc, Linux PM
In-Reply-To: <5092662.31r3eYUQgx@rafael.j.wysocki>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Move RT data validation checks from acpi_tad_set_real_time() to
a separate function called acpi_tad_rt_is_invalid() and use it
also in acpi_tad_get_real_time() to validate data coming from
the platform firmware.
Also make acpi_tad_set_real_time() return -EINVAL when the RT data
passed to it is invalid (instead of -ERANGE which is somewhat
confusing) and introduce ACPI_TAD_TZ_UNSPEC to represent the
"unspecified timezone" value.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/acpi_tad.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
--- a/drivers/acpi/acpi_tad.c
+++ b/drivers/acpi/acpi_tad.c
@@ -49,6 +49,9 @@ MODULE_AUTHOR("Rafael J. Wysocki");
/* Special value for disabled timer or expired timer wake policy. */
#define ACPI_TAD_WAKE_DISABLED (~(u32)0)
+/* ACPI TAD RTC */
+#define ACPI_TAD_TZ_UNSPEC 2047
+
struct acpi_tad_driver_data {
u32 capabilities;
};
@@ -67,6 +70,16 @@ struct acpi_tad_rt {
u8 padding[3]; /* must be 0 */
} __packed;
+static bool acpi_tad_rt_is_invalid(struct acpi_tad_rt *rt)
+{
+ return rt->year < 1900 || rt->year > 9999 ||
+ rt->month < 1 || rt->month > 12 ||
+ rt->hour > 23 || rt->minute > 59 || rt->second > 59 ||
+ rt->tz < -1440 ||
+ (rt->tz > 1440 && rt->tz != ACPI_TAD_TZ_UNSPEC) ||
+ rt->daylight > 3;
+}
+
static int acpi_tad_set_real_time(struct device *dev, struct acpi_tad_rt *rt)
{
acpi_handle handle = ACPI_HANDLE(dev);
@@ -80,12 +93,8 @@ static int acpi_tad_set_real_time(struct
unsigned long long retval;
acpi_status status;
- if (rt->year < 1900 || rt->year > 9999 ||
- rt->month < 1 || rt->month > 12 ||
- rt->hour > 23 || rt->minute > 59 || rt->second > 59 ||
- rt->tz < -1440 || (rt->tz > 1440 && rt->tz != 2047) ||
- rt->daylight > 3)
- return -ERANGE;
+ if (acpi_tad_rt_is_invalid(rt))
+ return -EINVAL;
args[0].buffer.pointer = (u8 *)rt;
args[0].buffer.length = sizeof(*rt);
@@ -145,6 +154,9 @@ static int acpi_tad_get_real_time(struct
if (ret)
return ret;
+ if (acpi_tad_rt_is_invalid(rt))
+ return -ENODATA;
+
return 0;
}
^ permalink raw reply
* [PATCH v1 3/7] ACPI: TAD: Use __free() for cleanup in time_store()
From: Rafael J. Wysocki @ 2026-03-04 18:14 UTC (permalink / raw)
To: Linux ACPI; +Cc: Alexandre Belloni, LKML, linux-rtc, Linux PM
In-Reply-To: <5092662.31r3eYUQgx@rafael.j.wysocki>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Use __free() for the automatic freeing of memory pointed to by local
variable str in time_store() which allows the code to become somewhat
easier to follow.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/acpi_tad.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
--- a/drivers/acpi/acpi_tad.c
+++ b/drivers/acpi/acpi_tad.c
@@ -167,57 +167,57 @@ static ssize_t time_store(struct device
const char *buf, size_t count)
{
struct acpi_tad_rt rt;
- char *str, *s;
- int val, ret = -ENODATA;
+ int val, ret;
+ char *s;
- str = kmemdup_nul(buf, count, GFP_KERNEL);
+ char *str __free(kfree) = kmemdup_nul(buf, count, GFP_KERNEL);
if (!str)
return -ENOMEM;
s = acpi_tad_rt_next_field(str, &val);
if (!s)
- goto out_free;
+ return -ENODATA;
rt.year = val;
s = acpi_tad_rt_next_field(s, &val);
if (!s)
- goto out_free;
+ return -ENODATA;
rt.month = val;
s = acpi_tad_rt_next_field(s, &val);
if (!s)
- goto out_free;
+ return -ENODATA;
rt.day = val;
s = acpi_tad_rt_next_field(s, &val);
if (!s)
- goto out_free;
+ return -ENODATA;
rt.hour = val;
s = acpi_tad_rt_next_field(s, &val);
if (!s)
- goto out_free;
+ return -ENODATA;
rt.minute = val;
s = acpi_tad_rt_next_field(s, &val);
if (!s)
- goto out_free;
+ return -ENODATA;
rt.second = val;
s = acpi_tad_rt_next_field(s, &val);
if (!s)
- goto out_free;
+ return -ENODATA;
rt.tz = val;
if (kstrtoint(s, 10, &val))
- goto out_free;
+ return -ENODATA;
rt.daylight = val;
@@ -226,10 +226,10 @@ static ssize_t time_store(struct device
memset(rt.padding, 0, 3);
ret = acpi_tad_set_real_time(dev, &rt);
+ if (ret)
+ return ret;
-out_free:
- kfree(str);
- return ret ? ret : count;
+ return count;
}
static ssize_t time_show(struct device *dev, struct device_attribute *attr,
^ permalink raw reply
* [PATCH v1 2/7] ACPI: TAD: Support RTC without wakeup
From: Rafael J. Wysocki @ 2026-03-04 18:13 UTC (permalink / raw)
To: Linux ACPI; +Cc: Alexandre Belloni, LKML, linux-rtc, Linux PM
In-Reply-To: <5092662.31r3eYUQgx@rafael.j.wysocki>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
The ACPI TAD can provide a functional RTC without wakeup capabilities,
so stop failing probe if AC wakeup is not supported.
Also, if _PRW is missing, do not fail probe, but clear the wakeup bits
in capabilities.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/acpi_tad.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
--- a/drivers/acpi/acpi_tad.c
+++ b/drivers/acpi/acpi_tad.c
@@ -546,8 +546,9 @@ static umode_t acpi_tad_attr_is_visible(
if (a == &dev_attr_caps.attr)
return a->mode;
- if (a == &dev_attr_ac_alarm.attr || a == &dev_attr_ac_policy.attr ||
- a == &dev_attr_ac_status.attr)
+ if ((dd->capabilities & ACPI_TAD_AC_WAKE) &&
+ (a == &dev_attr_ac_alarm.attr || a == &dev_attr_ac_policy.attr ||
+ a == &dev_attr_ac_status.attr))
return a->mode;
if ((dd->capabilities & ACPI_TAD_DC_WAKE) &&
@@ -581,8 +582,10 @@ static void acpi_tad_remove(struct platf
sysfs_remove_group(&dev->kobj, &acpi_tad_attr_group);
scoped_guard(pm_runtime_noresume, dev) {
- acpi_tad_disable_timer(dev, ACPI_TAD_AC_TIMER);
- acpi_tad_clear_status(dev, ACPI_TAD_AC_TIMER);
+ if (dd->capabilities & ACPI_TAD_AC_WAKE) {
+ acpi_tad_disable_timer(dev, ACPI_TAD_AC_TIMER);
+ acpi_tad_clear_status(dev, ACPI_TAD_AC_TIMER);
+ }
if (dd->capabilities & ACPI_TAD_DC_WAKE) {
acpi_tad_disable_timer(dev, ACPI_TAD_DC_TIMER);
acpi_tad_clear_status(dev, ACPI_TAD_DC_TIMER);
@@ -612,14 +615,9 @@ static int acpi_tad_probe(struct platfor
return -ENODEV;
}
- if (!(caps & ACPI_TAD_AC_WAKE)) {
- dev_info(dev, "Unsupported capabilities\n");
- return -ENODEV;
- }
-
if (!acpi_has_method(handle, "_PRW")) {
dev_info(dev, "Missing _PRW\n");
- return -ENODEV;
+ caps &= ~(ACPI_TAD_AC_WAKE | ACPI_TAD_DC_WAKE);
}
dd = devm_kzalloc(dev, sizeof(*dd), GFP_KERNEL);
@@ -635,9 +633,11 @@ static int acpi_tad_probe(struct platfor
* runtime suspend. Everything else should be taken care of by the ACPI
* PM domain callbacks.
*/
- device_init_wakeup(dev, true);
- dev_pm_set_driver_flags(dev, DPM_FLAG_SMART_SUSPEND |
- DPM_FLAG_MAY_SKIP_RESUME);
+ if (ACPI_TAD_AC_WAKE | ACPI_TAD_DC_WAKE) {
+ device_init_wakeup(dev, true);
+ dev_pm_set_driver_flags(dev, DPM_FLAG_SMART_SUSPEND |
+ DPM_FLAG_MAY_SKIP_RESUME);
+ }
/*
* The platform bus type layer tells the ACPI PM domain powers up the
^ permalink raw reply
* [PATCH v1 1/7] ACPI: TAD: Create one attribute group
From: Rafael J. Wysocki @ 2026-03-04 18:12 UTC (permalink / raw)
To: Linux ACPI; +Cc: Alexandre Belloni, LKML, linux-rtc, Linux PM
In-Reply-To: <5092662.31r3eYUQgx@rafael.j.wysocki>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Instead of creating three attribute groups, one for each supported
subset of capabilities, create just one and use an .is_visible()
callback in it to decide which attributes to use.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/acpi_tad.c | 80 +++++++++++++++++++++---------------------------
1 file changed, 35 insertions(+), 45 deletions(-)
--- a/drivers/acpi/acpi_tad.c
+++ b/drivers/acpi/acpi_tad.c
@@ -249,14 +249,6 @@ static ssize_t time_show(struct device *
static DEVICE_ATTR_RW(time);
-static struct attribute *acpi_tad_time_attrs[] = {
- &dev_attr_time.attr,
- NULL,
-};
-static const struct attribute_group acpi_tad_time_attr_group = {
- .attrs = acpi_tad_time_attrs,
-};
-
static int acpi_tad_wake_set(struct device *dev, char *method, u32 timer_id,
u32 value)
{
@@ -486,17 +478,6 @@ static ssize_t ac_status_show(struct dev
static DEVICE_ATTR_RW(ac_status);
-static struct attribute *acpi_tad_attrs[] = {
- &dev_attr_caps.attr,
- &dev_attr_ac_alarm.attr,
- &dev_attr_ac_policy.attr,
- &dev_attr_ac_status.attr,
- NULL,
-};
-static const struct attribute_group acpi_tad_attr_group = {
- .attrs = acpi_tad_attrs,
-};
-
static ssize_t dc_alarm_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
@@ -545,14 +526,44 @@ static ssize_t dc_status_show(struct dev
static DEVICE_ATTR_RW(dc_status);
-static struct attribute *acpi_tad_dc_attrs[] = {
+static struct attribute *acpi_tad_attrs[] = {
+ &dev_attr_caps.attr,
+ &dev_attr_ac_alarm.attr,
+ &dev_attr_ac_policy.attr,
+ &dev_attr_ac_status.attr,
&dev_attr_dc_alarm.attr,
&dev_attr_dc_policy.attr,
&dev_attr_dc_status.attr,
+ &dev_attr_time.attr,
NULL,
};
-static const struct attribute_group acpi_tad_dc_attr_group = {
- .attrs = acpi_tad_dc_attrs,
+
+static umode_t acpi_tad_attr_is_visible(struct kobject *kobj,
+ struct attribute *a, int n)
+{
+ struct acpi_tad_driver_data *dd = dev_get_drvdata(kobj_to_dev(kobj));
+
+ if (a == &dev_attr_caps.attr)
+ return a->mode;
+
+ if (a == &dev_attr_ac_alarm.attr || a == &dev_attr_ac_policy.attr ||
+ a == &dev_attr_ac_status.attr)
+ return a->mode;
+
+ if ((dd->capabilities & ACPI_TAD_DC_WAKE) &&
+ (a == &dev_attr_dc_alarm.attr || a == &dev_attr_dc_policy.attr ||
+ a == &dev_attr_dc_status.attr))
+ return a->mode;
+
+ if ((dd->capabilities & ACPI_TAD_RT) && a == &dev_attr_time.attr)
+ return a->mode;
+
+ return 0;
+}
+
+static const struct attribute_group acpi_tad_attr_group = {
+ .attrs = acpi_tad_attrs,
+ .is_visible = acpi_tad_attr_is_visible,
};
static int acpi_tad_disable_timer(struct device *dev, u32 timer_id)
@@ -567,12 +578,6 @@ static void acpi_tad_remove(struct platf
device_init_wakeup(dev, false);
- if (dd->capabilities & ACPI_TAD_RT)
- sysfs_remove_group(&dev->kobj, &acpi_tad_time_attr_group);
-
- if (dd->capabilities & ACPI_TAD_DC_WAKE)
- sysfs_remove_group(&dev->kobj, &acpi_tad_dc_attr_group);
-
sysfs_remove_group(&dev->kobj, &acpi_tad_attr_group);
scoped_guard(pm_runtime_noresume, dev) {
@@ -633,6 +638,7 @@ static int acpi_tad_probe(struct platfor
device_init_wakeup(dev, true);
dev_pm_set_driver_flags(dev, DPM_FLAG_SMART_SUSPEND |
DPM_FLAG_MAY_SKIP_RESUME);
+
/*
* The platform bus type layer tells the ACPI PM domain powers up the
* device, so set the runtime PM status of it to "active".
@@ -643,24 +649,8 @@ static int acpi_tad_probe(struct platfor
ret = sysfs_create_group(&dev->kobj, &acpi_tad_attr_group);
if (ret)
- goto fail;
-
- if (caps & ACPI_TAD_DC_WAKE) {
- ret = sysfs_create_group(&dev->kobj, &acpi_tad_dc_attr_group);
- if (ret)
- goto fail;
- }
-
- if (caps & ACPI_TAD_RT) {
- ret = sysfs_create_group(&dev->kobj, &acpi_tad_time_attr_group);
- if (ret)
- goto fail;
- }
-
- return 0;
+ acpi_tad_remove(pdev);
-fail:
- acpi_tad_remove(pdev);
return ret;
}
^ permalink raw reply
* [PATCH v1 0/7] ACPI: TAD: Assorted improvements and RTC class device interface
From: Rafael J. Wysocki @ 2026-03-04 18:11 UTC (permalink / raw)
To: Linux ACPI; +Cc: Alexandre Belloni, LKML, linux-rtc, Linux PM
Hi All,
This is a proper v1 of the series posted previously as a prototype:
https://lore.kernel.org/linux-acpi/4727679.LvFx2qVVIh@rafael.j.wysocki/
The code has changed somewhat, most importantly the first patch has been
split and review feedback on patch [6/7] (previously [5/6]) have been
taken into account.
This series is on top of linux-next.
Thanks!
^ permalink raw reply
* [PATCH] rtc: armada38x: zalloc + calloc to single allocation
From: Rosen Penev @ 2026-03-04 22:53 UTC (permalink / raw)
To: linux-rtc
Cc: Andrew Lunn, Gregory Clement, Sebastian Hesselbarth,
Alexandre Belloni,
moderated list:ARM/Marvell Kirkwood and Armada 370, 375, 38x,...,
open list
Use a flexible array member to simplify allocation.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/rtc/rtc-armada38x.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/rtc/rtc-armada38x.c b/drivers/rtc/rtc-armada38x.c
index 713fa0d077cd..245290ae1a8d 100644
--- a/drivers/rtc/rtc-armada38x.c
+++ b/drivers/rtc/rtc-armada38x.c
@@ -72,8 +72,8 @@ struct armada38x_rtc {
spinlock_t lock;
int irq;
bool initialized;
- struct value_to_freq *val_to_freq;
const struct armada38x_rtc_data *data;
+ struct value_to_freq val_to_freq[];
};
#define ALARM1 0
@@ -490,18 +490,13 @@ static __init int armada38x_rtc_probe(struct platform_device *pdev)
{
struct armada38x_rtc *rtc;
- rtc = devm_kzalloc(&pdev->dev, sizeof(struct armada38x_rtc),
+ rtc = devm_kzalloc(&pdev->dev, struct_size(rtc, val_to_freq, SAMPLE_NR),
GFP_KERNEL);
if (!rtc)
return -ENOMEM;
rtc->data = of_device_get_match_data(&pdev->dev);
- rtc->val_to_freq = devm_kcalloc(&pdev->dev, SAMPLE_NR,
- sizeof(struct value_to_freq), GFP_KERNEL);
- if (!rtc->val_to_freq)
- return -ENOMEM;
-
spin_lock_init(&rtc->lock);
rtc->regs = devm_platform_ioremap_resource_byname(pdev, "rtc");
--
2.53.0
^ permalink raw reply related
* Re: [PATCH v1 6/7] ACPI: TAD: Add RTC class device interface
From: Alexandre Belloni @ 2026-03-05 7:48 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: Linux ACPI, LKML, linux-rtc, Linux PM
In-Reply-To: <2352027.iZASKD2KPV@rafael.j.wysocki>
On 04/03/2026 19:16:01+0100, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Add an RTC class device interface allowing to read and set the real time
> value to the ACPI TAD driver.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> ---
> drivers/acpi/acpi_tad.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 76 insertions(+), 2 deletions(-)
>
> --- a/drivers/acpi/acpi_tad.c
> +++ b/drivers/acpi/acpi_tad.c
> @@ -25,6 +25,7 @@
> #include <linux/module.h>
> #include <linux/platform_device.h>
> #include <linux/pm_runtime.h>
> +#include <linux/rtc.h>
> #include <linux/suspend.h>
>
> MODULE_DESCRIPTION("ACPI Time and Alarm (TAD) Device Driver");
> @@ -51,6 +52,7 @@ MODULE_AUTHOR("Rafael J. Wysocki");
>
> /* ACPI TAD RTC */
> #define ACPI_TAD_TZ_UNSPEC 2047
> +#define ACPI_TAD_TIME_ISDST 3
>
> struct acpi_tad_driver_data {
> u32 capabilities;
> @@ -164,6 +166,8 @@ static int acpi_tad_get_real_time(struct
> return 0;
> }
>
> +/* sysfs interface */
> +
> static char *acpi_tad_rt_next_field(char *s, int *val)
> {
> char *p;
> @@ -579,6 +583,71 @@ static const struct attribute_group acpi
> .is_visible = acpi_tad_attr_is_visible,
> };
>
> +#ifdef CONFIG_RTC_CLASS
> +/* RTC class device interface */
> +
> +static int acpi_tad_rtc_set_time(struct device *dev, struct rtc_time *tm)
> +{
> + struct acpi_tad_rt rt;
> +
> + rt.year = tm->tm_year + 1900;
> + rt.month = tm->tm_mon + 1;
> + rt.day = tm->tm_mday;
> + rt.hour = tm->tm_hour;
> + rt.minute = tm->tm_min;
> + rt.second = tm->tm_sec;
> + rt.tz = ACPI_TAD_TZ_UNSPEC;
> + rt.daylight = ACPI_TAD_TIME_ISDST * !!tm->tm_isdst;
> +
> + return acpi_tad_set_real_time(dev, &rt);
> +}
> +
> +static int acpi_tad_rtc_read_time(struct device *dev, struct rtc_time *tm)
> +{
> + struct acpi_tad_rt rt;
> + int ret;
> +
> + ret = acpi_tad_get_real_time(dev, &rt);
> + if (ret)
> + return ret;
> +
> + tm->tm_year = rt.year - 1900;
> + tm->tm_mon = rt.month - 1;
> + tm->tm_mday = rt.day;
> + tm->tm_hour = rt.hour;
> + tm->tm_min = rt.minute;
> + tm->tm_sec = rt.second;
> + tm->tm_isdst = rt.daylight == ACPI_TAD_TIME_ISDST;
> +
> + return 0;
> +}
> +
> +static const struct rtc_class_ops acpi_tad_rtc_ops = {
> + .read_time = acpi_tad_rtc_read_time,
> + .set_time = acpi_tad_rtc_set_time,
> +};
> +
> +static void acpi_tad_register_rtc(struct device *dev)
> +{
> + struct rtc_device *rtc;
> +
> + rtc = devm_rtc_allocate_device(dev);
> + if (IS_ERR(rtc))
> + return;
> +
> + rtc->range_min = mktime64(1900, 1, 1, 0, 0, 0);
> + rtc->range_max = mktime64(9999, 12, 31, 23, 59, 59);
> +
> + rtc->ops = &acpi_tad_rtc_ops;
> +
> + devm_rtc_register_device(rtc);
> +}
> +#else /* !CONFIG_RTC_CLASS */
> +static inline void acpi_tad_register_rtc(struct device *dev) {}
> +#endif /* !CONFIG_RTC_CLASS */
> +
> +/* Platform driver interface */
> +
> static int acpi_tad_disable_timer(struct device *dev, u32 timer_id)
> {
> return acpi_tad_wake_set(dev, "_STV", timer_id, ACPI_TAD_WAKE_DISABLED);
> @@ -660,10 +729,15 @@ static int acpi_tad_probe(struct platfor
> pm_runtime_suspend(dev);
>
> ret = sysfs_create_group(&dev->kobj, &acpi_tad_attr_group);
> - if (ret)
> + if (ret) {
> acpi_tad_remove(pdev);
> + return ret;
> + }
>
> - return ret;
> + if (caps & ACPI_TAD_RT)
> + acpi_tad_register_rtc(dev);
> +
> + return 0;
> }
>
> static const struct acpi_device_id acpi_tad_ids[] = {
>
>
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply
* Re: [PATCH] rtc: armada38x: zalloc + calloc to single allocation
From: Gregory CLEMENT @ 2026-03-05 8:41 UTC (permalink / raw)
To: Rosen Penev, linux-rtc
Cc: Andrew Lunn, Sebastian Hesselbarth, Alexandre Belloni,
moderated list:ARM/Marvell Kirkwood and Armada 370, 375, 38x,...,
open list
In-Reply-To: <20260304225329.24510-1-rosenp@gmail.com>
Rosen Penev <rosenp@gmail.com> writes:
> Use a flexible array member to simplify allocation.
>
I must admit that I didn't know struct_size(), it is a nice helper!
Reviewed-by: Gregory CLEMENT <gregory.clement@bootlin.com>
Thanks,
Gregory
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
> drivers/rtc/rtc-armada38x.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/rtc/rtc-armada38x.c b/drivers/rtc/rtc-armada38x.c
> index 713fa0d077cd..245290ae1a8d 100644
> --- a/drivers/rtc/rtc-armada38x.c
> +++ b/drivers/rtc/rtc-armada38x.c
> @@ -72,8 +72,8 @@ struct armada38x_rtc {
> spinlock_t lock;
> int irq;
> bool initialized;
> - struct value_to_freq *val_to_freq;
> const struct armada38x_rtc_data *data;
> + struct value_to_freq val_to_freq[];
> };
>
> #define ALARM1 0
> @@ -490,18 +490,13 @@ static __init int armada38x_rtc_probe(struct platform_device *pdev)
> {
> struct armada38x_rtc *rtc;
>
> - rtc = devm_kzalloc(&pdev->dev, sizeof(struct armada38x_rtc),
> + rtc = devm_kzalloc(&pdev->dev, struct_size(rtc, val_to_freq, SAMPLE_NR),
> GFP_KERNEL);
> if (!rtc)
> return -ENOMEM;
>
> rtc->data = of_device_get_match_data(&pdev->dev);
>
> - rtc->val_to_freq = devm_kcalloc(&pdev->dev, SAMPLE_NR,
> - sizeof(struct value_to_freq), GFP_KERNEL);
> - if (!rtc->val_to_freq)
> - return -ENOMEM;
> -
> spin_lock_init(&rtc->lock);
>
> rtc->regs = devm_platform_ioremap_resource_byname(pdev, "rtc");
> --
> 2.53.0
>
--
Grégory CLEMENT, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply
* Re: [PATCH] rtc: armada38x: zalloc + calloc to single allocation
From: Rosen Penev @ 2026-03-05 8:51 UTC (permalink / raw)
To: Gregory CLEMENT
Cc: linux-rtc, Andrew Lunn, Sebastian Hesselbarth, Alexandre Belloni,
moderated list:ARM/Marvell Kirkwood and Armada 370, 375, 38x,...,
open list
In-Reply-To: <871phyfz34.fsf@BLaptop.bootlin.com>
On Thu, Mar 5, 2026 at 12:41 AM Gregory CLEMENT
<gregory.clement@bootlin.com> wrote:
>
> Rosen Penev <rosenp@gmail.com> writes:
>
> > Use a flexible array member to simplify allocation.
> >
>
> I must admit that I didn't know struct_size(), it is a nice helper!
There's kzalloc_flex that's even nicer. Has no devm version yet.
>
> Reviewed-by: Gregory CLEMENT <gregory.clement@bootlin.com>
>
> Thanks,
>
> Gregory
> > Signed-off-by: Rosen Penev <rosenp@gmail.com>
> > ---
> > drivers/rtc/rtc-armada38x.c | 9 ++-------
> > 1 file changed, 2 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/rtc/rtc-armada38x.c b/drivers/rtc/rtc-armada38x.c
> > index 713fa0d077cd..245290ae1a8d 100644
> > --- a/drivers/rtc/rtc-armada38x.c
> > +++ b/drivers/rtc/rtc-armada38x.c
> > @@ -72,8 +72,8 @@ struct armada38x_rtc {
> > spinlock_t lock;
> > int irq;
> > bool initialized;
> > - struct value_to_freq *val_to_freq;
> > const struct armada38x_rtc_data *data;
> > + struct value_to_freq val_to_freq[];
> > };
> >
> > #define ALARM1 0
> > @@ -490,18 +490,13 @@ static __init int armada38x_rtc_probe(struct platform_device *pdev)
> > {
> > struct armada38x_rtc *rtc;
> >
> > - rtc = devm_kzalloc(&pdev->dev, sizeof(struct armada38x_rtc),
> > + rtc = devm_kzalloc(&pdev->dev, struct_size(rtc, val_to_freq, SAMPLE_NR),
> > GFP_KERNEL);
> > if (!rtc)
> > return -ENOMEM;
> >
> > rtc->data = of_device_get_match_data(&pdev->dev);
> >
> > - rtc->val_to_freq = devm_kcalloc(&pdev->dev, SAMPLE_NR,
> > - sizeof(struct value_to_freq), GFP_KERNEL);
> > - if (!rtc->val_to_freq)
> > - return -ENOMEM;
> > -
> > spin_lock_init(&rtc->lock);
> >
> > rtc->regs = devm_platform_ioremap_resource_byname(pdev, "rtc");
> > --
> > 2.53.0
> >
>
> --
> Grégory CLEMENT, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
^ permalink raw reply
* [QUESTION] rtc: zynqmp: CALIB_RD reset behavior differs between ZynqMP and Versal
From: Takumi Ando @ 2026-03-05 9:24 UTC (permalink / raw)
To: linux-rtc; +Cc: alexandre.belloni, michal.simek, Yasushi SHOJI, kanta tamura
Hi,
I have a question about the initialization logic in the zynqmp RTC
driver(drivers/rtc/rtc-zynqmp.c).
Currently the driver programs CALIB_WRITE only when CALIB_READ returns 0:
ret = readl(... + RTC_CALIB_RD);
if (!ret)
writel(freq, ... + RTC_CALIB_WR);
My understanding is that this was designed to avoid overwriting an
existing calibration value. Since the RTC may continue running from the
battery domain even when Linux is not running, the calibration value may
have been configured previously and should be preserved.
However, according to the Versal Adaptive SoC Register Reference (AM012) [1],
the value returned by CALIB_RD after reset can be undefined.
In practice, on Versal hardware we observe non-zero values even before
any calibration has been programmed. Because of this, the current logic
may skip programming CALIB_WR and leave the Max_Tick field uninitialized.
On Zynq UltraScale+ Devices Register Reference (UG1087) [2],
CALIB_RD resets to 0, so the current logic works correctly there.
However, this assumption does not appear to hold for Versal.
If there is a register or mechanism that indicates whether the RTC has
already been calibrated, the driver could use that instead. However,
I could not find such an indicator in the documentation.
Am I missing something here? Is there a recommended way to detect whether
RTC calibration has already been configured?
Alternatively, would it be acceptable for the driver to always program
Max_Tick while preserving the fractional calibration bits already stored
in hardware?
Best regards,
[1] https://docs.amd.com/r/en-US/am012-versal-register-reference/CALIB_READ-PMC_RTC-Register
[2] https://docs.amd.com/r/en-US/ug1087-zynq-ultrascale-registers/CALIB_READ-RTC-Register
--
Takumi Ando
Space Cubics Inc.
^ permalink raw reply
* [PATCH v2 1/6] rtc: abx80x: Remove use of i2c_match_id()
From: Andrew Davis @ 2026-03-05 19:35 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel, Andrew Davis
In-Reply-To: <20260305193545.796294-1-afd@ti.com>
The function i2c_match_id() is used to fetch the matching ID from
the i2c_device_id table. This is often used to then retrieve the
matching driver_data. This can be done in one step with the helper
i2c_get_match_data().
This helper has a couple other benefits:
* It doesn't need the i2c_device_id passed in so we do not need
to have that forward declared, allowing us to remove those or
move the i2c_device_id table down to its more natural spot
with the other module info.
* It also checks for device match data, which allows for OF and
ACPI based probing. That means we do not have to manually check
those first and can remove those checks.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/rtc/rtc-abx80x.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c
index 3fee27914ba80..eca09872ea971 100644
--- a/drivers/rtc/rtc-abx80x.c
+++ b/drivers/rtc/rtc-abx80x.c
@@ -772,8 +772,7 @@ static int abx80x_probe(struct i2c_client *client)
struct abx80x_priv *priv;
int i, data, err, trickle_cfg = -EINVAL;
char buf[7];
- const struct i2c_device_id *id = i2c_match_id(abx80x_id, client);
- unsigned int part = id->driver_data;
+ unsigned int part = (uintptr_t)i2c_get_match_data(client);
unsigned int partnumber;
unsigned int majrev, minrev;
unsigned int lot;
--
2.39.2
^ permalink raw reply related
* [PATCH v2 2/6] rtc: m41t80: Remove use of i2c_match_id()
From: Andrew Davis @ 2026-03-05 19:35 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel, Andrew Davis
In-Reply-To: <20260305193545.796294-1-afd@ti.com>
The function i2c_match_id() is used to fetch the matching ID from
the i2c_device_id table. This is often used to then retrieve the
matching driver_data. This can be done in one step with the helper
i2c_get_match_data().
This helper has a couple other benefits:
* It doesn't need the i2c_device_id passed in so we do not need
to have that forward declared, allowing us to remove those or
move the i2c_device_id table down to its more natural spot
with the other module info.
* It also checks for device match data, which allows for OF and
ACPI based probing. That means we do not have to manually check
those first and can remove those checks.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/rtc/rtc-m41t80.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 740cab013f590..b26afef37d9cf 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -924,13 +924,7 @@ static int m41t80_probe(struct i2c_client *client)
return -ENOMEM;
m41t80_data->client = client;
- if (client->dev.of_node) {
- m41t80_data->features = (unsigned long)
- of_device_get_match_data(&client->dev);
- } else {
- const struct i2c_device_id *id = i2c_match_id(m41t80_id, client);
- m41t80_data->features = id->driver_data;
- }
+ m41t80_data->features = (unsigned long)i2c_get_match_data(client);
i2c_set_clientdata(client, m41t80_data);
m41t80_data->rtc = devm_rtc_allocate_device(&client->dev);
--
2.39.2
^ permalink raw reply related
* [PATCH v2 0/6] Remove use of i2c_match_id in RTC
From: Andrew Davis @ 2026-03-05 19:35 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel, Andrew Davis
Hello all,
RTC subsystem is one of the last still using i2c_match_id().
This is a v2 but nothing is changed from last time. If I'm
not sending this to the right folks let me know.
Thanks,
Andrew
Andrew Davis (6):
rtc: abx80x: Remove use of i2c_match_id()
rtc: m41t80: Remove use of i2c_match_id()
rtc: pcf2127: Remove use of i2c_match_id()
rtc: rs5c372: Remove use of i2c_match_id()
rtc: rv8803: Remove use of i2c_match_id()
rtc: rx8025: Remove use of i2c_match_id()
drivers/rtc/rtc-abx80x.c | 3 +--
drivers/rtc/rtc-m41t80.c | 8 +-------
drivers/rtc/rtc-pcf2127.c | 23 +++++++----------------
drivers/rtc/rtc-rs5c372.c | 7 +------
drivers/rtc/rtc-rv8803.c | 8 +-------
drivers/rtc/rtc-rx8025.c | 4 +---
6 files changed, 12 insertions(+), 41 deletions(-)
--
2.39.2
^ permalink raw reply
* [PATCH v2 6/6] rtc: rx8025: Remove use of i2c_match_id()
From: Andrew Davis @ 2026-03-05 19:35 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel, Andrew Davis
In-Reply-To: <20260305193545.796294-1-afd@ti.com>
The function i2c_match_id() is used to fetch the matching ID from
the i2c_device_id table. This is often used to then retrieve the
matching driver_data. This can be done in one step with the helper
i2c_get_match_data().
This helper has a couple other benefits:
* It doesn't need the i2c_device_id passed in so we do not need
to have that forward declared, allowing us to remove those or
move the i2c_device_id table down to its more natural spot
with the other module info.
* It also checks for device match data, which allows for OF and
ACPI based probing. That means we do not have to manually check
those first and can remove those checks.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/rtc/rtc-rx8025.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/rtc/rtc-rx8025.c b/drivers/rtc/rtc-rx8025.c
index ced6e7adfe8d0..c57081f9e02b4 100644
--- a/drivers/rtc/rtc-rx8025.c
+++ b/drivers/rtc/rtc-rx8025.c
@@ -522,7 +522,6 @@ static const struct attribute_group rx8025_attr_group = {
static int rx8025_probe(struct i2c_client *client)
{
- const struct i2c_device_id *id = i2c_match_id(rx8025_id, client);
struct i2c_adapter *adapter = client->adapter;
struct rx8025_data *rx8025;
int err = 0;
@@ -540,8 +539,7 @@ static int rx8025_probe(struct i2c_client *client)
i2c_set_clientdata(client, rx8025);
- if (id)
- rx8025->model = id->driver_data;
+ rx8025->model = (uintptr_t)i2c_get_match_data(client);
err = rx8025_init_client(client);
if (err)
--
2.39.2
^ permalink raw reply related
* [PATCH v2 5/6] rtc: rv8803: Remove use of i2c_match_id()
From: Andrew Davis @ 2026-03-05 19:35 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel, Andrew Davis
In-Reply-To: <20260305193545.796294-1-afd@ti.com>
The function i2c_match_id() is used to fetch the matching ID from
the i2c_device_id table. This is often used to then retrieve the
matching driver_data. This can be done in one step with the helper
i2c_get_match_data().
This helper has a couple other benefits:
* It doesn't need the i2c_device_id passed in so we do not need
to have that forward declared, allowing us to remove those or
move the i2c_device_id table down to its more natural spot
with the other module info.
* It also checks for device match data, which allows for OF and
ACPI based probing. That means we do not have to manually check
those first and can remove those checks.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/rtc/rtc-rv8803.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/rtc/rtc-rv8803.c b/drivers/rtc/rtc-rv8803.c
index 4e9e04cbec89a..2bf988a89fd7b 100644
--- a/drivers/rtc/rtc-rv8803.c
+++ b/drivers/rtc/rtc-rv8803.c
@@ -667,13 +667,7 @@ static int rv8803_probe(struct i2c_client *client)
mutex_init(&rv8803->flags_lock);
rv8803->client = client;
- if (client->dev.of_node) {
- rv8803->type = (uintptr_t)of_device_get_match_data(&client->dev);
- } else {
- const struct i2c_device_id *id = i2c_match_id(rv8803_id, client);
-
- rv8803->type = id->driver_data;
- }
+ rv8803->type = (uintptr_t)i2c_get_match_data(client);
i2c_set_clientdata(client, rv8803);
flags = rv8803_read_reg(client, RV8803_FLAG);
--
2.39.2
^ permalink raw reply related
* [PATCH v2 3/6] rtc: pcf2127: Remove use of i2c_match_id()
From: Andrew Davis @ 2026-03-05 19:35 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel, Andrew Davis
In-Reply-To: <20260305193545.796294-1-afd@ti.com>
The function i2c_match_id() is used to fetch the matching ID from
the i2c_device_id table. This is often used to then retrieve the
matching driver_data. This can be done in one step with the helper
i2c_get_match_data().
This helper has a couple other benefits:
* It doesn't need the i2c_device_id passed in so we do not need
to have that forward declared, allowing us to remove those or
move the i2c_device_id table down to its more natural spot
with the other module info.
* It also checks for device match data, which allows for OF and
ACPI based probing. That means we do not have to manually check
those first and can remove those checks.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/rtc/rtc-pcf2127.c | 23 +++++++----------------
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
index bb4fe81d3d62c..e4785c5a55d03 100644
--- a/drivers/rtc/rtc-pcf2127.c
+++ b/drivers/rtc/rtc-pcf2127.c
@@ -1449,10 +1449,10 @@ static const struct regmap_bus pcf2127_i2c_regmap = {
static struct i2c_driver pcf2127_i2c_driver;
static const struct i2c_device_id pcf2127_i2c_id[] = {
- { "pcf2127", PCF2127 },
- { "pcf2129", PCF2129 },
- { "pca2129", PCF2129 },
- { "pcf2131", PCF2131 },
+ { "pcf2127", (kernel_ulong_t)&pcf21xx_cfg[PCF2127] },
+ { "pcf2129", (kernel_ulong_t)&pcf21xx_cfg[PCF2129] },
+ { "pca2129", (kernel_ulong_t)&pcf21xx_cfg[PCF2129] },
+ { "pcf2131", (kernel_ulong_t)&pcf21xx_cfg[PCF2131] },
{ }
};
MODULE_DEVICE_TABLE(i2c, pcf2127_i2c_id);
@@ -1469,18 +1469,9 @@ static int pcf2127_i2c_probe(struct i2c_client *client)
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
return -ENODEV;
- if (client->dev.of_node) {
- variant = of_device_get_match_data(&client->dev);
- if (!variant)
- return -ENODEV;
- } else {
- enum pcf21xx_type type =
- i2c_match_id(pcf2127_i2c_id, client)->driver_data;
-
- if (type >= PCF21XX_LAST_ID)
- return -ENODEV;
- variant = &pcf21xx_cfg[type];
- }
+ variant = i2c_get_match_data(client);
+ if (!variant)
+ return -ENODEV;
config.max_register = variant->max_register,
--
2.39.2
^ permalink raw reply related
* [PATCH v2 4/6] rtc: rs5c372: Remove use of i2c_match_id()
From: Andrew Davis @ 2026-03-05 19:35 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel, Andrew Davis
In-Reply-To: <20260305193545.796294-1-afd@ti.com>
The function i2c_match_id() is used to fetch the matching ID from
the i2c_device_id table. This is often used to then retrieve the
matching driver_data. This can be done in one step with the helper
i2c_get_match_data().
This helper has a couple other benefits:
* It doesn't need the i2c_device_id passed in so we do not need
to have that forward declared, allowing us to remove those or
move the i2c_device_id table down to its more natural spot
with the other module info.
* It also checks for device match data, which allows for OF and
ACPI based probing. That means we do not have to manually check
those first and can remove those checks.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/rtc/rtc-rs5c372.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c
index f8fab0205f8cc..936f4f05c8c7a 100644
--- a/drivers/rtc/rtc-rs5c372.c
+++ b/drivers/rtc/rtc-rs5c372.c
@@ -825,12 +825,7 @@ static int rs5c372_probe(struct i2c_client *client)
rs5c372->client = client;
i2c_set_clientdata(client, rs5c372);
- if (client->dev.of_node) {
- rs5c372->type = (uintptr_t)of_device_get_match_data(&client->dev);
- } else {
- const struct i2c_device_id *id = i2c_match_id(rs5c372_id, client);
- rs5c372->type = id->driver_data;
- }
+ rs5c372->type = (uintptr_t)i2c_get_match_data(client);
/* we read registers 0x0f then 0x00-0x0f; skip the first one */
rs5c372->regs = &rs5c372->buf[1];
--
2.39.2
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox