# HG changeset patch # User Florian Pose # Date 1190281467 0 # Node ID b83392e8cd66ba4fd76dd71bc29eae0736fef9bd # Parent 5ee2c5ce9ccabfd87196a52f11c760e0d3e214c6 Fixed detection of missing EEPROM category limiter. diff -r 5ee2c5ce9cca -r b83392e8cd66 master/fsm_slave.c --- a/master/fsm_slave.c Thu Sep 20 09:43:59 2007 +0000 +++ b/master/fsm_slave.c Thu Sep 20 09:44:27 2007 +0000 @@ -403,14 +403,15 @@ cat_size = EC_READ_U16(fsm->fsm_sii.value + 2); if (cat_type != 0xFFFF) { // not the last category - fsm->sii_offset += cat_size + 2; - if (fsm->sii_offset >= EC_MAX_EEPROM_SIZE) { + off_t next_offset = 2UL + fsm->sii_offset + cat_size; + if (next_offset >= EC_MAX_EEPROM_SIZE) { EC_WARN("EEPROM size of slave %i exceeds" - " %i words (0xffff limiter missing?).\n", + " %u words (0xffff limiter missing?).\n", slave->ring_position, EC_MAX_EEPROM_SIZE); slave->eeprom_size = EC_FIRST_EEPROM_CATEGORY_OFFSET * 2; goto alloc_eeprom; } + fsm->sii_offset = next_offset; ec_fsm_sii_read(&fsm->fsm_sii, slave, fsm->sii_offset, EC_FSM_SII_NODE); ec_fsm_sii_exec(&fsm->fsm_sii); // execute state immediately @@ -421,18 +422,18 @@ alloc_eeprom: if (slave->eeprom_data) { - EC_INFO("Freeing old EEPROM data on slave %i...\n", + EC_WARN("Freeing old EEPROM data on slave %i...\n", slave->ring_position); kfree(slave->eeprom_data); } if (!(slave->eeprom_data = (uint8_t *) kmalloc(slave->eeprom_size, GFP_ATOMIC))) { + EC_ERR("Failed to allocate %u bytes of EEPROM data for slave %u.\n", + slave->eeprom_size, slave->ring_position); slave->eeprom_size = 0; slave->error_flag = 1; fsm->state = ec_fsm_slave_state_error; - EC_ERR("Failed to allocate EEPROM data for slave %u.\n", - slave->ring_position); return; } @@ -509,7 +510,8 @@ EC_READ_U16(slave->eeprom_data + 2 * 0x001C); if (eeprom_word_size < EC_FIRST_EEPROM_CATEGORY_OFFSET + 1) { - EC_ERR("Unexpected end of EEPROM data in slave %u.\n", + EC_ERR("Unexpected end of EEPROM data in slave %u:" + " First category header missing.\n", slave->ring_position); goto end; } @@ -522,7 +524,8 @@ // type and size words must fit if (cat_word + 2 - (uint16_t *) slave->eeprom_data > eeprom_word_size) { - EC_ERR("Unexpected end of EEPROM data in slave %u.\n", + EC_ERR("Unexpected end of EEPROM data in slave %u:" + " Category header incomplete.\n", slave->ring_position); goto end; } @@ -533,7 +536,8 @@ if (cat_word + cat_size - (uint16_t *) slave->eeprom_data > eeprom_word_size) { - EC_WARN("Unexpected end of EEPROM data in slave %u.\n", + EC_WARN("Unexpected end of EEPROM data in slave %u:" + " Category data incomplete.\n", slave->ring_position); goto end; } @@ -574,7 +578,8 @@ cat_word += cat_size; if (cat_word - (uint16_t *) slave->eeprom_data >= eeprom_word_size) { - EC_WARN("Unexpected end of EEPROM data in slave %u.\n", + EC_WARN("Unexpected end of EEPROM data in slave %u:" + " Next category header missing.\n", slave->ring_position); goto end; }