From 1ce90fe1603a2db9cdc11cf381574f4900e4bdd9 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sat, 9 Feb 2013 10:45:30 +0100 Subject: [PATCH] Reduce the arguments to clock_create. New clock options should go into 'struct default_ds' so that we can avoid growing clock_create indefinitely. Signed-off-by: Richard Cochran --- clock.c | 4 ++-- clock.h | 3 +-- config.c | 2 +- config.h | 1 - ds.h | 1 + ptp4l.c | 5 ++--- 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/clock.c b/clock.c index 9b3283f..f5836fd 100644 --- a/clock.c +++ b/clock.c @@ -484,7 +484,7 @@ UInteger8 clock_class(struct clock *c) struct clock *clock_create(int phc_index, struct interface *iface, int count, enum timestamp_type timestamping, struct default_ds *dds, - enum servo_type servo, int stats_interval) + enum servo_type servo) { int i, fadj = 0, max_adj = 0.0, sw_ts = timestamping == TS_SOFTWARE ? 1 : 0; struct clock *c = &the_clock; @@ -537,7 +537,7 @@ struct clock *clock_create(int phc_index, struct interface *iface, int count, pr_err("Failed to create moving average"); return NULL; } - c->stats_interval = stats_interval; + c->stats_interval = dds->stats_interval; c->stats.offset = stats_create(); c->stats.freq = stats_create(); c->stats.delay = stats_create(); diff --git a/clock.h b/clock.h index 6bc98cd..581fa14 100644 --- a/clock.h +++ b/clock.h @@ -67,12 +67,11 @@ UInteger8 clock_class(struct clock *c); * @param timestamping The timestamping mode for this clock. * @param dds A pointer to a default data set for the clock. * @param servo The servo that this clock will use. - * @param stats_interval Interval in which are printed clock statistics. * @return A pointer to the single global clock instance. */ struct clock *clock_create(int phc_index, struct interface *iface, int count, enum timestamp_type timestamping, struct default_ds *dds, - enum servo_type servo, int stats_interval); + enum servo_type servo); /** * Obtains a clock's default data set. diff --git a/config.c b/config.c index d0bbd63..dd96fc1 100644 --- a/config.c +++ b/config.c @@ -381,7 +381,7 @@ static enum parser_result parse_global_setting(const char *option, } else if (!strcmp(option, "summary_interval")) { if (1 != sscanf(value, "%d", &val)) return BAD_VALUE; - cfg->summary_interval = val; + cfg->dds.stats_interval = val; } else return NOT_PARSED; diff --git a/config.h b/config.h index 3af193c..497d683 100644 --- a/config.h +++ b/config.h @@ -76,7 +76,6 @@ struct config { int print_level; int use_syslog; int verbose; - int summary_interval; }; int config_read(char *name, struct config *cfg); diff --git a/ds.h b/ds.h index 06b22f4..06cb30a 100644 --- a/ds.h +++ b/ds.h @@ -51,6 +51,7 @@ struct default_ds { struct defaultDS dds; int free_running; int freq_est_interval; /*log seconds*/ + int stats_interval; /*log seconds*/ struct clock_description clock_desc; }; diff --git a/ptp4l.c b/ptp4l.c index 2a8eeb0..fc6d0df 100644 --- a/ptp4l.c +++ b/ptp4l.c @@ -52,6 +52,7 @@ static struct config cfg_settings = { }, .free_running = 0, .freq_est_interval = 1, + .stats_interval = 0, .clock_desc = { .productDescription = { .max_symbols = 64, @@ -99,7 +100,6 @@ static struct config cfg_settings = { .print_level = LOG_INFO, .use_syslog = 1, .verbose = 0, - .summary_interval = 0, .cfg_ignore = 0, }; @@ -352,8 +352,7 @@ int main(int argc, char *argv[]) clock = clock_create(phc_index, iface, cfg_settings.nports, *timestamping, &cfg_settings.dds, - cfg_settings.clock_servo, - cfg_settings.summary_interval); + cfg_settings.clock_servo); if (!clock) { fprintf(stderr, "failed to create a clock\n"); return -1;