All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] m68k: use read_persistent_clock64 consistently
@ 2018-04-23  8:52 Arnd Bergmann
  2018-04-23 10:33 ` Baolin Wang
  2018-04-24 10:25 ` Geert Uytterhoeven
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2018-04-23  8:52 UTC (permalink / raw)
  To: Geert Uytterhoeven, linux-m68k
  Cc: Stan Johnson, Finn Thain, Sam Creasey, y2038, baolin.wang,
	Arnd Bergmann, Alexandre Belloni, linux-kernel

We have two ways of getting the current time from a platform at boot
or during suspend: either using read_persistent_clock() or the rtc
class operation. We never need both, so I'm hiding the
read_persistent_clock variant when the generic RTC is enabled.

Since read_persistent_clock() and mktime() are deprecated because of
the y2038 overflow of time_t, we should use the time64_t based
replacements here.

Finally, the dependency on CONFIG_ARCH_USES_GETTIMEOFFSET looks
completely bogus in this case, so let's remove that. It was
added in commit b13b3f51ff7b ("m68k: fix inclusion of
arch_gettimeoffset for non-MMU 68k classic CPU types") to deal
with arch_gettimeoffset(), which has since been removed from
this file and is unrelated to the RTC functions.

The rtc accessors are only used by classic machines, while
coldfire uses proper RTC drivers, so we can put the old
ifdef back around both functions.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/m68k/kernel/time.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c
index 6b4389a6e8ea..3a8b47f8f97b 100644
--- a/arch/m68k/kernel/time.c
+++ b/arch/m68k/kernel/time.c
@@ -71,7 +71,9 @@ static irqreturn_t timer_interrupt(int irq, void *dummy)
 	return IRQ_HANDLED;
 }
 
-void read_persistent_clock(struct timespec *ts)
+#ifdef CONFIG_M68KCLASSIC
+#if !IS_BUILTIN(CONFIG_RTC_DRV_GENERIC)
+void read_persistent_clock64(struct timespec64 *ts)
 {
 	struct rtc_time time;
 
@@ -83,11 +85,12 @@ void read_persistent_clock(struct timespec *ts)
 
 	mach_hwclk(0, &time);
 
-	ts->tv_sec = mktime(time.tm_year + 1900, time.tm_mon + 1, time.tm_mday,
-			    time.tm_hour, time.tm_min, time.tm_sec);
+	ts->tv_sec = mktime64(time.tm_year + 1900, time.tm_mon + 1, time.tm_mday,
+			      time.tm_hour, time.tm_min, time.tm_sec);
 }
+#endif
 
-#if defined(CONFIG_ARCH_USES_GETTIMEOFFSET) && IS_ENABLED(CONFIG_RTC_DRV_GENERIC)
+#if IS_ENABLED(CONFIG_RTC_DRV_GENERIC)
 static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm)
 {
 	mach_hwclk(0, tm);
@@ -145,8 +148,8 @@ static int __init rtc_init(void)
 }
 
 module_init(rtc_init);
