This will allow removing the code that passes configuration options via
global variables.

Signed-off-by: Richard Cochran <richardcoch...@gmail.com>
---
 clock.c   | 4 ++--
 phc2sys.c | 3 ++-
 servo.c   | 3 ++-
 servo.h   | 5 ++++-
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/clock.c b/clock.c
index a47e1e9..8a5ef05 100644
--- a/clock.c
+++ b/clock.c
@@ -866,7 +866,7 @@ struct clock *clock_create(struct config *config, int 
phc_index,
                   the actual frequency of the clock. */
                clockadj_set_freq(c->clkid, fadj);
        }
-       c->servo = servo_create(servo, -fadj, max_adj, sw_ts);
+       c->servo = servo_create(c->config, servo, -fadj, max_adj, sw_ts);
        if (!c->servo) {
                pr_err("Failed to create clock servo");
                return NULL;
@@ -1356,7 +1356,7 @@ int clock_switch_phc(struct clock *c, int phc_index)
        }
        fadj = (int) clockadj_get_freq(clkid);
        clockadj_set_freq(clkid, fadj);
-       servo = servo_create(c->servo_type, -fadj, max_adj, 0);
+       servo = servo_create(c->config, c->servo_type, -fadj, max_adj, 0);
        if (!servo) {
                pr_err("Switching PHC, failed to create clock servo");
                phc_close(clkid);
diff --git a/phc2sys.c b/phc2sys.c
index 92af7ad..45ae363 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -224,7 +224,8 @@ static struct clock *clock_add(struct node *node, char 
*device)
                }
        }
 
-       c->servo = servo_create(node->servo_type, -ppb, max_ppb, 0);
+       c->servo = servo_create(&phc2sys_config, node->servo_type,
+                               -ppb, max_ppb, 0);
        servo_sync_interval(c->servo, node->phc_interval);
 
        if (clkid != CLOCK_REALTIME)
diff --git a/servo.c b/servo.c
index b936a85..aa71b21 100644
--- a/servo.c
+++ b/servo.c
@@ -30,7 +30,8 @@ double servo_step_threshold = 0.0;
 double servo_first_step_threshold = 0.00002; /* 20 microseconds */
 int servo_max_frequency = 900000000;
 
-struct servo *servo_create(enum servo_type type, int fadj, int max_ppb, int 
sw_ts)
+struct servo *servo_create(struct config *cfg, enum servo_type type,
+                          int fadj, int max_ppb, int sw_ts)
 {
        struct servo *servo;
 
diff --git a/servo.h b/servo.h
index 0a182a4..cc0b098 100644
--- a/servo.h
+++ b/servo.h
@@ -22,6 +22,8 @@
 
 #include <stdint.h>
 
+struct config;
+
 /**
  * When set to a non-zero value, this variable controls the maximum allowed
  * offset before a clock jump occurs instead of the default clock-slewing
@@ -92,7 +94,8 @@ 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(enum servo_type type, int fadj, int max_ppb, int 
sw_ts);
+struct servo *servo_create(struct config *cfg, enum servo_type type,
+                          int fadj, int max_ppb, int sw_ts);
 
 /**
  * Destroy an instance of a clock servo.
-- 
2.1.4


------------------------------------------------------------------------------
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to