Commit 37a05faf authored by Alessandro Rubini's avatar Alessandro Rubini

wr-servo: prevent wrong numbers when mu is negative

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent c92b4290
......@@ -282,6 +282,11 @@ int wr_servo_update(struct pp_instance *ppi)
big_delta_fix = s->delta_tx_m + s->delta_tx_s
+ s->delta_rx_m + s->delta_rx_s;
if ((signed)s->picos_mu < (signed)big_delta_fix) {
/* avoid negatives in calculations */
s->picos_mu = big_delta_fix;
}
delay_ms_fix = (((int64_t)(s->picos_mu - big_delta_fix) * (int64_t) s->fiber_fix_alpha) >> FIX_ALPHA_FRACBITS)
+ ((s->picos_mu - big_delta_fix) >> 1)
+ s->delta_tx_m + s->delta_rx_s + ph_adjust;
......
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