diff mbox

[2/2,RFC] ipmi: Update timespec usage to timespec64

Message ID 1420663910-6406-2-git-send-email-john.stultz@linaro.org
State Accepted
Headers show

Commit Message

John Stultz Jan. 7, 2015, 8:51 p.m. UTC
As part of the internal y2038 cleanup, this patch removes
timespec usage in the ipmi driver, replacing it timespec64

Cc: Corey Minyard <minyard@acm.org>
Cc: openipmi-developer@lists.sourceforge.net
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 drivers/char/ipmi/ipmi_si_intf.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

Comments

John Stultz Jan. 7, 2015, 9:22 p.m. UTC | #1
On Wed, Jan 7, 2015 at 1:12 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Wednesday 07 January 2015 12:51:50 John Stultz wrote:
>> As part of the internal y2038 cleanup, this patch removes
>> timespec usage in the ipmi driver, replacing it timespec64
>>
>> Cc: Corey Minyard <minyard@acm.org>
>> Cc: openipmi-developer@lists.sourceforge.net
>> Cc: Arnd Bergmann <arnd@arndb.de>
>> Signed-off-by: John Stultz <john.stultz@linaro.org>
>>
>
> In other drivers, we tended to use ktime_t and monotonic time,
> but your approach is definitely simpler because it doesn't have
> to rework the ipmi_si_is_busy logic and just do a
> s/timespec/timespec64/ conversion.
>
> Do you think it makes sense to use ktime_get_ts64 instead of
> getnstimeofday64 to get a monotonic time? The advantage would
> be to have the code work slightly better when racing against
> settimeofday, the downside would be that the debug printk
> shows the changed time base, but that would hopefully be
> irrelevant to someone debugging the code.

So here they were explicitly printing wall-time in sec/usec, so I was
somewhat hoping not to create any major behavioral changes.

But looking at this again, I see I sent a stale patch which has a
build bug (using tv_usec w/ a timespec64)... so let me redo this
anyway.

thanks
-john
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
diff mbox

Patch

diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index cc3a07d..814ba98 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -324,10 +324,10 @@  static void cleanup_ipmi_si(void);
 #ifdef DEBUG_TIMING
 void debug_timestamp(char *msg)
 {
-	struct timeval t;
+	struct timespec64 t;
 
-	do_gettimeofday(&t);
-	pr_debug("**%s: %d.%9.9d\n", msg, t.tv_sec, t.tv_usec);
+	do_getnstimeofday64(&t);
+	pr_debug("**%s: %lld.%9.9d\n", msg, (long long) t.tv_sec, t.tv_usec);
 }
 #else
 #define debug_timestamp(x)
@@ -988,18 +988,18 @@  static void set_run_to_completion(void *send_info, bool i_run_to_completion)
  * we are spinning in kipmid looking for something and not delaying
  * between checks
  */
-static inline void ipmi_si_set_not_busy(struct timespec *ts)
+static inline void ipmi_si_set_not_busy(struct timespec64 *ts)
 {
 	ts->tv_nsec = -1;
 }
-static inline int ipmi_si_is_busy(struct timespec *ts)
+static inline int ipmi_si_is_busy(struct timespec64 *ts)
 {
 	return ts->tv_nsec != -1;
 }
 
 static inline int ipmi_thread_busy_wait(enum si_sm_result smi_result,
 					const struct smi_info *smi_info,
-					struct timespec *busy_until)
+					struct timespec64 *busy_until)
 {
 	unsigned int max_busy_us = 0;
 
@@ -1008,12 +1008,13 @@  static inline int ipmi_thread_busy_wait(enum si_sm_result smi_result,
 	if (max_busy_us == 0 || smi_result != SI_SM_CALL_WITH_DELAY)
 		ipmi_si_set_not_busy(busy_until);
 	else if (!ipmi_si_is_busy(busy_until)) {
-		getnstimeofday(busy_until);
-		timespec_add_ns(busy_until, max_busy_us*NSEC_PER_USEC);
+		getnstimeofday64(busy_until);
+		timespec64_add_ns(busy_until, max_busy_us*NSEC_PER_USEC);
 	} else {
-		struct timespec now;
-		getnstimeofday(&now);
-		if (unlikely(timespec_compare(&now, busy_until) > 0)) {
+		struct timespec64 now;
+
+		getnstimeofday64(&now);
+		if (unlikely(timespec64_compare(&now, busy_until) > 0)) {
 			ipmi_si_set_not_busy(busy_until);
 			return 0;
 		}
@@ -1036,7 +1037,7 @@  static int ipmi_thread(void *data)
 	struct smi_info *smi_info = data;
 	unsigned long flags;
 	enum si_sm_result smi_result;
-	struct timespec busy_until;
+	struct timespec64 busy_until;
 
 	ipmi_si_set_not_busy(&busy_until);
 	set_user_nice(current, MAX_NICE);