/* @twsi: The MVTWSI register structure to use. @byte: The byte to send. @ack_flag: Flag that determines whether the received byte should be acknowledged by the controller or not (sent ACK/NAK). @tick: The duration of a clock cycle at the current I2C speed.  */
static int twsi_recv(struct mvtwsi_registers *twsi, u8 *byte, int ack_flag, uint tick)
/* @twsi: The MVTWSI register structure to use. @byte: The byte to send. @ack_flag: Flag that determines whether the received byte should be acknowledged by the controller or not (sent ACK/NAK). @tick: The duration of a clock cycle at the current I2C speed.  */
static int twsi_recv(struct mvtwsi_registers *twsi, u8 *byte, int ack_flag, uint tick)
{
	int expected_status, status, control;
	expected_status = ack_flag ? MVTWSI_STATUS_DATA_R_ACK :
			  MVTWSI_STATUS_DATA_R_NAK;
	control = MVTWSI_CONTROL_TWSIEN;
	control |= ack_flag == MVTWSI_READ_ACK ? MVTWSI_CONTROL_ACK : 0;
	writel(control | MVTWSI_CONTROL_CLEAR_IFLG, &twsi->control);
	status = twsi_wait(twsi, expected_status, tick);
	if (status == 0)
		*byte = readl(&twsi->data);
	return status;
}