Skip to content

Commit

Permalink
phc2sys: Simplify the main loop.
Browse files Browse the repository at this point in the history
Now that the PMC agent update method polls for port state notifications,
there is no need to call run_pmc_events().

Previously the 'subscriptions' flag shaped the program flow according to
whether auto-configuration or manual mode was in effect.  But now the
PMC agent tracks this difference internally, resulting in two parallel
sets of bookkeeping.

Remove the superfluous logic.

Signed-off-by: Richard Cochran <[email protected]>
  • Loading branch information
richardcochran committed Dec 6, 2020
1 parent c4a5eef commit f7ff879
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions phc2sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ static int update_needed(struct clock *c)
return 0;
}

static int do_loop(struct phc2sys_private *priv, int subscriptions)
static int do_loop(struct phc2sys_private *priv)
{
struct timespec interval;
struct clock *clock;
Expand All @@ -716,18 +716,14 @@ static int do_loop(struct phc2sys_private *priv, int subscriptions)
if (pmc_agent_update(priv->agent) < 0) {
continue;
}

if (subscriptions) {
run_pmc_events(priv->agent);
if (priv->state_changed) {
/* force getting offset, as it may have
* changed after the port state change */
if (pmc_agent_query_utc_offset(priv->agent, 1000)) {
pr_err("failed to get UTC offset");
continue;
}
reconfigure(priv);
if (priv->state_changed) {
/* force getting offset, as it may have
* changed after the port state change */
if (pmc_agent_query_utc_offset(priv->agent, 1000)) {
pr_err("failed to get UTC offset");
continue;
}
reconfigure(priv);
}
if (!priv->master)
continue;
Expand Down Expand Up @@ -1317,7 +1313,7 @@ int main(int argc, char *argv[])
goto end;
if (auto_init_ports(&priv, rt) < 0)
goto end;
r = do_loop(&priv, 1);
r = do_loop(&priv);
goto end;
}

Expand Down Expand Up @@ -1367,7 +1363,7 @@ int main(int argc, char *argv[])
servo_sync_interval(dst->servo, 1.0);
r = do_pps_loop(&priv, dst, pps_fd);
} else {
r = do_loop(&priv, 0);
r = do_loop(&priv);
}

end:
Expand Down

0 comments on commit f7ff879

Please sign in to comment.