FreeBSD/sys/dev/cxgb/common/cxgb_t3_hw.c
/*
 * Read an 8-bit value from the I2C bus.  If the "chained" parameter is
 * non-zero then a STOP bit will not be written after the read command.  On
 * error (the read timed out, etc.), a negative errno will be returned (e.g.
 * -EAGAIN, etc.).  On success, the 8-bit value read from the I2C bus is
 * stored into the buffer *valp and the value of the I2C ACK bit is returned
 * as a 0/1 value.
 */
Read an 8-bit value from the I2C bus.  If the "chained" parameter is
non-zero then a STOP bit will not be written after the read command.  On
error (the read timed out, etc.), a negative errno will be returned .  On success, the 8-bit value read from the I2C bus is
stored into the buffer *valp and the value of the I2C ACK bit is returned
as a 0/1 value.
Read an 8 - bit value from the I2C bus . If the " chained " parameter is non - zero then a STOP bit will not be written after the read command . On error ( the read timed out etc . ) a negative errno will be returned . On success the 8 - bit value read from the I2C bus is stored into the buffer * valp and the value of the I2C ACK bit is returned as a 0 / 1 value .
int t3_i2c_read8(adapter_t *adapter, int chained, u8 *valp)
{
	int ret;
	u32 opval;
	MDIO_LOCK(adapter);
	t3_write_reg(adapter, A_I2C_OP,
		     F_I2C_READ | (chained ? F_I2C_CONT : 0));
	ret = t3_wait_op_done_val(adapter, A_I2C_OP, F_I2C_BUSY, 0,
				  I2C_ATTEMPTS, 10, &opval);
	if (ret >= 0) {
		ret = ((opval & F_I2C_ACK) == F_I2C_ACK);
		*valp = G_I2C_DATA(t3_read_reg(adapter, A_I2C_DATA));
	}
	MDIO_UNLOCK(adapter);
	return ret;
}
int t3_i2c_read8 ( adapter_t * adapter , int chained , u8 * valp ) { int ret ; u32 opval ; MDIO_LOCK ( adapter ) ; t3_write_reg ( adapter , A_I2C_OP , F_I2C_READ | ( chained ? F_I2C_CONT : 0 ) ) ; ret = t3_wait_op_done_val ( adapter , A_I2C_OP , F_I2C_BUSY , 0 , I2C_ATTEMPTS , 10 , & opval ) ; if ( ret >= 0 ) { ret = ( ( opval & F_I2C_ACK ) == F_I2C_ACK ) ; * valp = G_I2C_DATA ( t3_read_reg ( adapter , A_I2C_DATA ) ) ; } MDIO_UNLOCK ( adapter ) ; return ret ; }
Read an 8-bit value from the I2C bus.
Read an 8 - bit value from the I2C bus .