Skip to contentSkip to conversation

watchdog: xen: use time64_t for timeouts

PATCH In review Arnd Bergmann 2 participants 3 messages Oct 19, 2017 Watchdog device drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 watchdog: xen: use time64_t for timeouts

The Xen watchdog driver uses __kernel_time_t and ktime_to_timespec() internally for managing its timeouts. Both are deprecated because of y2038 problems. The driver itself is fine, since it only uses monotonic times, but converting it to use ktime_get_seconds() avoids the deprecated interfaces and is slightly simpler.

---
 drivers/watchdog/xen_wdt.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/watchdog/xen_wdt.c +6 -6
index cf0e650c2015..5dd5c3494d55 100644
@@ -35,7 +35,7 @@
 static struct platform_device *platform_device;
 static DEFINE_SPINLOCK(wdt_lock);
 static struct sched_watchdog wdt;
-static __kernel_time_t wdt_expires;
+static time64_t wdt_expires;
 static bool is_active, expect_release;
 
 #define WATCHDOG_TIMEOUT 60 /* in seconds */
@@ -49,15 +49,15 @@ module_param(nowayout, bool, S_IRUGO);
 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
 	"(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
 
-static inline __kernel_time_t set_timeout(void)
+static inline time64_t set_timeout(void)
 {
 	wdt.timeout = timeout;
-	return ktime_to_timespec(ktime_get()).tv_sec + timeout;
+	return ktime_get_seconds() + timeout;
 }
 
 static int xen_wdt_start(void)
 {
-	__kernel_time_t expires;
+	time64_t expires;
 	int err;
 
 	spin_lock(&wdt_lock);
@@ -98,7 +98,7 @@ static int xen_wdt_stop(void)
 
 static int xen_wdt_kick(void)
 {
-	__kernel_time_t expires;
+	time64_t expires;
 	int err;
 
 	spin_lock(&wdt_lock);
@@ -222,7 +222,7 @@ static long xen_wdt_ioctl(struct file *file, unsigned int cmd,
 		return put_user(timeout, argp);
 
 	case WDIOC_GETTIMELEFT:
-		retval = wdt_expires - ktime_to_timespec(ktime_get()).tv_sec;
+		retval = wdt_expires - ktime_get_seconds();
 		return put_user(retval, argp);
 	}
 
Signature · 1 line
2.9.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Arnd Bergmann

The Xen watchdog driver uses __kernel_time_t and ktime_to_timespec() internally for managing its timeouts. Both are deprecated because of y2038 problems. The driver itself is fine, since it only uses monotonic times, but converting it to use ktime_get_seconds() avoids the deprecated interfaces and is slightly simpler.

Quoted 57 lines
---
 drivers/watchdog/xen_wdt.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/watchdog/xen_wdt.c +6 -6
index cf0e650c2015..5dd5c3494d55 100644
@@ -35,7 +35,7 @@
 static struct platform_device *platform_device;
 static DEFINE_SPINLOCK(wdt_lock);
 static struct sched_watchdog wdt;
-static __kernel_time_t wdt_expires;
+static time64_t wdt_expires;
 static bool is_active, expect_release;
 
 #define WATCHDOG_TIMEOUT 60 /* in seconds */
@@ -49,15 +49,15 @@ module_param(nowayout, bool, S_IRUGO);
 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
 	"(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
 
-static inline __kernel_time_t set_timeout(void)
+static inline time64_t set_timeout(void)
 {
 	wdt.timeout = timeout;
-	return ktime_to_timespec(ktime_get()).tv_sec + timeout;
+	return ktime_get_seconds() + timeout;
 }
 
 static int xen_wdt_start(void)
 {
-	__kernel_time_t expires;
+	time64_t expires;
 	int err;
 
 	spin_lock(&wdt_lock);
@@ -98,7 +98,7 @@ static int xen_wdt_stop(void)
 
 static int xen_wdt_kick(void)
 {
-	__kernel_time_t expires;
+	time64_t expires;
 	int err;
 
 	spin_lock(&wdt_lock);
@@ -222,7 +222,7 @@ static long xen_wdt_ioctl(struct file *file, unsigned int cmd,
 		return put_user(timeout, argp);
 
 	case WDIOC_GETTIMELEFT:
-		retval = wdt_expires - ktime_to_timespec(ktime_get()).tv_sec;
+		retval = wdt_expires - ktime_get_seconds();
 		return put_user(retval, argp);
 	}
 
Signature · 1 line
2.9.0
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 7 lines · Arnd Bergmann

The Xen watchdog driver uses __kernel_time_t and ktime_to_timespec() internally for managing its timeouts. Both are deprecated because of y2038 problems. The driver itself is fine, since it only uses monotonic times, but converting it to use ktime_get_seconds() avoids the deprecated interfaces and is slightly simpler.

Quoted 57 lines
---
 drivers/watchdog/xen_wdt.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/watchdog/xen_wdt.c +6 -6
index cf0e650c2015..5dd5c3494d55 100644
@@ -35,7 +35,7 @@
 static struct platform_device *platform_device;
 static DEFINE_SPINLOCK(wdt_lock);
 static struct sched_watchdog wdt;
-static __kernel_time_t wdt_expires;
+static time64_t wdt_expires;
 static bool is_active, expect_release;
 
 #define WATCHDOG_TIMEOUT 60 /* in seconds */
@@ -49,15 +49,15 @@ module_param(nowayout, bool, S_IRUGO);
 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
 	"(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
 
-static inline __kernel_time_t set_timeout(void)
+static inline time64_t set_timeout(void)
 {
 	wdt.timeout = timeout;
-	return ktime_to_timespec(ktime_get()).tv_sec + timeout;
+	return ktime_get_seconds() + timeout;
 }
 
 static int xen_wdt_start(void)
 {
-	__kernel_time_t expires;
+	time64_t expires;
 	int err;
 
 	spin_lock(&wdt_lock);
@@ -98,7 +98,7 @@ static int xen_wdt_stop(void)
 
 static int xen_wdt_kick(void)
 {
-	__kernel_time_t expires;
+	time64_t expires;
 	int err;
 
 	spin_lock(&wdt_lock);
@@ -222,7 +222,7 @@ static long xen_wdt_ioctl(struct file *file, unsigned int cmd,
 		return put_user(timeout, argp);
 
 	case WDIOC_GETTIMELEFT:
-		retval = wdt_expires - ktime_to_timespec(ktime_get()).tv_sec;
+		retval = wdt_expires - ktime_get_seconds();
 		return put_user(retval, argp);
 	}
 
Signature · 1 line
2.9.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel