Minor: Fixed line wraps and spacing.
--- a/master/datagram.h Mon Aug 01 16:53:21 2011 +0200
+++ b/master/datagram.h Mon Aug 01 17:02:45 2011 +0200
@@ -95,7 +95,8 @@
ec_origin_t data_origin; /**< Origin of the \a data memory. */
size_t mem_size; /**< Datagram \a data memory size. */
size_t data_size; /**< Size of the data in \a data. */
- ec_domain_t *domain; /**< Owning domain (may be null for non-domain datagrams) */
+ ec_domain_t *domain; /**< Owning domain (may be null for non-domain
+ datagrams) */
uint8_t index; /**< Index (set by master). */
uint16_t working_counter; /**< Working counter. */
ec_datagram_state_t state; /**< State. */
--- a/master/ethernet.c Mon Aug 01 16:53:21 2011 +0200
+++ b/master/ethernet.c Mon Aug 01 17:02:45 2011 +0200
@@ -326,9 +326,10 @@
// if the datagram was not sent, or is not yet received, skip this cycle
if (eoe->queue_datagram ||
- ec_mbox_is_datagram_state(&eoe->mbox,EC_DATAGRAM_QUEUED) ||
- ec_mbox_is_datagram_state(&eoe->mbox,EC_DATAGRAM_SENT))
- return;
+ ec_mbox_is_datagram_state(&eoe->mbox, EC_DATAGRAM_QUEUED) ||
+ ec_mbox_is_datagram_state(&eoe->mbox, EC_DATAGRAM_SENT)) {
+ return;
+ }
// call state function
eoe->state(eoe);
@@ -412,7 +413,7 @@
*/
void ec_eoe_state_rx_check(ec_eoe_t *eoe /**< EoE handler */)
{
- if (!ec_mbox_is_datagram_state(&eoe->mbox,EC_DATAGRAM_RECEIVED)) {
+ if (!ec_mbox_is_datagram_state(&eoe->mbox, EC_DATAGRAM_RECEIVED)) {
eoe->stats.rx_errors++;
#if EOE_DEBUG_LEVEL >= 1
EC_SLAVE_WARN(eoe->slave, "Failed to receive mbox"
@@ -451,7 +452,7 @@
unsigned int i;
#endif
- if (!ec_mbox_is_datagram_state(&eoe->mbox,EC_DATAGRAM_RECEIVED)) {
+ if (!ec_mbox_is_datagram_state(&eoe->mbox, EC_DATAGRAM_RECEIVED)) {
eoe->stats.rx_errors++;
#if EOE_DEBUG_LEVEL >= 1
EC_SLAVE_WARN(eoe->slave, "Failed to receive mbox"
@@ -688,7 +689,7 @@
*/
void ec_eoe_state_tx_sent(ec_eoe_t *eoe /**< EoE handler */)
{
- if (!ec_mbox_is_datagram_state(&eoe->mbox,EC_DATAGRAM_RECEIVED)) {
+ if (!ec_mbox_is_datagram_state(&eoe->mbox, EC_DATAGRAM_RECEIVED)) {
if (eoe->tries) {
eoe->tries--; // try again
eoe->queue_datagram = 1;
@@ -704,7 +705,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(&eoe->mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(&eoe->mbox, 1)) {
if (eoe->tries) {
eoe->tries--; // try again
eoe->queue_datagram = 1;
--- a/master/fsm_coe.c Mon Aug 01 16:53:21 2011 +0200
+++ b/master/fsm_coe.c Mon Aug 01 17:02:45 2011 +0200
@@ -332,10 +332,12 @@
ec_datagram_t *datagram = mbox->datagram;
ec_slave_t *slave = fsm->slave;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--) {
return; // FIXME: request again?
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ }
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE dictionary"
" request datagram: ");
@@ -343,7 +345,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Reception of CoE dictionary request failed: ");
ec_datagram_print_wc_error(datagram);
@@ -369,19 +371,21 @@
ec_datagram_t *datagram = mbox->datagram;
ec_slave_t *slave = fsm->slave;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
- return;
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--) {
+ return;
+ }
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE mailbox check datagram: ");
ec_datagram_print_state(datagram);
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
- fsm->state = ec_fsm_coe_error;
- EC_SLAVE_ERR(slave,"Reception of CoE mailbox check"
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
+ fsm->state = ec_fsm_coe_error;
+ EC_SLAVE_ERR(slave, "Reception of CoE mailbox check"
" datagram failed: ");
ec_datagram_print_wc_error(datagram);
return;
@@ -428,10 +432,12 @@
bool first_segment;
size_t index_list_offset;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--) {
return; // FIXME: request again?
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ }
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE dictionary"
" response datagram: ");
@@ -439,7 +445,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Reception of CoE dictionary response failed: ");
ec_datagram_print_wc_error(datagram);
@@ -583,10 +589,11 @@
ec_datagram_t *datagram = mbox->datagram;
ec_slave_t *slave = fsm->slave;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--)
return; // FIXME: check for response first?
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE SDO"
" description request datagram: ");
@@ -594,7 +601,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Reception of CoE SDO description"
" request failed: ");
@@ -621,17 +628,19 @@
ec_datagram_t *datagram = mbox->datagram;
ec_slave_t *slave = fsm->slave;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
- return;
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--) {
+ return;
+ }
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE mailbox check datagram: ");
ec_datagram_print_state(datagram);
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Reception of CoE mailbox check"
" datagram failed: ");
@@ -678,10 +687,12 @@
uint8_t *data, mbox_prot;
size_t rec_size, name_size;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--) {
return; // FIXME: request again?
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ }
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE SDO description"
" response datagram: ");
@@ -689,7 +700,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Reception of CoE SDO description"
" response failed: ");
@@ -820,10 +831,12 @@
ec_datagram_t *datagram = mbox->datagram;
ec_slave_t *slave = fsm->slave;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--) {
return; // FIXME: check for response first?
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ }
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE SDO entry"
" request datagram: ");
@@ -831,7 +844,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Reception of CoE SDO entry request failed: ");
ec_datagram_print_wc_error(datagram);
@@ -858,17 +871,19 @@
ec_datagram_t *datagram = mbox->datagram;
ec_slave_t *slave = fsm->slave;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
- return;
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--) {
+ return;
+ }
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE mailbox check datagram: ");
ec_datagram_print_state(datagram);
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Reception of CoE mailbox check"
" datagram failed: ");
@@ -917,10 +932,12 @@
ec_sdo_entry_t *entry;
u16 word;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--) {
return; // FIXME: request again?
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ }
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE SDO"
" description response datagram: ");
@@ -928,7 +945,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Reception of CoE SDO description"
" response failed: ");
@@ -1227,10 +1244,12 @@
ec_slave_t *slave = fsm->slave;
unsigned long diff_ms;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--) {
return; // FIXME: check for response first?
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ }
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE download"
@@ -1241,8 +1260,8 @@
diff_ms = (jiffies - fsm->request->jiffies_sent) * 1000 / HZ;
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
- if (ec_mbox_is_datagram_wc(mbox,0)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
+ if (ec_mbox_is_datagram_wc(mbox, 0)) {
if (diff_ms < fsm->request->response_timeout) {
#if DEBUG_RETRIES
EC_SLAVE_DBG(slave, 1, "Slave did not respond to SDO"
@@ -1286,10 +1305,12 @@
ec_datagram_t *datagram = mbox->datagram;
ec_slave_t *slave = fsm->slave;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
- return;
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--) {
+ return;
+ }
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE mailbox check"
@@ -1298,7 +1319,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
fsm->request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Reception of CoE mailbox check"
@@ -1412,10 +1433,12 @@
size_t rec_size;
ec_sdo_request_t *request = fsm->request;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--) {
return; // FIXME: request again?
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ }
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE download"
@@ -1424,7 +1447,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Reception of CoE download response failed: ");
@@ -1527,10 +1550,12 @@
ec_datagram_t *datagram = mbox->datagram;
ec_slave_t *slave = fsm->slave;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
- return;
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--) {
+ return;
+ }
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE mailbox check datagram: ");
@@ -1538,7 +1563,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
fsm->request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Reception of CoE mailbox segment check"
@@ -1587,10 +1612,12 @@
size_t rec_size;
ec_sdo_request_t *request = fsm->request;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--) {
return; // FIXME: request again?
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ }
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE download response"
@@ -1599,7 +1626,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Reception of CoE download response failed: ");
@@ -1758,10 +1785,12 @@
ec_slave_t *slave = fsm->slave;
unsigned long diff_ms;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--) {
return; // FIXME: check for response first?
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ }
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE upload request: ");
@@ -1771,8 +1800,8 @@
diff_ms = (jiffies - fsm->request->jiffies_sent) * 1000 / HZ;
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
- if (ec_mbox_is_datagram_wc(mbox,0)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
+ if (ec_mbox_is_datagram_wc(mbox, 0)) {
if (diff_ms < fsm->request->response_timeout) {
#if DEBUG_RETRIES
EC_SLAVE_DBG(slave, 1, "Slave did not respond to"
@@ -1818,10 +1847,12 @@
ec_datagram_t *datagram = mbox->datagram;
ec_slave_t *slave = fsm->slave;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
- return;
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--) {
+ return;
+ }
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE mailbox check datagram: ");
@@ -1829,7 +1860,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
fsm->request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Reception of CoE mailbox check"
@@ -1908,10 +1939,12 @@
unsigned int expedited, size_specified;
int ret;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--) {
return; // FIXME: request again?
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ }
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE upload response"
@@ -1920,7 +1953,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Reception of CoE upload response failed: ");
@@ -2101,10 +2134,12 @@
ec_datagram_t *datagram = mbox->datagram;
ec_slave_t *slave = fsm->slave;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--) {
return; // FIXME: check for response first?
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ }
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE upload segment"
@@ -2113,7 +2148,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
fsm->request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Reception of CoE upload segment"
@@ -2141,10 +2176,12 @@
ec_datagram_t *datagram = mbox->datagram;
ec_slave_t *slave = fsm->slave;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
- return;
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--) {
+ return;
+ }
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE mailbox check"
@@ -2153,7 +2190,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
fsm->request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Reception of CoE mailbox check datagram"
@@ -2202,10 +2239,12 @@
ec_sdo_request_t *request = fsm->request;
unsigned int last_segment;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT)
+ && fsm->retries--) {
return; // FIXME: request again?
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ }
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Failed to receive CoE upload segment"
@@ -2214,7 +2253,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Reception of CoE upload segment"
--- a/master/fsm_foe.c Mon Aug 01 16:53:21 2011 +0200
+++ b/master/fsm_foe.c Mon Aug 01 17:02:45 2011 +0200
@@ -207,7 +207,7 @@
}
data = ec_slave_mbox_prepare_send(fsm->slave,
- fsm->mbox,EC_MBOX_TYPE_FILEACCESS,
+ fsm->mbox, EC_MBOX_TYPE_FILEACCESS,
current_size + EC_FOE_HEADER_SIZE);
if (IS_ERR(data))
return -1;
@@ -316,14 +316,14 @@
printk("ec_fsm_foe_ack_check()\n");
#endif
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR);
EC_SLAVE_ERR(slave, "Failed to receive FoE mailbox check datagram: ");
ec_datagram_print_state(datagram);
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
// slave did not put anything in the mailbox yet
ec_foe_set_rx_error(fsm, FOE_WC_ERROR);
EC_SLAVE_ERR(slave, "Reception of FoE mailbox check datagram"
@@ -372,14 +372,14 @@
printk("ec_fsm_foe_ack_read()\n");
#endif
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR);
EC_SLAVE_ERR(slave, "Failed to receive FoE ack response datagram: ");
ec_datagram_print_state(datagram);
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
ec_foe_set_rx_error(fsm, FOE_WC_ERROR);
EC_SLAVE_ERR(slave, "Reception of FoE ack response failed: ");
ec_datagram_print_wc_error(datagram);
@@ -450,14 +450,14 @@
printk("ec_foe_state_sent_wrq()\n");
#endif
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR);
EC_SLAVE_ERR(slave, "Failed to send FoE WRQ: ");
ec_datagram_print_state(datagram);
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
// slave did not put anything in the mailbox yet
ec_foe_set_rx_error(fsm, FOE_WC_ERROR);
EC_SLAVE_ERR(slave, "Reception of FoE WRQ failed: ");
@@ -492,14 +492,14 @@
printk("ec_fsm_foe_state_data_sent()\n");
#endif
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
ec_foe_set_tx_error(fsm, FOE_RECEIVE_ERROR);
EC_SLAVE_ERR(slave, "Failed to receive FoE ack response datagram: ");
ec_datagram_print_state(datagram);
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
ec_foe_set_tx_error(fsm, FOE_WC_ERROR);
EC_SLAVE_ERR(slave, "Reception of FoE data send failed: ");
ec_datagram_print_wc_error(datagram);
@@ -580,14 +580,14 @@
printk("ec_foe_state_rrq_sent()\n");
#endif
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR);
EC_SLAVE_ERR(slave, "Failed to send FoE RRQ: ");
ec_datagram_print_state(datagram);
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
// slave did not put anything in the mailbox yet
ec_foe_set_rx_error(fsm, FOE_WC_ERROR);
EC_SLAVE_ERR(slave, "Reception of FoE RRQ failed: ");
@@ -670,14 +670,14 @@
printk("ec_fsm_foe_state_data_check()\n");
#endif
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR);
EC_SLAVE_ERR(slave, "Failed to send FoE DATA READ: ");
ec_datagram_print_state(datagram);
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
ec_foe_set_rx_error(fsm, FOE_WC_ERROR);
EC_SLAVE_ERR(slave, "Reception of FoE DATA READ: ");
ec_datagram_print_wc_error(datagram);
@@ -725,14 +725,14 @@
printk("ec_fsm_foe_state_data_read()\n");
#endif
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR);
EC_SLAVE_ERR(slave, "Failed to receive FoE DATA READ datagram: ");
ec_datagram_print_state(datagram);
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
ec_foe_set_rx_error(fsm, FOE_WC_ERROR);
EC_SLAVE_ERR(slave, "Reception of FoE DATA READ failed: ");
ec_datagram_print_wc_error(datagram);
@@ -846,14 +846,14 @@
printk("ec_foe_state_sent_ack()\n");
#endif
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR);
EC_SLAVE_ERR(slave, "Failed to send FoE ACK: ");
ec_datagram_print_state(datagram);
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
// slave did not put anything into the mailbox yet
ec_foe_set_rx_error(fsm, FOE_WC_ERROR);
EC_SLAVE_ERR(slave, "Reception of FoE ACK failed: ");
--- a/master/fsm_master.c Mon Aug 01 16:53:21 2011 +0200
+++ b/master/fsm_master.c Mon Aug 01 17:02:45 2011 +0200
@@ -134,11 +134,12 @@
ec_fsm_master_t *fsm /**< Master state machine. */
)
{
- if (ec_mbox_is_datagram_state(fsm->mbox,EC_DATAGRAM_QUEUED)
- || ec_mbox_is_datagram_state(fsm->mbox,EC_DATAGRAM_SENT)) {
+ if (ec_mbox_is_datagram_state(fsm->mbox, EC_DATAGRAM_QUEUED)
+ || ec_mbox_is_datagram_state(fsm->mbox, EC_DATAGRAM_SENT)) {
// datagram was not sent or received yet.
return 0;
}
+
fsm->state(fsm);
return 1;
}
@@ -391,7 +392,7 @@
"datagram size (%zu)!\n", request->length,
fsm->datagram->mem_size);
request->state = EC_INT_REQUEST_FAILURE;
- kref_put(&request->refcount,ec_master_reg_request_release);
+ kref_put(&request->refcount, ec_master_reg_request_release);
wake_up(&master->reg_queue);
continue;
}
@@ -994,7 +995,7 @@
correction =
(datagram->cycles_sent - slave->master->dc_cycles_app_start_time)
* 1000000LL;
- do_div(correction,cpu_khz);
+ do_div(correction, cpu_khz);
#else
correction =
(u64) ((datagram->jiffies_sent-slave->master->dc_jiffies_app_start_time) * 1000 / HZ)
@@ -1069,7 +1070,7 @@
if (!ec_fsm_sii_success(&fsm->fsm_sii)) {
EC_SLAVE_ERR(slave, "Failed to write SII data.\n");
request->state = EC_INT_REQUEST_FAILURE;
- kref_put(&request->refcount,ec_master_sii_write_request_release);
+ kref_put(&request->refcount, ec_master_sii_write_request_release);
wake_up(&master->sii_queue);
ec_fsm_master_restart(fsm);
return;
@@ -1098,7 +1099,7 @@
// TODO: Evaluate other SII contents!
request->state = EC_INT_REQUEST_SUCCESS;
- kref_put(&request->refcount,ec_master_sii_write_request_release);
+ kref_put(&request->refcount, ec_master_sii_write_request_release);
wake_up(&master->sii_queue);
// check for another SII write request
@@ -1192,7 +1193,7 @@
" request datagram: ");
ec_datagram_print_state(datagram);
request->state = EC_INT_REQUEST_FAILURE;
- kref_put(&request->refcount,ec_master_reg_request_release);
+ kref_put(&request->refcount, ec_master_reg_request_release);
wake_up(&master->reg_queue);
ec_fsm_master_restart(fsm);
return;
@@ -1207,7 +1208,7 @@
EC_MASTER_ERR(master, "Failed to allocate %zu bytes"
" of memory for register data.\n", request->length);
request->state = EC_INT_REQUEST_FAILURE;
- kref_put(&request->refcount,ec_master_reg_request_release);
+ kref_put(&request->refcount, ec_master_reg_request_release);
wake_up(&master->reg_queue);
ec_fsm_master_restart(fsm);
return;
@@ -1222,7 +1223,7 @@
EC_MASTER_ERR(master, "Register request failed.\n");
}
- kref_put(&request->refcount,ec_master_reg_request_release);
+ kref_put(&request->refcount, ec_master_reg_request_release);
wake_up(&master->reg_queue);
// check for another register request
@@ -1241,7 +1242,8 @@
{
ec_sii_write_request_t *request = container_of(ref, ec_sii_write_request_t, refcount);
if (request->slave)
- EC_SLAVE_DBG(request->slave, 1, "Releasing SII write request %p.\n",request);
+ EC_SLAVE_DBG(request->slave, 1, "Releasing SII write request %p.\n",
+ request);
kfree(request->words);
kfree(request);
}
@@ -1255,7 +1257,8 @@
{
ec_reg_request_t *request = container_of(ref, ec_reg_request_t, refcount);
if (request->slave)
- EC_SLAVE_DBG(request->slave, 1, "Releasing reg request %p.\n",request);
+ EC_SLAVE_DBG(request->slave, 1, "Releasing reg request %p.\n",
+ request);
if (request->data)
kfree(request->data);
kfree(request);
@@ -1270,7 +1273,8 @@
{
ec_master_sdo_request_t *request = container_of(ref, ec_master_sdo_request_t, refcount);
if (request->slave)
- EC_SLAVE_DBG(request->slave, 1, "Releasing SDO request %p.\n",request);
+ EC_SLAVE_DBG(request->slave, 1, "Releasing SDO request %p.\n",
+ request);
ec_sdo_request_clear(&request->req);
kfree(request);
}
@@ -1284,7 +1288,8 @@
{
ec_master_foe_request_t *request = container_of(ref, ec_master_foe_request_t, refcount);
if (request->slave)
- EC_SLAVE_DBG(request->slave, 1, "Releasing FoE request %p.\n",request);
+ EC_SLAVE_DBG(request->slave, 1, "Releasing FoE request %p.\n",
+ request);
ec_foe_request_clear(&request->req);
kfree(request);
}
@@ -1298,7 +1303,8 @@
{
ec_master_soe_request_t *request = container_of(ref, ec_master_soe_request_t, refcount);
if (request->slave)
- EC_SLAVE_DBG(request->slave, 1, "Releasing SoE request %p.\n",request);
+ EC_SLAVE_DBG(request->slave, 1, "Releasing SoE request %p.\n",
+ request);
ec_soe_request_clear(&request->req);
kfree(request);
}
--- a/master/fsm_master.h Mon Aug 01 16:53:21 2011 +0200
+++ b/master/fsm_master.h Mon Aug 01 17:02:45 2011 +0200
@@ -128,7 +128,7 @@
struct ec_fsm_master {
ec_master_t *master; /**< master the FSM runs on */
ec_datagram_t *datagram; /**< datagram used in the state machine */
- ec_mailbox_t* mbox; /**< mailbox used in the CoE state machine */
+ ec_mailbox_t *mbox; /**< mailbox used in the state machine */
unsigned int retries; /**< retries on datagram timeout. */
void (*state)(ec_fsm_master_t *); /**< master state function */
--- a/master/fsm_slave.c Mon Aug 01 16:53:21 2011 +0200
+++ b/master/fsm_slave.c Mon Aug 01 17:02:45 2011 +0200
@@ -101,8 +101,8 @@
ec_fsm_slave_t *fsm /**< Slave state machine. */
)
{
- if (ec_mbox_is_datagram_state(fsm->mbox,EC_DATAGRAM_QUEUED)
- || ec_mbox_is_datagram_state(fsm->mbox,EC_DATAGRAM_SENT)) {
+ if (ec_mbox_is_datagram_state(fsm->mbox, EC_DATAGRAM_QUEUED)
+ || ec_mbox_is_datagram_state(fsm->mbox, EC_DATAGRAM_SENT)) {
// datagram was not sent or received yet.
return 0;
}
--- a/master/fsm_soe.c Mon Aug 01 16:53:21 2011 +0200
+++ b/master/fsm_soe.c Mon Aug 01 17:02:45 2011 +0200
@@ -244,10 +244,10 @@
ec_slave_t *slave = fsm->slave;
unsigned long diff_ms;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
return; // FIXME: check for response first?
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->state = ec_fsm_soe_error;
EC_SLAVE_ERR(slave, "Failed to receive SoE read request: ");
ec_datagram_print_state(mbox->datagram);
@@ -257,8 +257,8 @@
diff_ms = (jiffies - fsm->request->jiffies_sent) * 1000 / HZ;
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
- if (ec_mbox_is_datagram_wc(mbox,0)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
+ if (ec_mbox_is_datagram_wc(mbox, 0)) {
if (diff_ms < EC_SOE_RESPONSE_TIMEOUT) {
// no response; send request datagram again
return;
@@ -287,10 +287,10 @@
ec_mailbox_t *mbox = fsm->mbox;
ec_slave_t *slave = fsm->slave;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
- return;
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
+ return;
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->state = ec_fsm_soe_error;
EC_SLAVE_ERR(slave, "Failed to receive SoE mailbox check datagram: ");
ec_datagram_print_state(mbox->datagram);
@@ -298,7 +298,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
fsm->state = ec_fsm_soe_error;
EC_SLAVE_ERR(slave, "Reception of SoE mailbox check"
" datagram failed: ");
@@ -343,10 +343,10 @@
size_t rec_size, data_size;
ec_soe_request_t *req = fsm->request;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
return; // FIXME: request again?
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->state = ec_fsm_soe_error;
EC_SLAVE_ERR(slave, "Failed to receive SoE read response datagram: ");
ec_datagram_print_state(mbox->datagram);
@@ -354,7 +354,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
fsm->state = ec_fsm_soe_error;
EC_SLAVE_ERR(slave, "Reception of SoE read response failed: ");
ec_datagram_print_wc_error(mbox->datagram);
@@ -543,10 +543,10 @@
ec_slave_t *slave = fsm->slave;
unsigned long diff_ms;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
return; // FIXME: check for response first?
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->state = ec_fsm_soe_error;
EC_SLAVE_ERR(slave, "Failed to receive SoE write request: ");
ec_datagram_print_state(mbox->datagram);
@@ -556,8 +556,8 @@
diff_ms = (jiffies - fsm->request->jiffies_sent) * 1000 / HZ;
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
- if (ec_mbox_is_datagram_wc(mbox,0)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
+ if (ec_mbox_is_datagram_wc(mbox, 0)) {
if (diff_ms < EC_SOE_RESPONSE_TIMEOUT) {
// no response; send request datagram again
return;
@@ -588,10 +588,10 @@
ec_slave_t *slave = fsm->slave;
ec_soe_request_t *req = fsm->request;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
- return;
-
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
+ return;
+
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->state = ec_fsm_soe_error;
EC_SLAVE_ERR(slave, "Failed to receive SoE write request datagram: ");
ec_datagram_print_state(mbox->datagram);
@@ -599,7 +599,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
fsm->state = ec_fsm_soe_error;
EC_SLAVE_ERR(slave, "Reception of SoE write request datagram: ");
ec_datagram_print_wc_error(mbox->datagram);
@@ -647,10 +647,10 @@
uint16_t idn;
size_t rec_size;
- if (ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
+ if (ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_TIMED_OUT) && fsm->retries--)
return; // FIXME: request again?
- if (!ec_mbox_is_datagram_state(mbox,EC_DATAGRAM_RECEIVED)) {
+ if (!ec_mbox_is_datagram_state(mbox, EC_DATAGRAM_RECEIVED)) {
fsm->state = ec_fsm_soe_error;
EC_SLAVE_ERR(slave, "Failed to receive SoE write"
" response datagram: ");
@@ -659,7 +659,7 @@
return;
}
- if (!ec_mbox_is_datagram_wc(mbox,1)) {
+ if (!ec_mbox_is_datagram_wc(mbox, 1)) {
fsm->state = ec_fsm_soe_error;
EC_SLAVE_ERR(slave, "Reception of SoE write response failed: ");
ec_datagram_print_wc_error(mbox->datagram);
--- a/master/mailbox.c Mon Aug 01 16:53:21 2011 +0200
+++ b/master/mailbox.c Mon Aug 01 17:02:45 2011 +0200
@@ -77,44 +77,41 @@
/*****************************************************************************/
-/**
- Queues the slave datagrams.
-*/
-
-void ec_slave_mbox_queue_datagrams(const ec_slave_t* slave, /** slave */
- ec_mailbox_t* mbox /** mailbox */
- )
+/** Queues the slave datagrams.
+ */
+void ec_slave_mbox_queue_datagrams(
+ const ec_slave_t *slave, /** slave */
+ ec_mailbox_t *mbox /** mailbox */
+ )
{
ec_master_queue_request_fsm_datagram(slave->master, mbox->datagram);
-#ifdef EC_REDUCE_MBOXFRAMESIZE
- if (mbox->end_datagram.type != EC_DATAGRAM_NONE)
- {
- ec_master_queue_request_fsm_datagram(slave->master, &mbox->end_datagram);
- }
-#endif
-}
-
-
-/*****************************************************************************/
-
-/**
- Queues the datagrams.
-*/
-
-void ec_master_mbox_queue_datagrams(ec_master_t* master, /** master */
- ec_mailbox_t* mbox /** mailbox */
- )
+
+#ifdef EC_REDUCE_MBOXFRAMESIZE
+ if (mbox->end_datagram.type != EC_DATAGRAM_NONE) {
+ ec_master_queue_request_fsm_datagram(slave->master,
+ &mbox->end_datagram);
+ }
+#endif
+}
+
+/*****************************************************************************/
+
+/** Queues the datagrams.
+ */
+void ec_master_mbox_queue_datagrams(
+ ec_master_t *master, /** master */
+ ec_mailbox_t *mbox /** mailbox */
+ )
{
ec_master_queue_fsm_datagram(master, mbox->datagram);
-#ifdef EC_REDUCE_MBOXFRAMESIZE
- if (mbox->end_datagram.type != EC_DATAGRAM_NONE)
- {
+
+#ifdef EC_REDUCE_MBOXFRAMESIZE
+ if (mbox->end_datagram.type != EC_DATAGRAM_NONE) {
ec_master_queue_fsm_datagram(master, &mbox->end_datagram);
}
#endif
}
-
/*****************************************************************************/
/**
--- a/master/mailbox.h Mon Aug 01 16:53:21 2011 +0200
+++ b/master/mailbox.h Mon Aug 01 17:02:45 2011 +0200
@@ -52,49 +52,59 @@
*/
struct ec_mailbox
{
- ec_datagram_t* datagram; /**< Datagram used for the mailbox content. */
+ ec_datagram_t *datagram; /**< Datagram used for the mailbox content. */
#ifdef EC_REDUCE_MBOXFRAMESIZE
- ec_datagram_t end_datagram; /**< Datagram used for writing the end byte to the mailbox. */
+ ec_datagram_t end_datagram; /**< Datagram used for writing the end byte to
+ the mailbox. */
#endif
};
typedef struct ec_mailbox ec_mailbox_t; /**< \see ec_mailbox. */
/*****************************************************************************/
-void ec_mbox_init(ec_mailbox_t *, ec_datagram_t*);
-void ec_mbox_clear(ec_mailbox_t*);
+void ec_mbox_init(ec_mailbox_t *, ec_datagram_t *);
+void ec_mbox_clear(ec_mailbox_t *);
+
/**
Checks the datagrams states.
*/
-static inline int ec_mbox_is_datagram_state(ec_mailbox_t*mbox,
- ec_datagram_state_t state) {
+static inline int ec_mbox_is_datagram_state(
+ ec_mailbox_t *mbox,
+ ec_datagram_state_t state
+ )
+{
return (mbox->datagram->state == state)
#ifdef EC_REDUCE_MBOXFRAMESIZE
- && (mbox->end_datagram.type == EC_DATAGRAM_NONE || mbox->end_datagram.state == state)
+ && (mbox->end_datagram.type == EC_DATAGRAM_NONE
+ || mbox->end_datagram.state == state)
#endif
- ;
+ ;
}
/**
Checks the datagrams working counter.
*/
-static inline int ec_mbox_is_datagram_wc(ec_mailbox_t*mbox,
- size_t wc) {
+static inline int ec_mbox_is_datagram_wc(
+ ec_mailbox_t *mbox,
+ size_t wc
+ )
+{
return (mbox->datagram->working_counter == wc)
#ifdef EC_REDUCE_MBOXFRAMESIZE
- && (mbox->end_datagram.type == EC_DATAGRAM_NONE || mbox->end_datagram.working_counter == wc)
+ && (mbox->end_datagram.type == EC_DATAGRAM_NONE
+ || mbox->end_datagram.working_counter == wc)
#endif
;
}
-void ec_slave_mbox_queue_datagrams(const ec_slave_t*,ec_mailbox_t*);
-void ec_master_mbox_queue_datagrams(ec_master_t*, ec_mailbox_t*);
-uint8_t *ec_slave_mbox_prepare_send(const ec_slave_t*,ec_mailbox_t *,
+void ec_slave_mbox_queue_datagrams(const ec_slave_t *, ec_mailbox_t *);
+void ec_master_mbox_queue_datagrams(ec_master_t *, ec_mailbox_t *);
+uint8_t *ec_slave_mbox_prepare_send(const ec_slave_t *, ec_mailbox_t *,
uint8_t, size_t);
-int ec_slave_mbox_prepare_check(const ec_slave_t*,ec_mailbox_t *);
-int ec_slave_mbox_check(ec_mailbox_t *);
-int ec_slave_mbox_prepare_fetch(const ec_slave_t*,ec_mailbox_t *);
-uint8_t *ec_slave_mbox_fetch(const ec_slave_t*,ec_mailbox_t *,
+int ec_slave_mbox_prepare_check(const ec_slave_t *, ec_mailbox_t *);
+int ec_slave_mbox_check(ec_mailbox_t *);
+int ec_slave_mbox_prepare_fetch(const ec_slave_t *, ec_mailbox_t *);
+uint8_t *ec_slave_mbox_fetch(const ec_slave_t *, ec_mailbox_t *,
uint8_t *, size_t *);
/*****************************************************************************/
--- a/master/master.c Mon Aug 01 16:53:21 2011 +0200
+++ b/master/master.c Mon Aug 01 17:02:45 2011 +0200
@@ -674,19 +674,18 @@
ec_datagram_t *datagram, *next;
size_t queue_size = 0;
- if (master->fsm_queue_lock_cb)
+ if (master->fsm_queue_lock_cb) {
master->fsm_queue_lock_cb(master->fsm_queue_locking_data);
+ }
+
if (ec_mutex_trylock(&master->fsm_queue_mutex) == 0) {
- if (master->fsm_queue_unlock_cb)
- master->fsm_queue_unlock_cb(master->fsm_queue_locking_data);
- return;
- }
+ goto unlock_cb;
+ }
+
if (list_empty(&master->fsm_datagram_queue)) {
- ec_mutex_unlock(&master->fsm_queue_mutex);
- if (master->fsm_queue_unlock_cb)
- master->fsm_queue_unlock_cb(master->fsm_queue_locking_data);
- return;
- }
+ goto unlock;
+ }
+
list_for_each_entry(datagram, &master->datagram_queue, queue) {
queue_size += datagram->data_size;
}
@@ -704,10 +703,9 @@
#ifdef EC_HAVE_CYCLES
datagram->cycles_sent = 0;
#endif
- datagram->jiffies_sent = 0;
+ datagram->jiffies_sent = 0; // FIXME why?
ec_master_queue_datagram(master, datagram);
- }
- else {
+ } else {
if (datagram->data_size > master->max_queue_size) {
list_del_init(&datagram->fsm_queue);
datagram->state = EC_DATAGRAM_ERROR;
@@ -754,9 +752,13 @@
}
}
}
+
+unlock:
ec_mutex_unlock(&master->fsm_queue_mutex);
- if (master->fsm_queue_unlock_cb)
+unlock_cb:
+ if (master->fsm_queue_unlock_cb) {
master->fsm_queue_unlock_cb(master->fsm_queue_locking_data);
+ }
}
/*****************************************************************************/
@@ -777,15 +779,16 @@
/*****************************************************************************/
-/** Places an request (SDO/FoE/SoE/EoE) fsm datagram in the sdo datagram queue.
+/** Places an request (SDO/FoE/SoE/EoE) fsm datagram in the sdo datagram
+ * queue.
*/
void ec_master_queue_request_fsm_datagram(
ec_master_t *master, /**< EtherCAT master */
ec_datagram_t *datagram /**< datagram */
)
{
- ec_master_queue_fsm_datagram(master,datagram);
- master->fsm.idle = 0; // pump the bus as fast as possible
+ ec_master_queue_fsm_datagram(master, datagram);
+ master->fsm.idle = 0; // pump the bus as fast as possible
}
/*****************************************************************************/
@@ -799,8 +802,9 @@
{
ec_datagram_t *queued_datagram;
- if (master->fsm_queue_lock_cb)
+ if (master->fsm_queue_lock_cb) {
master->fsm_queue_lock_cb(master->fsm_queue_locking_data);
+ }
ec_mutex_lock(&master->fsm_queue_mutex);
// check, if the datagram is already queued
@@ -808,10 +812,7 @@
fsm_queue) {
if (queued_datagram == datagram) {
datagram->state = EC_DATAGRAM_QUEUED;
- ec_mutex_unlock(&master->fsm_queue_mutex);
- if (master->fsm_queue_unlock_cb)
- master->fsm_queue_unlock_cb(master->fsm_queue_locking_data);
- return;
+ goto unlock;
}
}
@@ -825,11 +826,13 @@
#ifdef EC_HAVE_CYCLES
datagram->cycles_sent = get_cycles();
#endif
- datagram->jiffies_sent = jiffies;
-
+ datagram->jiffies_sent = jiffies; // FIXME why?
+
+unlock:
ec_mutex_unlock(&master->fsm_queue_mutex);
- if (master->fsm_queue_unlock_cb)
+ if (master->fsm_queue_unlock_cb) {
master->fsm_queue_unlock_cb(master->fsm_queue_locking_data);
+ }
}
/*****************************************************************************/
@@ -929,12 +932,14 @@
list_add_tail(&datagram->sent, &sent_datagrams);
datagram->index = master->datagram_index++;
- EC_MASTER_DBG(master, 2, "adding datagram %p i=0x%02X size=%zu\n",datagram,
- datagram->index,datagram_size);
+ EC_MASTER_DBG(master, 2, "Adding datagram %p i=0x%02X size=%zu\n",
+ datagram, datagram->index,datagram_size);
// set "datagram following" flag in previous frame
- if (follows_word)
- EC_WRITE_U16(follows_word, EC_READ_U16(follows_word) | 0x8000);
+ if (follows_word) {
+ EC_WRITE_U16(follows_word,
+ EC_READ_U16(follows_word) | 0x8000);
+ }
// EtherCAT datagram header
EC_WRITE_U8 (cur_data, datagram->type);
@@ -948,25 +953,35 @@
// EtherCAT datagram data
frame_datagram_data = cur_data;
if (datagram->domain) {
- unsigned int datagram_address = EC_READ_U32(datagram->address);
+ unsigned int datagram_address =
+ EC_READ_U32(datagram->address);
int i = 0;
uint8_t *domain_data = datagram->data;
- list_for_each_entry(domain_fmmu, &datagram->domain->fmmu_configs, list) {
+ list_for_each_entry(domain_fmmu,
+ &datagram->domain->fmmu_configs, list) {
if (domain_fmmu->dir == EC_DIR_OUTPUT ) {
- unsigned int frame_offset = domain_fmmu->logical_start_address-datagram_address;
- memcpy(frame_datagram_data+frame_offset, domain_data, domain_fmmu->data_size);
+ unsigned int frame_offset =
+ domain_fmmu->logical_start_address
+ - datagram_address;
+ memcpy(frame_datagram_data+frame_offset, domain_data,
+ domain_fmmu->data_size);
if (unlikely(master->debug_level > 1)) {
- EC_DBG("sending dg %p i=0x%02X fmmu %u fp=%u dp=%zu size=%u\n",
- datagram,datagram->index, i,frame_offset,domain_data-datagram->data,domain_fmmu->data_size);
- ec_print_data(domain_data, domain_fmmu->data_size);
+ EC_DBG("sending dg %p i=0x%02X fmmu %u fp=%u"
+ " dp=%zu size=%u\n",
+ datagram, datagram->index, i,
+ frame_offset,
+ domain_data - datagram->data,
+ domain_fmmu->data_size);
+ ec_print_data(domain_data,
+ domain_fmmu->data_size);
}
}
domain_data += domain_fmmu->data_size;
++i;
}
- }
- else {
- memcpy(frame_datagram_data, datagram->data, datagram->data_size);
+ } else {
+ memcpy(frame_datagram_data, datagram->data,
+ datagram->data_size);
}
cur_data += datagram->data_size;
@@ -1123,26 +1138,32 @@
continue;
}
frame_datagram_data = cur_data;
+
if (datagram->domain) {
size_t datagram_address = EC_READ_U32(datagram->address);
int i = 0;
uint8_t *domain_data = datagram->data;
- list_for_each_entry(domain_fmmu, &datagram->domain->fmmu_configs, list) {
- if (domain_fmmu->dir == EC_DIR_INPUT ) {
- unsigned int frame_offset = domain_fmmu->logical_start_address-datagram_address;
- memcpy(domain_data, frame_datagram_data+frame_offset, domain_fmmu->data_size);
+
+ list_for_each_entry(domain_fmmu, &datagram->domain->fmmu_configs,
+ list) {
+ if (domain_fmmu->dir == EC_DIR_INPUT) {
+ unsigned int frame_offset =
+ domain_fmmu->logical_start_address - datagram_address;
+ memcpy(domain_data, frame_datagram_data + frame_offset,
+ domain_fmmu->data_size);
if (unlikely(master->debug_level > 1)) {
- EC_DBG("receiving dg %p i=0x%02X fmmu %u fp=%u dp=%zu size=%u\n",
- datagram,datagram->index, i,
- frame_offset,domain_data-datagram->data,domain_fmmu->data_size);
+ EC_DBG("receiving dg %p i=0x%02X fmmu %u fp=%u"
+ " dp=%zu size=%u\n",
+ datagram, datagram->index, i,
+ frame_offset, domain_data - datagram->data,
+ domain_fmmu->data_size);
ec_print_data(domain_data, domain_fmmu->data_size);
}
}
domain_data += domain_fmmu->data_size;
++i;
}
- }
- else {
+ } else {
// copy received data into the datagram memory
memcpy(datagram->data, frame_datagram_data, data_size);
}
@@ -1282,6 +1303,7 @@
ec_master_t *master = (ec_master_t *) priv_data;
ec_slave_t *slave = NULL;
size_t sent_bytes;
+
// send interval in IDLE phase
ec_master_set_send_interval(master, 1000000 / HZ);
@@ -1298,8 +1320,9 @@
ec_mutex_unlock(&master->io_mutex);
// execute master & slave state machines
- if (ec_mutex_lock_interruptible(&master->master_mutex))
+ if (ec_mutex_lock_interruptible(&master->master_mutex)) {
break;
+ }
if (ec_fsm_master_exec(&master->fsm)) {
ec_master_mbox_queue_datagrams(master, &master->fsm_mbox);
}
@@ -1309,8 +1332,9 @@
ec_fsm_slave_exec(&slave->fsm); // may queue datagram in fsm queue
}
#if defined(EC_EOE)
- if (!ec_master_eoe_processing(master))
- master->fsm.idle = 0; // pump the bus as fast as possible
+ if (!ec_master_eoe_processing(master)) {
+ master->fsm.idle = 0; // pump the bus as fast as possible
+ }
#endif
ec_mutex_unlock(&master->master_mutex);
@@ -1362,10 +1386,12 @@
ec_master_output_stats(master);
// execute master & slave state machines
- if (ec_mutex_lock_interruptible(&master->master_mutex))
+ if (ec_mutex_lock_interruptible(&master->master_mutex)) {
break;
- if (ec_fsm_master_exec(&master->fsm))
+ }
+ if (ec_fsm_master_exec(&master->fsm)) {
ec_master_mbox_queue_datagrams(master, &master->fsm_mbox);
+ }
for (slave = master->slaves;
slave < master->slaves + master->slave_count;
slave++) {
@@ -2080,7 +2106,8 @@
if (unlikely(!master->main_device.link_state)) {
// link is down, no datagram can be sent
- list_for_each_entry_safe(datagram, next, &master->datagram_queue, queue) {
+ list_for_each_entry_safe(datagram, next, &master->datagram_queue,
+ queue) {
datagram->state = EC_DATAGRAM_ERROR;
list_del_init(&datagram->queue);
}
--- a/master/master.h Mon Aug 01 16:53:21 2011 +0200
+++ b/master/master.h Mon Aug 01 17:02:45 2011 +0200
@@ -246,7 +246,8 @@
fsm_datagram_queue. */
struct list_head fsm_datagram_queue; /**< External Datagram queue. */
- unsigned int send_interval; /**< Interval between calls to ecrt_master_send */
+ unsigned int send_interval; /**< Interval between calls to
+ ecrt_master_send */
size_t max_queue_size; /**< Maximum size of datagram queue */
unsigned int debug_level; /**< Master debug level. */
@@ -263,10 +264,14 @@
void (*fsm_queue_lock_cb)(void *); /**< FSM queue lock callback. */
void (*fsm_queue_unlock_cb)(void *); /**< FSM queue unlock callback. */
- void *fsm_queue_locking_data; /**< Data parameter of fsm queue locking callbacks. */
- void (*app_fsm_queue_lock_cb)(void *); /**< App's FSM queue lock callback. */
- void (*app_fsm_queue_unlock_cb)(void *); /**< App's FSM queue unlock callback. */
- void *app_fsm_queue_locking_data; /**< App's data parameter of fsm queue locking callbacks. */
+ void *fsm_queue_locking_data; /**< Data parameter of fsm queue locking
+ callbacks. */
+ void (*app_fsm_queue_lock_cb)(void *); /**< App's FSM queue lock callback.
+ */
+ void (*app_fsm_queue_unlock_cb)(void *); /**< App's FSM queue unlock
+ callback. */
+ void *app_fsm_queue_locking_data; /**< App's data parameter of fsm queue
+ locking callbacks. */
struct list_head sii_requests; /**< SII write requests. */
wait_queue_head_t sii_queue; /**< Wait queue for SII