linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: allow rtc_read_alarm without read_alarm callback
@ 2023-02-14 22:27 alexandre.belloni
  2023-02-15 15:00 ` Philippe Schenker
  0 siblings, 1 reply; 2+ messages in thread
From: alexandre.belloni @ 2023-02-14 22:27 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni
  Cc: Zhipeng Wang, Marcel Ziswiler, linux-rtc, linux-kernel

From: Alexandre Belloni <alexandre.belloni@bootlin.com>

.read_alarm is not necessary to read the current alarm because it is
recorded in the aie_timer and so rtc_read_alarm() will never call
rtc_read_alarm_internal() which is the only function calling the callback.

Reported-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
Reported-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Fixes: 7ae41220ef58 ("rtc: introduce features bitfield")
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 7c30cb3c764d..499d89150afc 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -392,7 +392,7 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
 		return err;
 	if (!rtc->ops) {
 		err = -ENODEV;
-	} else if (!test_bit(RTC_FEATURE_ALARM, rtc->features) || !rtc->ops->read_alarm) {
+	} else if (!test_bit(RTC_FEATURE_ALARM, rtc->features)) {
 		err = -EINVAL;
 	} else {
 		memset(alarm, 0, sizeof(struct rtc_wkalrm));
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] rtc: allow rtc_read_alarm without read_alarm callback
  2023-02-14 22:27 [PATCH] rtc: allow rtc_read_alarm without read_alarm callback alexandre.belloni
@ 2023-02-15 15:00 ` Philippe Schenker
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Schenker @ 2023-02-15 15:00 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni
  Cc: Marcel Ziswiler, zhipeng.wang_1, linux-rtc, linux-kernel,
	Francesco Dolcini

On Tue, 2023-02-14 at 23:27 +0100, alexandre.belloni@bootlin.com wrote:
> From: Alexandre Belloni <alexandre.belloni@bootlin.com>
> 
> .read_alarm is not necessary to read the current alarm because it is
> recorded in the aie_timer and so rtc_read_alarm() will never call
> rtc_read_alarm_internal() which is the only function calling the
> callback.
> 
> Reported-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
> Reported-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
> Fixes: 7ae41220ef58 ("rtc: introduce features bitfield")
> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Tested-by: Philippe Schenker <philippe.schenker@toradex.com>

I tested on our SoMs Colibri iMX8X and Apalis iMX8

I used the variants that had i.MX 8QXP and i.MX 8QM placed. This patch
did solve the problem we currently have. I also wanted to mention that I
could not get them to run on a mainline kernel in a acceptable time-
frame so I tested on Toradex's kernel that is based on NXP's Kernel. [1]

[1]
https://git.toradex.com/cgit/linux-toradex.git/log/?h=toradex_5.15-2.1.x-imx

> ---
>  drivers/rtc/interface.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
> index 7c30cb3c764d..499d89150afc 100644
> --- a/drivers/rtc/interface.c
> +++ b/drivers/rtc/interface.c
> @@ -392,7 +392,7 @@ int rtc_read_alarm(struct rtc_device *rtc, struct
> rtc_wkalrm *alarm)
>                 return err;
>         if (!rtc->ops) {
>                 err = -ENODEV;
> -       } else if (!test_bit(RTC_FEATURE_ALARM, rtc->features) ||
> !rtc->ops->read_alarm) {
> +       } else if (!test_bit(RTC_FEATURE_ALARM, rtc->features)) {
>                 err = -EINVAL;
>         } else {
>                 memset(alarm, 0, sizeof(struct rtc_wkalrm));


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-15 15:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-14 22:27 [PATCH] rtc: allow rtc_read_alarm without read_alarm callback alexandre.belloni
2023-02-15 15:00 ` Philippe Schenker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).