-
-#endif /* CONFIG_ARCH_USES_GETTIMEOFFSET */
+#endif /* CONFIG_RTC_DRV_GENERIC */
+#endif /* CONFIG M68KCLASSIC */
 
 void __init time_init(void)
 {
-- 
2.9.0

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

* Re: [PATCH] m68k: use read_persistent_clock64 consistently
  2018-04-23  8:52 [PATCH] m68k: use read_persistent_clock64 consistently Arnd Bergmann
@ 2018-04-23 10:33 ` Baolin Wang
  2018-04-24 10:25 ` Geert Uytterhoeven
  1 sibling, 0 replies; 3+ messages in thread
From: Baolin Wang @ 2018-04-23 10:33 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Geert Uytterhoeven, linux-m68k, Stan Johnson, Finn Thain,
	Sam Creasey, y2038 Mailman List, Alexandre Belloni, LKML

On 23 April 2018 at 16:52, Arnd Bergmann <arnd@arndb.de> wrote:
> We have two ways of getting the current time from a platform at boot
> or during suspend: either using read_persistent_clock() or the rtc
> class operation. We never need both, so I'm hiding the
> read_persistent_clock variant when the generic RTC is enabled.
>
> Since read_persistent_clock() and mktime() are deprecated because of
> the y2038 overflow of time_t, we should use the time64_t based
> replacements here.
>
> Finally, the dependency on CONFIG_ARCH_USES_GETTIMEOFFSET looks
> completely bogus in this case, so let's remove that. It was
> added in commit b13b3f51ff7b ("m68k: fix inclusion of
> arch_gettimeoffset for non-MMU 68k classic CPU types") to deal
> with arch_gettimeoffset(), which has since been removed from
> this file and is unrelated to the RTC functions.
>
> The rtc accessors are only used by classic machines, while
> coldfire uses proper RTC drivers, so we can put the old
> ifdef back around both functions.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Thanks for correct my mistake. Please add my tag if it helps.
Reviewed-by: Baolin Wang <baolin.wang@linaro.org>

> ---
>  arch/m68k/kernel/time.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c
> index 6b4389a6e8ea..3a8b47f8f97b 100644
> --- a/arch/m68k/kernel/time.c
> +++ b/arch/m68k/kernel/time.c
> @@ -71,7 +71,9 @@ static irqreturn_t timer_interrupt(int irq, void *dummy)
>         return IRQ_HANDLED;
>  }
>
> -void read_persistent_clock(struct timespec *ts)
> +#ifdef CONFIG_M68KCLASSIC
> +#if !IS_BUILTIN(CONFIG_RTC_DRV_GENERIC)
> +void read_persistent_clock64(struct timespec64 *ts)
>  {
>         struct rtc_time time;
>
> @@ -83,11 +85,12 @@ void read_persistent_clock(struct timespec *ts)
>
>         mach_hwclk(0, &time);
>
> -       ts->tv_sec = mktime(time.tm_year + 1900, time.tm_mon + 1, time.tm_mday,
> -                           time.tm_hour, time.tm_min, time.tm_sec);
> +       ts->tv_sec = mktime64(time.tm_year + 1900, time.tm_mon + 1, time.tm_mday,
> +                             time.tm_hour, time.tm_min, time.tm_sec);
>  }
> +#endif
>
> -#if defined(CONFIG_ARCH_USES_GETTIMEOFFSET) && IS_ENABLED(CONFIG_RTC_DRV_GENERIC)
> +#if IS_ENABLED(CONFIG_RTC_DRV_GENERIC)
>  static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm)
>  {
>         mach_hwclk(0, tm);
> @@ -145,8 +148,8 @@ static int __init rtc_init(void)
>  }
>
>  module_init(rtc_init);
> -
> -#endif /* CONFIG_ARCH_USES_GETTIMEOFFSET */
> +#endif /* CONFIG_RTC_DRV_GENERIC */
> +#endif /* CONFIG M68KCLASSIC */
>
>  void __init time_init(void)
>  {
> --
> 2.9.0
>



-- 
Baolin.wang
Best Regards

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

* Re: [PATCH] m68k: use read_persistent_clock64 consistently
  2018-04-23  8:52 [PATCH] m68k: use read_persistent_clock64 consistently Arnd Bergmann
  2018-04-23 10:33 ` Baolin Wang
@ 2018-04-24 10:25 ` Geert Uytterhoeven
  1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2018-04-24 10:25 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-m68k, Stan Johnson, Finn Thain, Sam Creasey,
	y2038 Mailman List, Baolin Wang, Alexandre Belloni,
	Linux Kernel Mailing List

On Mon, Apr 23, 2018 at 10:52 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> We have two ways of getting the current time from a platform at boot
> or during suspend: either using read_persistent_clock() or the rtc
> class operation. We never need both, so I'm hiding the
> read_persistent_clock variant when the generic RTC is enabled.
>
> Since read_persistent_clock() and mktime() are deprecated because of
> the y2038 overflow of time_t, we should use the time64_t based
> replacements here.
>
> Finally, the dependency on CONFIG_ARCH_USES_GETTIMEOFFSET looks
> completely bogus in this case, so let's remove that. It was
> added in commit b13b3f51ff7b ("m68k: fix inclusion of
> arch_gettimeoffset for non-MMU 68k classic CPU types") to deal
> with arch_gettimeoffset(), which has since been removed from
> this file and is unrelated to the RTC functions.
>
> The rtc accessors are only used by classic machines, while
> coldfire uses proper RTC drivers, so we can put the old
> ifdef back around both functions.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Thanks, applied and queued for v4.18 with Baolin's Rb.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

end of thread, other threads:[~2018-04-24 10:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-23  8:52 [PATCH] m68k: use read_persistent_clock64 consistently Arnd Bergmann
2018-04-23 10:33 ` Baolin Wang
2018-04-24 10:25 ` Geert Uytterhoeven

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.