[PATCH v2 09/15] char/mmtimer:Convert to the 64bit methods for k_clock callback function

2015-04-30 Thread Baolin Wang
This patch converts to the 64bit methods for k_clock callback
function, that converts the timespec type to timespec64 type and
converts the itimerspec type to itimerspec64 type.

Signed-off-by: Baolin Wang 
---
 drivers/char/mmtimer.c |   36 +---
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 3d6c067..213d0bb 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -478,18 +478,18 @@ static int sgi_clock_period;
 static struct timespec sgi_clock_offset;
 static int sgi_clock_period;
 
-static int sgi_clock_get(clockid_t clockid, struct timespec *tp)
+static int sgi_clock_get(clockid_t clockid, struct timespec64 *tp)
 {
u64 nsec;
 
nsec = rtc_time() * sgi_clock_period
+ sgi_clock_offset.tv_nsec;
-   *tp = ns_to_timespec(nsec);
+   *tp = ns_to_timespec64(nsec);
tp->tv_sec += sgi_clock_offset.tv_sec;
return 0;
 };
 
-static int sgi_clock_set(const clockid_t clockid, const struct timespec *tp)
+static int sgi_clock_set(const clockid_t clockid, const struct timespec64 *tp)
 {
 
u64 nsec;
@@ -657,7 +657,7 @@ static int sgi_timer_del(struct k_itimer *timr)
 }
 
 /* Assumption: it_lock is already held with irq's disabled */
