Skip to contentSkip to conversation

powerpc: mpic_timer: avoid struct timeval

PATCH RESEND Applied Arnd Bergmann 2 participants 2 messages Jan 16, 2018 – Jan 22, 2018 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 powerpc: mpic_timer: avoid struct timeval

In an effort to remove all instances of 'struct timeval' from the kernel, I'm changing the powerpc mpic_timer interface to use plain seconds instead. There is only one user of this interface, and that doesn't use the microseconds portion, so the code gets noticeably simpler in the process.

---
Submitted in November 2017, no reply, resending. Please apply.

---
 arch/powerpc/include/asm/mpic_timer.h       |  8 ++---
 arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c | 16 ++++-----
 arch/powerpc/sysdev/mpic_timer.c            | 55 ++++++-----------------------
 3 files changed, 21 insertions(+), 58 deletions(-)
arch/powerpc/include/asm/mpic_timer.h +4 -4
index 0e23cd4ac8aa..13e6702ec458 100644
@@ -29,17 +29,17 @@ struct mpic_timer {
 
 #ifdef CONFIG_MPIC_TIMER
 struct mpic_timer *mpic_request_timer(irq_handler_t fn,  void *dev,
-		const struct timeval *time);
+		time64_t time);
 void mpic_start_timer(struct mpic_timer *handle);
 void mpic_stop_timer(struct mpic_timer *handle);
-void mpic_get_remain_time(struct mpic_timer *handle, struct timeval *time);
+void mpic_get_remain_time(struct mpic_timer *handle, time64_t *time);
 void mpic_free_timer(struct mpic_timer *handle);
 #else
 struct mpic_timer *mpic_request_timer(irq_handler_t fn,  void *dev,
-		const struct timeval *time) { return NULL; }
+		time64_t time) { return NULL; }
 void mpic_start_timer(struct mpic_timer *handle) { }
 void mpic_stop_timer(struct mpic_timer *handle) { }
-void mpic_get_remain_time(struct mpic_timer *handle, struct timeval *time) { }
+void mpic_get_remain_time(struct mpic_timer *handle, time64_t *time) { }
 void mpic_free_timer(struct mpic_timer *handle) { }
 #endif
 
arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c +7 -9
index 1707bf04dec6..94278e8af192 100644
@@ -56,17 +56,16 @@ static ssize_t fsl_timer_wakeup_show(struct device *dev,
 				struct device_attribute *attr,
 				char *buf)
 {
-	struct timeval interval;
-	int val = 0;
+	time64_t interval = 0;
 
 	mutex_lock(&sysfs_lock);
 	if (fsl_wakeup->timer) {
 		mpic_get_remain_time(fsl_wakeup->timer, &interval);
-		val = interval.tv_sec + 1;
+		interval++;
 	}
 	mutex_unlock(&sysfs_lock);
 
-	return sprintf(buf, "%d\n", val);
+	return sprintf(buf, "%lld\n", interval);
 }
 
 static ssize_t fsl_timer_wakeup_store(struct device *dev,
@@ -74,11 +73,10 @@ static ssize_t fsl_timer_wakeup_store(struct device *dev,
 				const char *buf,
 				size_t count)
 {
-	struct timeval interval;
+	time64_t interval;
 	int ret;
 
-	interval.tv_usec = 0;
-	if (kstrtol(buf, 0, &interval.tv_sec))
+	if (kstrtoll(buf, 0, &interval))
 		return -EINVAL;
 
 	mutex_lock(&sysfs_lock);
@@ -89,13 +87,13 @@ static ssize_t fsl_timer_wakeup_store(struct device *dev,
 		fsl_wakeup->timer = NULL;
 	}
 
-	if (!interval.tv_sec) {
+	if (!interval) {
 		mutex_unlock(&sysfs_lock);
 		return count;
 	}
 
 	fsl_wakeup->timer = mpic_request_timer(fsl_mpic_timer_irq,
-						fsl_wakeup, &interval);
+						fsl_wakeup, interval);
 	if (!fsl_wakeup->timer) {
 		mutex_unlock(&sysfs_lock);
 		return -EINVAL;
arch/powerpc/sysdev/mpic_timer.c +10 -45

109 lines not on this page · raw message

Signature · 1 line
2.9.0
#1 lore raw
Quoted 7 lines · Arnd Bergmann

In an effort to remove all instances of 'struct timeval' from the kernel, I'm changing the powerpc mpic_timer interface to use plain seconds instead. There is only one user of this interface, and that doesn't use the microseconds portion, so the code gets noticeably simpler in the process.

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/11ed8c5569b149a065184dc8ce2241

cheers