clock: store the configuration in the clock data structure.

This will help us to simplify the passing of parameters between the main
program. clock, and ports.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2015-08-10 20:05:37 +02:00
parent ae09c1c4c0
commit 1579b7893b
3 changed files with 13 additions and 7 deletions

View File

@ -73,6 +73,7 @@ struct clock_subscriber {
}; };
struct clock { struct clock {
struct config *config;
clockid_t clkid; clockid_t clkid;
struct servo *servo; struct servo *servo;
enum servo_type servo_type; enum servo_type servo_type;
@ -792,9 +793,10 @@ static void clock_remove_port(struct clock *c, struct port *p)
port_close(p); port_close(p);
} }
struct clock *clock_create(int phc_index, struct interfaces_head *ifaces, struct clock *clock_create(struct config *config, int phc_index,
enum timestamp_type timestamping, struct default_ds *dds, struct interfaces_head *ifaces,
enum servo_type servo) enum timestamp_type timestamping,
struct default_ds *dds, enum servo_type servo)
{ {
int fadj = 0, max_adj = 0, sw_ts = timestamping == TS_SOFTWARE ? 1 : 0; int fadj = 0, max_adj = 0, sw_ts = timestamping == TS_SOFTWARE ? 1 : 0;
struct clock *c = &the_clock; struct clock *c = &the_clock;
@ -814,6 +816,7 @@ struct clock *clock_create(int phc_index, struct interfaces_head *ifaces,
udsif->transport = TRANS_UDS; udsif->transport = TRANS_UDS;
udsif->delay_filter_length = 1; udsif->delay_filter_length = 1;
c->config = config;
c->free_running = dds->free_running; c->free_running = dds->free_running;
c->freq_est_interval = dds->freq_est_interval; c->freq_est_interval = dds->freq_est_interval;
c->grand_master_capable = dds->grand_master_capable; c->grand_master_capable = dds->grand_master_capable;

View File

@ -61,6 +61,7 @@ UInteger8 clock_class(struct clock *c);
* Create a clock instance. There can only be one clock in any system, * Create a clock instance. There can only be one clock in any system,
* so subsequent calls will destroy the previous clock instance. * so subsequent calls will destroy the previous clock instance.
* *
* @param config Pointer to the configuration database.
* @param phc_index PTP hardware clock device to use. * @param phc_index PTP hardware clock device to use.
* Pass -1 to select CLOCK_REALTIME. * Pass -1 to select CLOCK_REALTIME.
* @param ifaces A queue of network interfaces. * @param ifaces A queue of network interfaces.
@ -69,9 +70,10 @@ UInteger8 clock_class(struct clock *c);
* @param servo The servo that this clock will use. * @param servo The servo that this clock will use.
* @return A pointer to the single global clock instance. * @return A pointer to the single global clock instance.
*/ */
struct clock *clock_create(int phc_index, struct interfaces_head *ifaces, struct clock *clock_create(struct config *config, int phc_index,
enum timestamp_type timestamping, struct default_ds *dds, struct interfaces_head *ifaces,
enum servo_type servo); enum timestamp_type timestamping,
struct default_ds *dds, enum servo_type servo);
/** /**
* Obtains a clock's default data set. * Obtains a clock's default data set.

View File

@ -377,7 +377,8 @@ int main(int argc, char *argv[])
return -1; return -1;
} }
clock = clock_create(phc_index, &cfg_settings.interfaces, clock = clock_create(&cfg_settings,
phc_index, &cfg_settings.interfaces,
*timestamping, &cfg_settings.dds, *timestamping, &cfg_settings.dds,
cfg_settings.clock_servo); cfg_settings.clock_servo);
if (!clock) { if (!clock) {