From da347d7a36f2c0c213fda336eb40720d0eefc99b Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 4 Apr 2013 17:28:21 +0200 Subject: [PATCH] ptp4l: Set clock frequency on start. Due to a bug in older kernels, frequency reading may silently fail and return 0. Set the frequency to the read value to make sure the servo has the actual frequency of the clock. Signed-off-by: Miroslav Lichvar --- clock.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clock.c b/clock.c index 1f55276..44ef81a 100644 --- a/clock.c +++ b/clock.c @@ -597,6 +597,10 @@ struct clock *clock_create(int phc_index, struct interface *iface, int count, if (c->clkid != CLOCK_INVALID) { fadj = (int) clockadj_get_freq(c->clkid); + /* Due to a bug in older kernels, the reading may silently fail + and return 0. Set the frequency back to make sure fadj is + the actual frequency of the clock. */ + clockadj_set_freq(c->clkid, fadj); } c->servo = servo_create(servo, -fadj, max_adj, sw_ts); if (!c->servo) {