From d67892abd73458e56263441956206d796650f5bd Mon Sep 17 00:00:00 2001 From: Jacob Keller Date: Fri, 28 Sep 2012 11:45:43 -0700 Subject: [PATCH] ptp4l: modify servo setup to take an enum rather than string passing a string as the servo type seems ugly when there are only a few choices. This patch modifies the servo_create to take an enum instead. Signed-off-by: Jacob Keller --- clock.c | 2 +- servo.c | 4 ++-- servo.h | 11 +++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/clock.c b/clock.c index dc0e6c6..9b2c374 100644 --- a/clock.c +++ b/clock.c @@ -437,7 +437,7 @@ struct clock *clock_create(int phc_index, struct interface *iface, int count, if (c->clkid != CLOCK_INVALID) { fadj = (int) clock_ppb_read(c->clkid); } - c->servo = servo_create("pi", -fadj, max_adj, sw_ts); + c->servo = servo_create(CLOCK_SERVO_PI, -fadj, max_adj, sw_ts); if (!c->servo) { pr_err("Failed to create clock servo"); return NULL; diff --git a/servo.c b/servo.c index 8a644aa..97c2e60 100644 --- a/servo.c +++ b/servo.c @@ -21,9 +21,9 @@ #include "pi.h" #include "servo_private.h" -struct servo *servo_create(char *name, int fadj, int max_ppb, int sw_ts) +struct servo *servo_create(enum servo_type type, int fadj, int max_ppb, int sw_ts) { - if (!strncmp(name, "pi", 2)) { + if (type == CLOCK_SERVO_PI) { return pi_servo_create(fadj, max_ppb, sw_ts); } return NULL; diff --git a/servo.h b/servo.h index 0147d79..0d2ab71 100644 --- a/servo.h +++ b/servo.h @@ -23,6 +23,13 @@ /** Opaque type */ struct servo; +/** + * Defines the available servo cores + */ +enum servo_type { + CLOCK_SERVO_PI, +}; + /** * Defines the caller visible states of a clock servo. */ @@ -47,7 +54,7 @@ enum servo_state { /** * Create a new instance of a clock servo. - * @param name The name of the servo flavor to create. + * @param type The type of the servo to create. * @param fadj The clock's current adjustment in parts per billion. * @param max_ppb The absolute maxinum adjustment allowed by the clock * in parts per billion. The clock servo will clamp its @@ -56,7 +63,7 @@ enum servo_state { * and the servo should use more aggressive filtering. * @return A pointer to a new servo on success, NULL otherwise. */ -struct servo *servo_create(char *name, int fadj, int max_ppb, int sw_ts); +struct servo *servo_create(enum servo_type type, int fadj, int max_ppb, int sw_ts); /** * Destroy an instance of a clock servo.