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 <jacob.e.keller@intel.com>
master
Jacob Keller 2012-09-28 11:45:43 -07:00 committed by Richard Cochran
parent a0fc92957f
commit d67892abd7
3 changed files with 12 additions and 5 deletions

View File

@ -437,7 +437,7 @@ struct clock *clock_create(int phc_index, struct interface *iface, int count,
if (c->clkid != CLOCK_INVALID) { if (c->clkid != CLOCK_INVALID) {
fadj = (int) clock_ppb_read(c->clkid); 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) { if (!c->servo) {
pr_err("Failed to create clock servo"); pr_err("Failed to create clock servo");
return NULL; return NULL;

View File

@ -21,9 +21,9 @@
#include "pi.h" #include "pi.h"
#include "servo_private.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 pi_servo_create(fadj, max_ppb, sw_ts);
} }
return NULL; return NULL;

11
servo.h
View File

@ -23,6 +23,13 @@
/** Opaque type */ /** Opaque type */
struct servo; struct servo;
/**
* Defines the available servo cores
*/
enum servo_type {
CLOCK_SERVO_PI,
};
/** /**
* Defines the caller visible states of a clock servo. * Defines the caller visible states of a clock servo.
*/ */
@ -47,7 +54,7 @@ enum servo_state {
/** /**
* Create a new instance of a clock servo. * 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 fadj The clock's current adjustment in parts per billion.
* @param max_ppb The absolute maxinum adjustment allowed by the clock * @param max_ppb The absolute maxinum adjustment allowed by the clock
* in parts per billion. The clock servo will clamp its * 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. * and the servo should use more aggressive filtering.
* @return A pointer to a new servo on success, NULL otherwise. * @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. * Destroy an instance of a clock servo.