Re: [RFC PATCH 2/4] rtc: Convert rtc_class_ops.set_mmss() to use time64_t

From: pang.xunlei
Date: Fri Nov 28 2014 - 11:49:54 EST


On 27 November 2014 at 20:02, Xunlei Pang <pang.xunlei@xxxxxxxxxx> wrote:
> Currently the rtc_class_op's set_mmss() function takes a 32bit second
> value (on 32bit systems), which is problematic for dates past y2038.
>
> This patch resolves it by changing the interface and all users to use
> y2038 safe time64_t.
>
> Cc: John Stultz <john.stultz@xxxxxxxxxx>
> Cc: Arnd Bergmann <arnd.bergmann@xxxxxxxxxx>
> Signed-off-by: Xunlei Pang <pang.xunlei@xxxxxxxxxx>
>
> diff --git a/drivers/rtc/rtc-ds2404.c b/drivers/rtc/rtc-ds2404.c
> index fc209dc..ec50757 100644
> --- a/drivers/rtc/rtc-ds2404.c
> +++ b/drivers/rtc/rtc-ds2404.c
> @@ -210,9 +210,16 @@ static int ds2404_read_time(struct device *dev, struct rtc_time *dt)
> return rtc_valid_tm(dt);
> }
>
> -static int ds2404_set_mmss(struct device *dev, unsigned long secs)
> +static int ds2404_set_mmss(struct device *dev, time64_t secs)
> {
> + /*
> + * y2106 issue:
> + * On 32bit systems the time64_t secs value gets cast to
> + * a 32bit long, and thus we can only write a maximum value
> + * of y2016
> + */
> u32 time = cpu_to_le32(secs);
> +
> ds2404_write_memory(dev, 0x203, 4, (u8 *)&time);

Hi Sven,

Does this rtc hardware support ds2404_write_memory() with length > 4,
i.e. y2106 safe?

Thanks,
Xunlei
> return 0;
> }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/