Skip to content

Commit

Permalink
clock: store the configuration in the clock data structure.
Browse files Browse the repository at this point in the history
This will help us to simplify the passing of parameters between the main
program. clock, and ports.

Signed-off-by: Richard Cochran <[email protected]>
  • Loading branch information
richardcochran committed Aug 16, 2015
1 parent ae09c1c commit 1579b78
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
9 changes: 6 additions & 3 deletions clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ struct clock_subscriber {
};

struct clock {
struct config *config;
clockid_t clkid;
struct servo *servo;
enum servo_type servo_type;
Expand Down Expand Up @@ -792,9 +793,10 @@ static void clock_remove_port(struct clock *c, struct port *p)
port_close(p);
}

struct clock *clock_create(int phc_index, struct interfaces_head *ifaces,
enum timestamp_type timestamping, struct default_ds *dds,
enum servo_type servo)
struct clock *clock_create(struct config *config, int phc_index,
struct interfaces_head *ifaces,
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;
struct clock *c = &the_clock;
Expand All @@ -814,6 +816,7 @@ struct clock *clock_create(int phc_index, struct interfaces_head *ifaces,
udsif->transport = TRANS_UDS;
udsif->delay_filter_length = 1;

c->config = config;
c->free_running = dds->free_running;
c->freq_est_interval = dds->freq_est_interval;
c->grand_master_capable = dds->grand_master_capable;
Expand Down
8 changes: 5 additions & 3 deletions clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ UInteger8 clock_class(struct clock *c);
* Create a clock instance. There can only be one clock in any system,
* 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.
* Pass -1 to select CLOCK_REALTIME.
* @param ifaces A queue of network interfaces.
Expand All @@ -69,9 +70,10 @@ UInteger8 clock_class(struct clock *c);
* @param servo The servo that this clock will use.
* @return A pointer to the single global clock instance.
*/
struct clock *clock_create(int phc_index, struct interfaces_head *ifaces,
enum timestamp_type timestamping, struct default_ds *dds,
enum servo_type servo);
struct clock *clock_create(struct config *config, int phc_index,
struct interfaces_head *ifaces,
enum timestamp_type timestamping,
struct default_ds *dds, enum servo_type servo);

/**
* Obtains a clock's default data set.
Expand Down
3 changes: 2 additions & 1 deletion ptp4l.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ int main(int argc, char *argv[])
return -1;
}

clock = clock_create(phc_index, &cfg_settings.interfaces,
clock = clock_create(&cfg_settings,
phc_index, &cfg_settings.interfaces,
*timestamping, &cfg_settings.dds,
cfg_settings.clock_servo);
if (!clock) {
Expand Down

0 comments on commit 1579b78

Please sign in to comment.