Skip to content

Commit

Permalink
Reduce the arguments to clock_create.
Browse files Browse the repository at this point in the history
New clock options should go into 'struct default_ds' so that we can avoid
growing clock_create indefinitely.

Signed-off-by: Richard Cochran <[email protected]>
  • Loading branch information
richardcochran committed Feb 9, 2013
1 parent 3136e3e commit 1ce90fe
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions ds.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
5 changes: 2 additions & 3 deletions ptp4l.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -99,7 +100,6 @@ static struct config cfg_settings = {
.print_level = LOG_INFO,
.use_syslog = 1,
.verbose = 0,
.summary_interval = 0,

.cfg_ignore = 0,
};
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1ce90fe

Please sign in to comment.