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 <richardcochran@gmail.com>
master
Richard Cochran 2013-02-09 10:45:30 +01:00
parent 3136e3e46c
commit 1ce90fe160
6 changed files with 7 additions and 9 deletions

View File

@ -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();

View File

@ -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.

View File

@ -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;

View File

@ -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);

1
ds.h
View File

@ -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;
};

View File

@ -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;