Commit 3fc858d2 authored by Alessandro Rubini's avatar Alessandro Rubini

servo: trivial fix: rename of a field

This renames "ofst_first_updated" (wrongly a runtime option) into
"t1_t2_valid" as a servo field. This makes thing more readable and
is a fix in that it allows more than one servo to coexist in the future.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 4741d553
......@@ -26,7 +26,6 @@ struct pp_runtime_opts {
/* ethernet_mode:1, -- moved to ppsi, is no more global */
/* e2e_mode:1, -- no more: we only support e2e */
/* gptp_mode:1, -- no more: peer-to-peer unsupported */
ofst_first_updated:1,
no_rst_clk:1;
Integer16 ap, ai;
Integer16 s;
......@@ -105,6 +104,7 @@ struct pp_servo {
Integer32 obs_drift;
struct pp_owd_fltr owd_fltr;
struct pp_ofm_fltr ofm_fltr;
int t1_t2_valid; /* set at sync/follow-up time */
};
/*
......
......@@ -28,7 +28,6 @@ struct pp_runtime_opts default_rt_opts = {
.ap = PP_DEFAULT_AP,
.ai = PP_DEFAULT_AI,
.s = PP_DEFAULT_DELAY_S,
.ofst_first_updated = 0, /* FIXME: is it a option or a state var? */
.announce_intvl = PP_DEFAULT_ANNOUNCE_INTERVAL,
.sync_intvl = PP_DEFAULT_SYNC_INTERVAL,
.prio1 = PP_DEFAULT_PRIORITY1,
......
......@@ -54,7 +54,7 @@ static int __pp_servo_got_sync(struct pp_instance *ppi)
if (m_to_s_dly.seconds) {
pp_diag(ppi, servo, 1, "%s aborted, delay greater "
"than 1 second\n", __func__);
return -1;
return 0; /* not good */
}
if (m_to_s_dly.nanoseconds > OPTS(ppi)->max_dly) {
pp_diag(ppi, servo, 1, "%s aborted, delay %d greater "
......@@ -62,7 +62,7 @@ static int __pp_servo_got_sync(struct pp_instance *ppi)
__func__,
(int)m_to_s_dly.nanoseconds,
(int)OPTS(ppi)->max_dly);
return -1;
return 0; /* not good */
}
}
......@@ -94,7 +94,7 @@ static int __pp_servo_got_sync(struct pp_instance *ppi)
if (DSCUR(ppi)->offsetFromMaster.seconds) {
pp_diag(ppi, servo, 1, "%s aborted, offset greater "
"than 1 second\n", __func__);
return -1;
return 0; /* not good */
}
if ((DSCUR(ppi)->offsetFromMaster.nanoseconds) >
......@@ -104,7 +104,7 @@ static int __pp_servo_got_sync(struct pp_instance *ppi)
__func__,
(int)DSCUR(ppi)->offsetFromMaster.nanoseconds,
(int)OPTS(ppi)->max_rst);
return -1;
return 0; /* not good */
}
}
......@@ -129,7 +129,7 @@ adjust:
ppi->t_ops->adjust_offset(ppi, -adj);
}
}
return 0;
return 1; /* ok */
}
/* the PI controller */
......@@ -156,7 +156,7 @@ adjust:
else
ppi->t_ops->adjust_offset(ppi, -adj);
}
return 0;
return 1; /* ok */
}
/* Called by slave and uncalib when we have t1 and t2 */
......@@ -164,13 +164,12 @@ void pp_servo_got_sync(struct pp_instance *ppi)
{
char s[24];
if (__pp_servo_got_sync(ppi)) { /* error: message already reported */
OPTS(ppi)->ofst_first_updated = 0;
SRV(ppi)->t1_t2_valid = __pp_servo_got_sync(ppi);
if (!SRV(ppi)->t1_t2_valid) {
/* error: message already reported */
return;
}
OPTS(ppi)->ofst_first_updated = 1;
/* Ok: print data */
format_TimeInternal(s, &SRV(ppi)->m_to_s_dly);
pp_diag(ppi, servo, 2, "Raw offset from master: %s\n", s);
......@@ -192,7 +191,7 @@ static void pp_update_delay(struct pp_instance *ppi,
struct pp_owd_fltr *owd_fltr = &SRV(ppi)->owd_fltr;
int s;
if (!OPTS(ppi)->ofst_first_updated)
if (!SRV(ppi)->t1_t2_valid)
return;
/* calc 'slave to master' delay */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment