Re: rtc/m41t80: use rtc_valid_tm() to check returned tm

From: Atsushi Nemoto
Date: Tue Aug 17 2010 - 10:51:02 EST


On Fri, 13 Aug 2010 09:43:38 +0800, Wan ZongShun <mcuos.com@xxxxxxxxx> wrote:
> 2010/8/13 Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>:
> >> - Â Â Â return 0;
> >> + Â Â Â return rtc_valid_tm(t);
> >
> > warning: passing argument 1 of ârtc_valid_tmâ from incompatible pointer type
> >
> > `t' is of type `struct rtc_wkalrm *', not `struct rtc_time *'.
> > Probably the intention was:
> >
> > Â Â Â Âreturn rtc_valid_tm(&t->time);
>
> Okay, thank you point this warning.
>
> Andrew ,
>
> Could you please fix this warning directly for me?
> 'return rtc_valid_tm(t)' should be insteaded by 'return
> rtc_valid_tm(&t->time);'.

No, t->time does not contain complete date/time. It just holds some
alarm settings and -1 for some fields.

So rtc_valid_tm(&t->time) will always returns -EINVAL.
The correct fix would be just reverting rtc_valid_tm here.

------------------------------------------------------
From: Atsushi Nemoto <anemo@xxxxxxxxxxxxx>
Subject: [PATCH] rtc: m41t80: do not use rtc_valid_tm in m41t80_rtc_read_alarm

The commit b485fe5ea ("rtc/m41t80: use rtc_valid_tm() to check
returned tm") added rtc_valid_tm to m41t80_rtc_read_alarm() but it was
wrong while the t->time does not contain complete date/time.

This patch also fix a warning:
warning: passing argument 1 of ârtc_valid_tmâ from incompatible pointer type

Signed-off-by: Atsushi Nemoto <anemo@xxxxxxxxxxxxx>
---
drivers/rtc/rtc-m41t80.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 66377f3..d60557c 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -364,7 +364,7 @@ static int m41t80_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *t)
t->time.tm_isdst = -1;
t->enabled = !!(reg[M41T80_REG_ALARM_MON] & M41T80_ALMON_AFE);
t->pending = !!(reg[M41T80_REG_FLAGS] & M41T80_FLAGS_AF);
- return rtc_valid_tm(t);
+ return 0;
}

static struct rtc_class_ops m41t80_rtc_ops = {
èº{.nÇ+‰·Ÿ®‰­†+%ŠËlzwm…ébëæìr¸›zX§»®w¥Š{ayºÊÚë,j­¢f£¢·hš‹àz¹®w¥¢¸ ¢·¦j:+v‰¨ŠwèjØm¶Ÿÿ¾«‘êçzZ+ƒùšŽŠÝj"ú!¶iO•æ¬z·švØ^¶m§ÿðà nÆàþY&—