misc: ibmasm: Replace timeval with timespec64
PATCH v2 1/1 misc: ibmasm: Replace timeval with timespec64
This patch replaces timeval with timespec64 as 32 bit 'struct timeval' will not give current time beyond 2038.
The patch changes the code to use ktime_get_real_ts64() which returns a 'struct timespec64' instead of do_gettimeofday() which returns a 'struct timeval'
This patch also alters the format strings in sprintf() for now.tv_sec and now.tv_nsec to incorporate 'long long' on 32 bit architectures and leading zeroes respectively.
---
Changes in v2:
-change format string of now.tv_sec to '%llu' -change format string of now.tv_nsec to '%.08lu'
drivers/misc/ibmasm/ibmasm.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/misc/ibmasm/ibmasm.h +4 -3
@@ -34,6 +34,7 @@#include <linux/kref.h> #include <linux/device.h> #include <linux/input.h> +#include <linux/time64.h> /* Driver identification */ #define DRIVER_NAME "ibmasm"
@@ -53,9 +54,9 @@ extern int ibmasm_debug;static inline char *get_timestamp (char *buf) { -struct timeval now; -do_gettimeofday (&now); -sprintf (buf,"%lu.%lu" , now.tv_sec, now.tv_usec); +struct timespec64 now; +ktime_get_real_ts64 (&now); +sprintf (buf,"%llu.%.08lu" , (long long )now.tv_sec, now.tv_usec);return buf; }
Signature · 1 line
1.9.1
Quoted 7 lines · On Friday 23 October 2015 17:52:06 Amitoj Kaur Chawla wrote:
This patch replaces timeval with timespec64 as 32 bit 'struct timeval' will not give current time beyond 2038.
The patch changes the code to use
ktime_get_real_ts64()which returns a 'struct timespec64' instead ofdo_gettimeofday()which returns a 'struct timeval'
Quoted 5 lines
This patch also alters the format strings in
sprintf()for now.tv_sec and now.tv_nsec to incorporate 'long long' on 32 bit architectures and leading zeroes respectively.Signed-off-by Amitoj Kaur Chawla <[email protected]>
Arnd Bergmann
maintainerQuoted 8 lines · On Friday 23 October 2015 15:39:49 Arnd Bergmann wrote:
Quoted 7 lines · On Friday 23 October 2015 17:52:06 Amitoj Kaur Chawla wrote:
This patch replaces timeval with timespec64 as 32 bit 'struct timeval' will not give current time beyond 2038.
The patch changes the code to use
ktime_get_real_ts64()which returns a 'struct timespec64' instead ofdo_gettimeofday()which returns a 'struct timeval'
Quoted 7 lines
Quoted 5 lines
This patch also alters the format strings in
sprintf()for now.tv_sec and now.tv_nsec to incorporate 'long long' on 32 bit architectures and leading zeroes respectively.Signed-off-by Amitoj Kaur Chawla <[email protected]>Reviewed-by Arnd Bergmann <[email protected]>
I was going to suggest to send this to the maintainers now, but after checking the MAINTAINERS file myself, I see that this would be Greg and me ;-)
Greg, can you pick this up into the char-misc tree?
Arnd
Quoted 15 lines · Arnd Bergmann
Quoted 14 lines · On Friday 23 October 2015 15:39:49 Arnd Bergmann wrote:
Quoted 12 lines · On Friday 23 October 2015 17:52:06 Amitoj Kaur Chawla wrote:
This patch replaces timeval with timespec64 as 32 bit 'struct timeval' will not give current time beyond 2038.
The patch changes the code to use
ktime_get_real_ts64()which returns a 'struct timespec64' instead ofdo_gettimeofday()which returns a 'struct timeval'This patch also alters the format strings in
sprintf()for now.tv_sec and now.tv_nsec to incorporate 'long long' on 32 bit architectures and leading zeroes respectively.Signed-off-by Amitoj Kaur Chawla <[email protected]>
Quoted 8 lines
Quoted 1 line
Reviewed-by Arnd Bergmann <[email protected]>I was going to suggest to send this to the maintainers now, but after checking the
MAINTAINERSfile myself, I see that this would be Greg and me ;-)Greg, can you pick this up into the char-misc tree?
Arnd
Hi Arnd,
I made a slight error while sending v2 which I caught after figuring out of my issue of compiling the module.
I'm sending a v3 after build testing it.
Should I cc you and Greg separately or let it be?
Signature · 1 line
Amitoj
Arnd Bergmann
maintainerQuoted 25 lines · On Friday 23 October 2015 19:28:00 Amitoj Kaur Chawla wrote:
Quoted 15 lines · Arnd Bergmann
Quoted 14 lines · On Friday 23 October 2015 15:39:49 Arnd Bergmann wrote:
Quoted 12 lines · On Friday 23 October 2015 17:52:06 Amitoj Kaur Chawla wrote:
This patch replaces timeval with timespec64 as 32 bit 'struct timeval' will not give current time beyond 2038.
The patch changes the code to use
ktime_get_real_ts64()which returns a 'struct timespec64' instead ofdo_gettimeofday()which returns a 'struct timeval'This patch also alters the format strings in
sprintf()for now.tv_sec and now.tv_nsec to incorporate 'long long' on 32 bit architectures and leading zeroes respectively.Signed-off-by Amitoj Kaur Chawla <[email protected]>Quoted 8 lines
Quoted 1 line
Reviewed-by Arnd Bergmann <[email protected]>I was going to suggest to send this to the maintainers now, but after checking the
MAINTAINERSfile myself, I see that this would be Greg and meGreg, can you pick this up into the char-misc tree?
Arnd
Quoted 8 lines
Hi Arnd,
I made a slight error while sending v2 which I caught after figuring out of my issue of compiling the module.
I'm sending a v3 after build testing it.
Should I cc you and Greg separately or let it be?
In general, it helps to Cc maintainers. We are good at ignoring duplicate mails.
Arnd