# HG changeset patch # User Dave Page # Date 1387221510 18000 # Node ID 9b36a16271e6e4ac4f2dbba728459a85c4dc5584 # Parent 1a969896d52eb64fdf6b0c706f039d3cb04efede Fix spurious FoE write timeout diff -r 1a969896d52e -r 9b36a16271e6 master/fsm_foe.c --- a/master/fsm_foe.c Fri Feb 20 16:06:23 2015 +0100 +++ b/master/fsm_foe.c Mon Dec 16 14:18:30 2013 -0500 @@ -42,9 +42,10 @@ /*****************************************************************************/ -/** Maximum time in ms to wait for responses when reading out the dictionary. - */ -#define EC_FSM_FOE_TIMEOUT 3000 +/** Maximum time in jiffies to wait for responses when reading out the + * dictionary. + */ +#define EC_FSM_FOE_TIMEOUT_JIFFIES (3 * HZ) /** Size of the FoE header. */ @@ -365,9 +366,8 @@ if (!ec_slave_mbox_check(fsm->datagram)) { // slave did not put anything in the mailbox yet - unsigned long diff_ms = (fsm->datagram->jiffies_received - - fsm->jiffies_start) * 1000 / HZ; - if (diff_ms >= EC_FSM_FOE_TIMEOUT) { + if (time_after(datagram->jiffies_received, + fsm->jiffies_start + EC_FSM_FOE_TIMEOUT_JIFFIES)) { ec_foe_set_tx_error(fsm, FOE_TIMEOUT_ERROR); EC_SLAVE_ERR(slave, "Timeout while waiting for ack response.\n"); return; @@ -704,9 +704,8 @@ } if (!ec_slave_mbox_check(fsm->datagram)) { - unsigned long diff_ms = (fsm->datagram->jiffies_received - - fsm->jiffies_start) * 1000 / HZ; - if (diff_ms >= EC_FSM_FOE_TIMEOUT) { + if (time_after(datagram->jiffies_received, + fsm->jiffies_start + EC_FSM_FOE_TIMEOUT_JIFFIES)) { ec_foe_set_tx_error(fsm, FOE_TIMEOUT_ERROR); EC_SLAVE_ERR(slave, "Timeout while waiting for ack response.\n"); return;