Centrally defined mailbox types.
--- a/master/ethernet.c Wed Nov 05 15:06:54 2014 +0100
+++ b/master/ethernet.c Wed Nov 05 18:42:12 2014 +0100
@@ -299,7 +299,7 @@
#endif
data = ec_slave_mbox_prepare_send(eoe->slave, &eoe->datagram,
- 0x02, current_size + 4);
+ EC_MBOX_TYPE_EOE, current_size + 4);
if (IS_ERR(data))
return PTR_ERR(data);
@@ -478,7 +478,7 @@
return;
}
- if (mbox_prot != 0x02) { // EoE FIXME mailbox handler necessary
+ if (mbox_prot != EC_MBOX_TYPE_EOE) { // FIXME mailbox handler necessary
eoe->stats.rx_errors++;
#if EOE_DEBUG_LEVEL >= 1
EC_SLAVE_WARN(eoe->slave, "Other mailbox protocol response for %s.\n",
--- a/master/fsm_coe.c Wed Nov 05 15:06:54 2014 +0100
+++ b/master/fsm_coe.c Wed Nov 05 18:42:12 2014 +0100
@@ -318,7 +318,8 @@
)
{
ec_slave_t *slave = fsm->slave;
- uint8_t *data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, 8);
+ uint8_t *data = ec_slave_mbox_prepare_send(slave, datagram,
+ EC_MBOX_TYPE_COE, 8);
if (IS_ERR(data)) {
return PTR_ERR(data);
}
@@ -470,7 +471,8 @@
)
{
ec_slave_t *slave = fsm->slave;
- u8 *data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, 8);
+ u8 *data = ec_slave_mbox_prepare_send(slave, datagram, EC_MBOX_TYPE_COE,
+ 8);
if (IS_ERR(data)) {
return PTR_ERR(data);
}
@@ -532,7 +534,7 @@
return;
}
- if (mbox_prot != 0x03) { // CoE
+ if (mbox_prot != EC_MBOX_TYPE_COE) {
EC_SLAVE_ERR(slave, "Received mailbox protocol 0x%02X as response.\n",
mbox_prot);
fsm->state = ec_fsm_coe_error;
@@ -752,7 +754,8 @@
)
{
ec_slave_t *slave = fsm->slave;
- u8 *data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, 10);
+ u8 *data = ec_slave_mbox_prepare_send(slave, datagram, EC_MBOX_TYPE_COE,
+ 10);
if (IS_ERR(data)) {
return PTR_ERR(data);
}
@@ -813,7 +816,7 @@
return;
}
- if (mbox_prot != 0x03) { // CoE
+ if (mbox_prot != EC_MBOX_TYPE_COE) {
EC_SLAVE_ERR(slave, "Received mailbox protocol 0x%02X as response.\n",
mbox_prot);
fsm->state = ec_fsm_coe_error;
@@ -1049,7 +1052,7 @@
return;
}
- if (mbox_prot != 0x03) { // CoE
+ if (mbox_prot != EC_MBOX_TYPE_COE) {
EC_SLAVE_ERR(slave, "Received mailbox protocol"
" 0x%02X as response.\n", mbox_prot);
fsm->state = ec_fsm_coe_error;
@@ -1200,7 +1203,7 @@
uint8_t data_set_size;
if (request->data_size <= 4) { // use expedited transfer type
- data = ec_slave_mbox_prepare_send(slave, datagram, 0x03,
+ data = ec_slave_mbox_prepare_send(slave, datagram, EC_MBOX_TYPE_COE,
EC_COE_DOWN_REQ_HEADER_SIZE);
if (IS_ERR(data)) {
request->errno = PTR_ERR(data);
@@ -1241,7 +1244,7 @@
data_size = required_data_size;
}
- data = ec_slave_mbox_prepare_send(slave, datagram, 0x03,
+ data = ec_slave_mbox_prepare_send(slave, datagram, EC_MBOX_TYPE_COE,
data_size);
if (IS_ERR(data)) {
request->errno = PTR_ERR(data);
@@ -1491,7 +1494,7 @@
+ EC_COE_DOWN_SEG_MIN_DATA_SIZE;
}
- data = ec_slave_mbox_prepare_send(slave, datagram, 0x03,
+ data = ec_slave_mbox_prepare_send(slave, datagram, EC_MBOX_TYPE_COE,
data_size);
if (IS_ERR(data)) {
request->errno = PTR_ERR(data);
@@ -1565,7 +1568,7 @@
return;
}
- if (mbox_prot != 0x03) { // CoE
+ if (mbox_prot != EC_MBOX_TYPE_COE) {
request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Received mailbox protocol 0x%02X as response.\n",
@@ -1743,7 +1746,7 @@
return;
}
- if (mbox_prot != 0x03) { // CoE
+ if (mbox_prot != EC_MBOX_TYPE_COE) {
request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_ERR(slave, "Received mailbox protocol 0x%02X as response.\n",
@@ -1844,7 +1847,8 @@
ec_sdo_request_t *request = fsm->request;
ec_master_t *master = slave->master;
- u8 *data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, 10);
+ u8 *data = ec_slave_mbox_prepare_send(slave, datagram, EC_MBOX_TYPE_COE,
+ 10);
if (IS_ERR(data)) {
request->errno = PTR_ERR(data);
return PTR_ERR(data);
@@ -2035,7 +2039,8 @@
)
{
uint8_t *data =
- ec_slave_mbox_prepare_send(fsm->slave, datagram, 0x03, 10);
+ ec_slave_mbox_prepare_send(fsm->slave, datagram, EC_MBOX_TYPE_COE,
+ 10);
if (IS_ERR(data)) {
fsm->request->errno = PTR_ERR(data);
fsm->state = ec_fsm_coe_error;
@@ -2108,7 +2113,7 @@
ec_print_data(data, rec_size);
}
- if (mbox_prot != 0x03) { // CoE
+ if (mbox_prot != EC_MBOX_TYPE_COE) {
request->errno = EIO;
fsm->state = ec_fsm_coe_error;
EC_SLAVE_WARN(slave, "Received mailbox protocol 0x%02X"
@@ -2413,7 +2418,7 @@
ec_print_data(data, rec_size);
}
- if (mbox_prot != 0x03) { // CoE
+ if (mbox_prot != EC_MBOX_TYPE_COE) {
EC_SLAVE_ERR(slave, "Received mailbox protocol 0x%02X as response.\n",
mbox_prot);
request->errno = EIO;
--- a/master/fsm_foe.c Wed Nov 05 15:06:54 2014 +0100
+++ b/master/fsm_foe.c Wed Nov 05 18:42:12 2014 +0100
@@ -46,10 +46,6 @@
*/
#define EC_FSM_FOE_TIMEOUT 3000
-/** Mailbox type FoE.
- */
-#define EC_MBOX_TYPE_FILEACCESS 0x04
-
/** Size of the FoE header.
*/
#define EC_FOE_HEADER_SIZE 6
@@ -253,8 +249,7 @@
}
data = ec_slave_mbox_prepare_send(fsm->slave,
- datagram, EC_MBOX_TYPE_FILEACCESS,
- current_size + EC_FOE_HEADER_SIZE);
+ datagram, EC_MBOX_TYPE_FOE, current_size + EC_FOE_HEADER_SIZE);
if (IS_ERR(data)) {
return -1;
}
@@ -291,7 +286,7 @@
current_size = fsm->tx_filename_len;
data = ec_slave_mbox_prepare_send(fsm->slave, datagram,
- EC_MBOX_TYPE_FILEACCESS, current_size + EC_FOE_HEADER_SIZE);
+ EC_MBOX_TYPE_FOE, current_size + EC_FOE_HEADER_SIZE);
if (IS_ERR(data)) {
return -1;
}
@@ -428,7 +423,7 @@
return;
}
- if (mbox_prot != EC_MBOX_TYPE_FILEACCESS) { // FoE
+ if (mbox_prot != EC_MBOX_TYPE_FOE) {
ec_foe_set_tx_error(fsm, FOE_MBOX_PROT_ERROR);
EC_SLAVE_ERR(slave, "Received mailbox protocol 0x%02X as response.\n",
mbox_prot);
@@ -563,7 +558,7 @@
current_size = fsm->rx_filename_len;
data = ec_slave_mbox_prepare_send(fsm->slave, datagram,
- EC_MBOX_TYPE_FILEACCESS, current_size + EC_FOE_HEADER_SIZE);
+ EC_MBOX_TYPE_FOE, current_size + EC_FOE_HEADER_SIZE);
if (IS_ERR(data)) {
return -1;
}
@@ -594,7 +589,7 @@
uint8_t *data;
data = ec_slave_mbox_prepare_send(fsm->slave, datagram,
- EC_MBOX_TYPE_FILEACCESS, EC_FOE_HEADER_SIZE);
+ EC_MBOX_TYPE_FOE, EC_FOE_HEADER_SIZE);
if (IS_ERR(data)) {
return -1;
}
@@ -767,7 +762,7 @@
return;
}
- if (mbox_prot != EC_MBOX_TYPE_FILEACCESS) { // FoE
+ if (mbox_prot != EC_MBOX_TYPE_FOE) {
EC_SLAVE_ERR(slave, "Received mailbox protocol 0x%02X as response.\n",
mbox_prot);
ec_foe_set_rx_error(fsm, FOE_PROT_ERROR);
--- a/master/fsm_soe.c Wed Nov 05 15:06:54 2014 +0100
+++ b/master/fsm_soe.c Wed Nov 05 18:42:12 2014 +0100
@@ -41,10 +41,6 @@
/*****************************************************************************/
-/** Mailbox type for SoE.
- */
-#define EC_MBOX_TYPE_SOE 0x05
-
/** SoE operations
*/
enum ec_soe_opcodes {
--- a/master/mailbox.h Wed Nov 05 15:06:54 2014 +0100
+++ b/master/mailbox.h Wed Nov 05 18:42:12 2014 +0100
@@ -45,6 +45,16 @@
*/
#define EC_MBOX_HEADER_SIZE 6
+/** Mailbox types.
+ */
+enum ec_mbox_types {
+ EC_MBOX_TYPE_EOE = 0x02,
+ EC_MBOX_TYPE_COE = 0x03,
+ EC_MBOX_TYPE_FOE = 0x04,
+ EC_MBOX_TYPE_SOE = 0x05,
+ EC_MBOX_TYPE_VOE = 0x0f,
+};
+
/*****************************************************************************/
uint8_t *ec_slave_mbox_prepare_send(const ec_slave_t *, ec_datagram_t *,
--- a/master/voe_handler.c Wed Nov 05 15:06:54 2014 +0100
+++ b/master/voe_handler.c Wed Nov 05 18:42:12 2014 +0100
@@ -40,10 +40,6 @@
#include "mailbox.h"
#include "voe_handler.h"
-/** VoE mailbox type.
- */
-#define EC_MBOX_TYPE_VOE 0x0f
-
/** VoE header size.
*/
#define EC_VOE_HEADER_SIZE 6