Skip to contentSkip to conversation

posix-timers:Split out the guts of the syscall and change the implementation for timer_gettime

PATCH Superseded Baolin Wang 1 participant 1 message May 11, 2015 Posix clocks and timers

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 4/22 posix-timers:Split out the guts of the syscall and change the implementation for timer_gettime

This patch splits out the guts of the timer_gettime syscall and changes the timer_gettime syscall implementation to prepare the converting to 64bit methods for the timer_gettime syscall function in posix-timers.c file.

---
 kernel/time/posix-timers.c |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
kernel/time/posix-timers.c +11 -5
index 31ea01f..9df664a 100644
@@ -766,11 +766,8 @@ common_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting)
 		cur_setting->it_value = ktime_to_timespec(remaining);
 }
 
-/* Get the time remaining on a POSIX.1b interval timer. */
-SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
-		struct itimerspec __user *, setting)
+static int __timer_gettime(timer_t timer_id, struct itimerspec *cur_setting)
 {
-	struct itimerspec cur_setting;
 	struct k_itimer *timr;
 	struct k_clock *kc;
 	unsigned long flags;
@@ -784,9 +781,18 @@ SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
 	if (WARN_ON_ONCE(!kc || !kc->timer_get))
 		ret = -EINVAL;
 	else
-		kc->timer_get(timr, &cur_setting);
+		kc->timer_get(timr, cur_setting);
 
 	unlock_timer(timr, flags);
+	return ret;
+}
+
+/* Get the time remaining on a POSIX.1b interval timer. */
+SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
+		struct itimerspec __user *, setting)
+{
+	struct itimerspec cur_setting;
+	int ret = __timer_gettime(timer_id, &cur_setting);
 
 	if (!ret && copy_to_user(setting, &cur_setting, sizeof (cur_setting)))
 		return -EFAULT;
Signature · 1 line
1.7.9.5