/* Prepare the EEPROM for reading  */ if(e1000_acquire_eeprom(hw) != E1000_SUCCESS) return -E1000_ERR_EEPROM; 
/* FLASH reads without acquiring the semaphore are safe in 82573-based * controllers. */ if ((e1000_is_onboard_nvm_eeprom(hw) == TRUE) || (hw->mac_type != e1000_82573)) { /* Prepare the EEPROM for reading  */ if(e1000_acquire_eeprom(hw) != E1000_SUCCESS) return -E1000_ERR_EEPROM; }  if(eeprom->use_eerd == TRUE) { ret_val = e1000_read_eeprom_eerd(hw, offset, words, data); if ((e1000_is_onboard_nvm_eeprom(hw) == TRUE) || (hw->mac_type != e1000_82573)) e1000_release_eeprom(hw); return ret_val; } 
e1000_read_eeprom(struct e1000_hw *hw,                  uint16_t offset,                  uint16_t words,                  uint16_t *data){    struct e1000_eeprom_info *eeprom = &hw->eeprom;    uint32_t i = 0;    DEBUGFUNC("e1000_read_eeprom");    /* A check for invalid values:  offset too large, too many words, and not     * enough words.     */    if((offset >= eeprom->word_size) || (words > eeprom->word_size - offset) ||       (words == 0)) {        DEBUGOUT("\"words\" parameter out of bounds\n");        return -E1000_ERR_EEPROM;    }    /* Prepare the EEPROM for reading  */    if(e1000_acquire_eeprom(hw) != E1000_SUCCESS)        return -E1000_ERR_EEPROM;    if(eeprom->type == e1000_eeprom_spi) {        uint16_t word_in;        uint8_t read_opcode = EEPROM_READ_OPCODE_SPI;        if(e1000_spi_eeprom_ready(hw)) {            e1000_release_eeprom(hw);            return -E1000_ERR_EEPROM;        }        e1000_standby_eeprom(hw);        /* Some SPI eeproms use the 8th address bit embedded in the opcode */        if((eeprom->address_bits == 8) && (offset >= 128))            read_opcode |= EEPROM_A8_OPCODE_SPI;        /* Send the READ command (opcode + addr)  */        e1000_shift_out_ee_bits(hw, read_opcode, eeprom->opcode_bits);        e1000_shift_out_ee_bits(hw, (uint16_t)(offset*2), eeprom->address_bits);        /* Read the data.  The address of the eeprom internally increments with         * each byte (spi) being read, saving on the overhead of eeprom setup         * and tear-down.  The address counter will roll over if reading beyond         * the size of the eeprom, thus allowing the entire memory to be read         * starting from any offset. */        for (i = 0; i < words; i++) {            word_in = e1000_shift_in_ee_bits(hw, 16);            data[i] = (word_in >> 8) | (word_in << 8);        }    } else if(eeprom->type == e1000_eeprom_microwire) {        for (i = 0; i < words; i++) {            /* Send the READ command (opcode + addr)  */            e1000_shift_out_ee_bits(hw, EEPROM_READ_OPCODE_MICROWIRE,                                    eeprom->opcode_bits);            e1000_shift_out_ee_bits(hw, (uint16_t)(offset + i),                                    eeprom->address_bits);            /* Read the data.  For microwire, each word requires the overhead             * of eeprom setup and tear-down. */            data[i] = e1000_shift_in_ee_bits(hw, 16);            e1000_standby_eeprom(hw);        }    }    /* End this read operation */    e1000_release_eeprom(hw);    return E1000_SUCCESS;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/2d7edb923a823660b081bd4c660300ee19adca8d/e1000_hw.c/buggy/drivers/net/e1000/e1000_hw.c