[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1426743909-24335-3-git-send-email-baolin.wang@linaro.org>
Date: Thu, 19 Mar 2015 13:45:07 +0800
From: Baolin Wang <baolin.wang@...aro.org>
To: richardcochran@...il.com
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
john.stultz@...aro.com, tglx@...utronix.de, arnd@...aro.org,
baolin.wang@...aro.org
Subject: [PATCH 2/4] ptp/clcok:Introduce the setktime/getktime interfaces with "ktime_t" type
This patch introduces another two options to get/set time with "ktime_t"
type in ptp clock operation.
Original code will set/get time through the settime/gettime interfaces
with "timespec" type, that will cause break issue in year 2038. And now
introducing the new setktime/getktime interfaces with "ktime_t" type to
use firstly.
Signed-off-by: Baolin Wang <baolin.wang@...aro.org>
---
drivers/ptp/ptp_clock.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index 296b0ec..46425ad 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
@@ -106,14 +106,30 @@ static int ptp_clock_getres(struct posix_clock *pc, struct timespec *tp)
static int ptp_clock_settime(struct posix_clock *pc, const struct timespec *tp)
{
+ ktime_t kt;
struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
- return ptp->info->settime(ptp->info, tp);
+
+ if (ptp->info->setktime) {
+ kt = timespec_to_ktime(*tp);
+ return ptp->info->setktime(ptp->info, kt);
+ } else {
+ return ptp->info->settime(ptp->info, tp);
+ }
}
static int ptp_clock_gettime(struct posix_clock *pc, struct timespec *tp)
{
+ ktime_t kt;
+ int ret;
struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
- return ptp->info->gettime(ptp->info, tp);
+
+ if (ptp->info->getktime) {
+ ret = ptp->info->getktime(ptp->info, &kt);
+ *tp = ktime_to_timespec(kt);
+ return ret;
+ } else {
+ return ptp->info->gettime(ptp->info, tp);
+ }
}
static int ptp_clock_adjtime(struct posix_clock *pc, struct timex *tx)
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists