Skip to contentSkip to conversation

Implement clock_getres() function correctly

PTP Thomas Gleixner 3 participants 4 messages Dec 4, 2011 – Dec 5, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

clock_getres() needs to put the resolution into the provided timespec and return 0 in case of success.

---

drivers/ptp/ptp_clock.c +4 -1
index cf3f999..6b0c02a 100644
@@ -101,7 +101,10 @@ static s32 scaled_ppm_to_ppb(long ppm)
 
 static int ptp_clock_getres(struct posix_clock *pc, struct timespec *tp)
 {
-	return 1; /* always round timer functions to one nanosecond */
+	/* Resolution is one nanosecond */
+	*tp.tv_sec = 0;
+	*tp.tv_nsec = 1;
+	return 0;
 }
 
 static int ptp_clock_settime(struct posix_clock *pc, const struct timespec *tp)
#1 lore raw
Quoted 5 lines · Thomas Gleixner

clock_getres() needs to put the resolution into the provided timespec and return 0 in case of success.

Gah, wrong version.

drivers/ptp/ptp_clock.c +4 -1
index cf3f999..6b0c02a 100644
@@ -101,7 +101,10 @@ static s32 scaled_ppm_to_ppb(long ppm)
 
 static int ptp_clock_getres(struct posix_clock *pc, struct timespec *tp)
 {
-	return 1; /* always round timer functions to one nanosecond */
+	/* Resolution is one nanosecond */
+	tp->tv_sec = 0;
+	tp->tv_nsec = 1;
+	return 0;
 }
 
 static int ptp_clock_settime(struct posix_clock *pc, const struct timespec *tp)
maintainer Acked-by
#2 lore raw
Quoted 9 lines · Thomas Gleixner
Quoted 5 lines · Thomas Gleixner

clock_getres() needs to put the resolution into the provided timespec and return 0 in case of success.

Gah, wrong version.

Thanks for spotting that weird left over (from the old posix-timer.c code).

BTW, my email address has changed. Did you see my patch for MAINTAINERS a few weeks back? It would help when finding the current email address.

Thanks,
Richard

Quoted 22 lines
drivers/ptp/ptp_clock.c +4 -2
index cf3f999..6b0c02a 100644
@@ -101,7 +101,10 @@ static s32 scaled_ppm_to_ppb(long ppm)
 
 static int ptp_clock_getres(struct posix_clock *pc, struct timespec *tp)
 {
-	return 1; /* always round timer functions to one nanosecond */
+	/* Resolution is one nanosecond */
+	tp->tv_sec = 0;
+	tp->tv_nsec = 1;
+	return 0;
 }
 
 static int ptp_clock_settime(struct posix_clock *pc, const struct timespec *tp)
 
--

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

Acked-by
#3 lore raw
In reply to Thomas Gleixner
Quoted 16 lines · Thomas Gleixner
Quoted 5 lines · Thomas Gleixner

clock_getres() needs to put the resolution into the provided timespec and return 0 in case of success.

Gah, wrong version.

drivers/ptp/ptp_clock.c +0 -0
index cf3f999..6b0c02a 100644
@@ -101,7 +101,10 @@ static s32 scaled_ppm_to_ppb(long ppm)
 

drivers/ptp/ptp_clock.c static s32 scaled_ppm_to_ppb(long ppm) · line 110

Quoted 10 lines
drivers/ptp/ptp_clock.c +4 -1
 static int ptp_clock_getres(struct posix_clock *pc, struct timespec *tp)
 {
-	return 1; /* always round timer functions to one nanosecond */
+	/* Resolution is one nanosecond */
+	tp->tv_sec = 0;
+	tp->tv_nsec = 1;
+	return 0;
 }
 
 static int ptp_clock_settime(struct posix_clock *pc, const struct timespec *tp)

Looks good.