linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] m68k/mac: Rework patch "use time64_t in RTC handling"
@ 2018-07-24  7:07 Finn Thain
  2018-07-24  9:23 ` Arnd Bergmann
  2018-07-29  9:00 ` Geert Uytterhoeven
  0 siblings, 2 replies; 3+ messages in thread
From: Finn Thain @ 2018-07-24  7:07 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Arnd Bergmann, linux-m68k, linux-kernel

This addresses the issues arising from commit 324caa29cd04
("m68k: mac: use time64_t in RTC handling").

Adopt __u32 for the union in via_read_time(), consistent with changes
to via_write_time().

Use low_32_bits() in via_write_time(), consistent with changes to
pmu_write_time() and cuda_write_time().

Have via_read_time() return a time64_t, consistent with changes to
pmu_read_time and cuda_read_time().

Drop the pointless wraparound conditional in via_read_time().

Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
---
 arch/m68k/mac/misc.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/arch/m68k/mac/misc.c b/arch/m68k/mac/misc.c
index bdc83eac6c61..19e9d8eef1f2 100644
--- a/arch/m68k/mac/misc.c
+++ b/arch/m68k/mac/misc.c
@@ -251,11 +251,11 @@ static void via_write_pram(int offset, __u8 data)
  * is basically any machine with Mac II-style ADB.
  */
 
-static long via_read_time(void)
+static time64_t via_read_time(void)
 {
 	union {
 		__u8 cdata[4];
-		long idata;
+		__u32 idata;
 	} result, last_result;
 	int count = 1;
 
@@ -275,12 +275,8 @@ static long via_read_time(void)
 		via_pram_command(0x89, &result.cdata[1]);
 		via_pram_command(0x8D, &result.cdata[0]);
 
-		if (result.idata == last_result.idata) {
-			if (result.idata < RTC_OFFSET)
-				result.idata += 0x100000000ull;
-
-			return result.idata - RTC_OFFSET;
-		}
+		if (result.idata == last_result.idata)
+			return (time64_t)result.idata - RTC_OFFSET;
 
 		if (++count > 10)
 			break;
@@ -288,8 +284,8 @@ static long via_read_time(void)
 		last_result.idata = result.idata;
 	}
 
-	pr_err("via_read_time: failed to read a stable value; got 0x%08lx then 0x%08lx\n",
-	       last_result.idata, result.idata);
+	pr_err("%s: failed to read a stable value; got 0x%08x then 0x%08x\n",
+	       __func__, last_result.idata, result.idata);
 
 	return 0;
 }
@@ -314,7 +310,7 @@ static void via_write_time(time64_t time)
 	temp = 0x55;
 	via_pram_command(0x35, &temp);
 
-	data.idata = time + RTC_OFFSET;
+	data.idata = lower_32_bits(time + RTC_OFFSET);
 	via_pram_command(0x01, &data.cdata[3]);
 	via_pram_command(0x05, &data.cdata[2]);
 	via_pram_command(0x09, &data.cdata[1]);
-- 
2.16.4


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

* Re: [PATCH] m68k/mac: Rework patch "use time64_t in RTC handling"
  2018-07-24  7:07 [PATCH] m68k/mac: Rework patch "use time64_t in RTC handling" Finn Thain
@ 2018-07-24  9:23 ` Arnd Bergmann
  2018-07-29  9:00 ` Geert Uytterhoeven
  1 sibling, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2018-07-24  9:23 UTC (permalink / raw)
  To: Finn Thain; +Cc: Geert Uytterhoeven, linux-m68k, Linux Kernel Mailing List

On Tue, Jul 24, 2018 at 9:07 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
> This addresses the issues arising from commit 324caa29cd04
> ("m68k: mac: use time64_t in RTC handling").
>
> Adopt __u32 for the union in via_read_time(), consistent with changes
> to via_write_time().
>
> Use low_32_bits() in via_write_time(), consistent with changes to
> pmu_write_time() and cuda_write_time().
>
> Have via_read_time() return a time64_t, consistent with changes to
> pmu_read_time and cuda_read_time().
>
> Drop the pointless wraparound conditional in via_read_time().
>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

Thanks for fixing it up!

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

* Re: [PATCH] m68k/mac: Rework patch "use time64_t in RTC handling"
  2018-07-24  7:07 [PATCH] m68k/mac: Rework patch "use time64_t in RTC handling" Finn Thain
  2018-07-24  9:23 ` Arnd Bergmann
@ 2018-07-29  9:00 ` Geert Uytterhoeven
  1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2018-07-29  9:00 UTC (permalink / raw)
  To: Finn Thain, Arnd Bergmann; +Cc: linux-m68k, Linux Kernel Mailing List

Hi Finn, Arnd,

On Tue, Jul 24, 2018 at 9:07 AM Finn Thain <fthain@telegraphics.com.au> wrote:
> This addresses the issues arising from commit 324caa29cd04
> ("m68k: mac: use time64_t in RTC handling").
>
> Adopt __u32 for the union in via_read_time(), consistent with changes
> to via_write_time().
>
> Use low_32_bits() in via_write_time(), consistent with changes to

lower_32_bits()

> pmu_write_time() and cuda_write_time().
>
> Have via_read_time() return a time64_t, consistent with changes to
> pmu_read_time and cuda_read_time().

pmu_read_time()

> Drop the pointless wraparound conditional in via_read_time().
>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>

Thanks!

Applied to master with the above fixed.
Folded into the original commit on for-v4.19, with:

    [fthain: Adopt __u32 for the union in via_read_time(), consistent with
             changes to via_write_time()]
    [fthain: Use lower_32_bits() in via_write_time(), consistent with changes
             to pmu_write_time() and cuda_write_time()]
    [fthain: Have via_read_time() return a time64_t, consistent with changes
             to pmu_read_time() and cuda_read_time()]
    [fthain: Drop the pointless wraparound conditional in via_read_time()]
    Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
    Reviewed-by: Arnd Bergmann <arnd@arndb.de>

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-07-29  9:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-24  7:07 [PATCH] m68k/mac: Rework patch "use time64_t in RTC handling" Finn Thain
2018-07-24  9:23 ` Arnd Bergmann
2018-07-29  9:00 ` Geert Uytterhoeven

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).