Add leap function to servo.

Introduce a new function to inform the servo about upcoming leap second.
This is used when the kernel leap is disabled to allow the servo to
handle better the sudden 1 second step in the offset when the leap
second is inserted or deleted.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
master
Miroslav Lichvar 2014-06-20 16:32:48 +02:00 committed by Richard Cochran
parent 7d740f17e5
commit 2aa6b10c3b
5 changed files with 20 additions and 0 deletions

View File

@ -697,6 +697,8 @@ static int clock_utc_correct(struct clock *c, tmv_t ingress)
if (c->leap_set != clock_leap) { if (c->leap_set != clock_leap) {
if (c->kernel_leap) if (c->kernel_leap)
sysclk_set_leap(clock_leap); sysclk_set_leap(clock_leap);
else
servo_leap(c->servo, clock_leap);
c->leap_set = clock_leap; c->leap_set = clock_leap;
} }
} }

View File

@ -1114,6 +1114,8 @@ static int clock_handle_leap(struct node *node, struct clock *clock,
if (clock->clkid == CLOCK_REALTIME && if (clock->clkid == CLOCK_REALTIME &&
node->kernel_leap) node->kernel_leap)
sysclk_set_leap(clock_leap); sysclk_set_leap(clock_leap);
else
servo_leap(clock->servo, clock_leap);
clock->leap_set = clock_leap; clock->leap_set = clock_leap;
} }
} }

View File

@ -107,3 +107,9 @@ double servo_rate_ratio(struct servo *servo)
return 1.0; return 1.0;
} }
void servo_leap(struct servo *servo, int leap)
{
if (servo->leap)
servo->leap(servo, leap);
}

View File

@ -132,4 +132,12 @@ void servo_reset(struct servo *servo);
*/ */
double servo_rate_ratio(struct servo *servo); double servo_rate_ratio(struct servo *servo);
/**
* Inform a clock servo about upcoming leap second.
* @param servo Pointer to a servo obtained via @ref servo_create().
* @param leap +1 when leap second will be inserted, -1 when leap second
* will be deleted, 0 when it passed.
*/
void servo_leap(struct servo *servo, int leap);
#endif #endif

View File

@ -38,6 +38,8 @@ struct servo {
void (*reset)(struct servo *servo); void (*reset)(struct servo *servo);
double (*rate_ratio)(struct servo *servo); double (*rate_ratio)(struct servo *servo);
void (*leap)(struct servo *servo, int leap);
}; };
#endif #endif