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
parent
a0fc92957f
commit
d67892abd7
2
clock.c
2
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;
|
||||
|
|
4
servo.c
4
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;
|
||||
|
|
11
servo.h
11
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.
|
||||
|
|
Loading…
Reference in New Issue