-static void sgi_timer_get(struct k_itimer *timr, struct itimerspec 
*cur_setting)
+static void sgi_timer_get(struct k_itimer *timr, struct itimerspec64 
*cur_setting)
 {
 
if (timr->it.mmtimer.clock == TIMER_OFF) {
@@ -668,14 +668,14 @@ static void sgi_timer_get(struct k_itimer *timr, struct 
itimerspec *cur_setting)
return;
}
 
-   cur_setting->it_interval = ns_to_timespec(timr->it.mmtimer.incr * 
sgi_clock_period);
-   cur_setting->it_value = ns_to_timespec((timr->it.mmtimer.expires - 
rtc_time()) * sgi_clock_period);
+   cur_setting->it_interval = ns_to_timespec64(timr->it.mmtimer.incr * 
sgi_clock_period);
+   cur_setting->it_value = ns_to_timespec64((timr->it.mmtimer.expires - 
rtc_time()) * sgi_clock_period);
 }
 
 
 static int sgi_timer_set(struct k_itimer *timr, int flags,
-   struct itimerspec * new_setting,
-   struct itimerspec * old_setting)
+   struct itimerspec64 *new_setting,
+   struct itimerspec64 *old_setting)
 {
unsigned long when, period, irqflags;
int err = 0;
@@ -687,8 +687,8 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
sgi_timer_get(timr, old_setting);
 
sgi_timer_del(timr);
-   when = timespec_to_ns(_setting->it_value);
-   period = timespec_to_ns(_setting->it_interval);
+   when = timespec64_to_ns(_setting->it_value);
+   period = timespec64_to_ns(_setting->it_interval);
 
if (when == 0)
/* Clear timer */
@@ -699,11 +699,9 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
return -ENOMEM;
 
if (flags & TIMER_ABSTIME) {
-   struct timespec n;
unsigned long now;
 
-   getnstimeofday();
-   now = timespec_to_ns();
+   now = ktime_get_real_ns();
if (when > now)
when -= now;
else
@@ -765,7 +763,7 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
return err;
 }
 
-static int sgi_clock_getres(const clockid_t which_clock, struct timespec *tp)
+static int sgi_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
 {
tp->tv_sec = 0;
tp->tv_nsec = sgi_clock_period;
@@ -773,13 +771,13 @@ static int sgi_clock_getres(const clockid_t which_clock, 
struct timespec *tp)
 }
 
 static struct k_clock sgi_clock = {
-   .clock_set  = sgi_clock_set,
-   .clock_get  = sgi_clock_get,
-   .clock_getres   = sgi_clock_getres,
+   .clock_set64= sgi_clock_set,
+   .clock_get64= sgi_clock_get,
+   .clock_getres64 = sgi_clock_getres,
.timer_create   = sgi_timer_create,
-   .timer_set  = sgi_timer_set,
+   .timer_set64= sgi_timer_set,
.timer_del  = sgi_timer_del,
-   .timer_get  = sgi_timer_get
+   .timer_get64= sgi_timer_get
 };
 
 /**
-- 
1.7.9.5

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


[PATCH v2 09/15] char/mmtimer:Convert to the 64bit methods for k_clock callback function

2015-04-30 Thread Baolin Wang
This patch converts to the 64bit methods for k_clock callback
function, that converts the timespec type to timespec64 type and
converts the itimerspec type to itimerspec64 type.

Signed-off-by: Baolin Wang baolin.w...@linaro.org
---
 drivers/char/mmtimer.c |   36 +---
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 3d6c067..213d0bb 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -478,18 +478,18 @@ static int sgi_clock_period;
 static struct timespec sgi_clock_offset;
 static int sgi_clock_period;
 
-static int sgi_clock_get(clockid_t clockid, struct timespec *tp)
+static int sgi_clock_get(clockid_t clockid, struct timespec64 *tp)
 {
u64 nsec;
 
nsec = rtc_time() * sgi_clock_period
+ sgi_clock_offset.tv_nsec;
-   *tp = ns_to_timespec(nsec);
+   *tp = ns_to_timespec64(nsec);
tp-tv_sec += sgi_clock_offset.tv_sec;
return 0;
 };
 
-static int sgi_clock_set(const clockid_t clockid, const struct timespec *tp)
+static int sgi_clock_set(const clockid_t clockid, const struct timespec64 *tp)
 {
 
u64 nsec;
@@ -657,7 +657,7 @@ static int sgi_timer_del(struct k_itimer *timr)
 }
 
 /* Assumption: it_lock is already held with irq's disabled */
-static void sgi_timer_get(struct k_itimer *timr, struct itimerspec 
*cur_setting)
+static void sgi_timer_get(struct k_itimer *timr, struct itimerspec64 
*cur_setting)
 {
 
if (timr-it.mmtimer.clock == TIMER_OFF) {
@@ -668,14 +668,14 @@ static void sgi_timer_get(struct k_itimer *timr, struct 
itimerspec *cur_setting)
return;
}
 
-   cur_setting-it_interval = ns_to_timespec(timr-it.mmtimer.incr * 
sgi_clock_period);
-   cur_setting-it_value = ns_to_timespec((timr-it.mmtimer.expires - 
rtc_time()) * sgi_clock_period);
+   cur_setting-it_interval = ns_to_timespec64(timr-it.mmtimer.incr * 
sgi_clock_period);
+   cur_setting-it_value = ns_to_timespec64((timr-it.mmtimer.expires - 
rtc_time()) * sgi_clock_period);
 }
 
 
 static int sgi_timer_set(struct k_itimer *timr, int flags,
-   struct itimerspec * new_setting,
-   struct itimerspec * old_setting)
+   struct itimerspec64 *new_setting,
+   struct itimerspec64 *old_setting)
 {
unsigned long when, period, irqflags;
int err = 0;
@@ -687,8 +687,8 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
sgi_timer_get(timr, old_setting);
 
sgi_timer_del(timr);
-   when = timespec_to_ns(new_setting-it_value);
-   period = timespec_to_ns(new_setting-it_interval);
+   when = timespec64_to_ns(new_setting-it_value);
+   period = timespec64_to_ns(new_setting-it_interval);
 
if (when == 0)
/* Clear timer */
@@ -699,11 +699,9 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
return -ENOMEM;
 
if (flags  TIMER_ABSTIME) {
-   struct timespec n;
unsigned long now;
 
-   getnstimeofday(n);
-   now = timespec_to_ns(n);
+   now = ktime_get_real_ns();
if (when  now)
when -= now;
else
@@ -765,7 +763,7 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
return err;
 }
 
-static int sgi_clock_getres(const clockid_t which_clock, struct timespec *tp)
+static int sgi_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
 {
tp-tv_sec = 0;
tp-tv_nsec = sgi_clock_period;
@@ -773,13 +771,13 @@ static int sgi_clock_getres(const clockid_t which_clock, 
struct timespec *tp)
 }
 
 static struct k_clock sgi_clock = {
-   .clock_set  = sgi_clock_set,
-   .clock_get  = sgi_clock_get,
-   .clock_getres   = sgi_clock_getres,
+   .clock_set64= sgi_clock_set,
+   .clock_get64= sgi_clock_get,
+   .clock_getres64 = sgi_clock_getres,
.timer_create   = sgi_timer_create,
-   .timer_set  = sgi_timer_set,
+   .timer_set64= sgi_timer_set,
.timer_del  = sgi_timer_del,
-   .timer_get  = sgi_timer_get
+   .timer_get64= sgi_timer_get
 };
 
 /**
-- 
1.7.9.5

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