/* Returns the "i2c type". This is a pointer to a struct that describes the I2C chain on this board. To minimize impact on struct ipath_devdata, the (small integer) index into the table is actually memoized, rather then the pointer. Memoization is because the type is determined on the first call per chip. An alternative would be to move type determination to early init code.  */
static struct i2c_chain_desc* ipath_i2c_type(struct ipath_devdata *dd)
/* Returns the "i2c type". This is a pointer to a struct that describes the I2C chain on this board. To minimize impact on struct ipath_devdata, the (small integer) index into the table is actually memoized, rather then the pointer. Memoization is because the type is determined on the first call per chip. An alternative would be to move type determination to early init code.  */
static struct i2c_chain_desc* ipath_i2c_type(struct ipath_devdata *dd)
{
	int idx;
	idx = dd->ipath_i2c_chain_type - 1;
	if (idx >= 0 && idx < (ARRAY_SIZE(i2c_chains) - 1))
		goto done;
	idx = 0;
	while (i2c_chains[idx].probe_dev != IPATH_NO_DEV) {
		if (!i2c_probe(dd, i2c_chains[idx].probe_dev))
			break;
		++idx;
	}
	if (idx == 0)
		eeprom_reset(dd);
	if (i2c_chains[idx].probe_dev == IPATH_NO_DEV)
		idx = -1;
	else
		dd->ipath_i2c_chain_type = idx + 1;
done:
	return (idx >= 0) ? i2c_chains + idx : NULL;
}