/* Read SEEPROM. A zero is written to the flag register when the addres is written to the Control register. The hardware device will set the flag to a one when 4B have been transferred to the Data register.  */
int t1_seeprom_read(adapter_t *adapter, u32 addr, __le32 *data)
/* Read SEEPROM. A zero is written to the flag register when the addres is written to the Control register. The hardware device will set the flag to a one when 4B have been transferred to the Data register.  */
int t1_seeprom_read(adapter_t *adapter, u32 addr, __le32 *data)
{
	int i = EEPROM_MAX_POLL;
	u16 val;
	u32 v;
	if (addr >= EEPROMSIZE || (addr & 3))
		return -EINVAL;
	pci_write_config_word(adapter->pdev, A_PCICFG_VPD_ADDR, (u16)addr);
	do {
		udelay(50);
		pci_read_config_word(adapter->pdev, A_PCICFG_VPD_ADDR, &val);
	} while (!(val & F_VPD_OP_FLAG) && --i);
	if (!(val & F_VPD_OP_FLAG)) {
		CH_ERR("%s: reading EEPROM address 0x%x failed\n",
		       adapter->name, addr);
		return -EIO;
	}
	pci_read_config_dword(adapter->pdev, A_PCICFG_VPD_DATA, &v);
	*data = cpu_to_le32(v);
	return 0;
}