From 056fca7b51d949aa0e18e0eb647838874a53bcbe Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Tue, 14 Jun 2016 15:59:14 +0100 Subject: i2c: Factor our send() and recv() common logic Most of the control flow logic between send and recv (error checking etc) is the same. Factor this out into a common send_recv() API. This is then usable by clients, where the control logic for send and receive differs only by a boolean. E.g. if (send) i2c_send(...): else i2c_recv(...); becomes: i2c_send_recv(... , send); Signed-off-by: Peter Crosthwaite Reviewed-by: Alistair Francis Signed-off-by: KONRAD Frederic Message-id: 1465833014-21982-4-git-send-email-fred.konrad@greensocs.com Changes from FK: * Rebased on master. * Rebased on my i2c broadcast patch. Signed-off-by: KONRAD Frederic Reviewed-by: Alistair Francis Signed-off-by: Peter Maydell --- include/hw/i2c/i2c.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h index 4986ebc73c..c4085aa366 100644 --- a/include/hw/i2c/i2c.h +++ b/include/hw/i2c/i2c.h @@ -56,6 +56,7 @@ int i2c_bus_busy(I2CBus *bus); int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv); void i2c_end_transfer(I2CBus *bus); void i2c_nack(I2CBus *bus); +int i2c_send_recv(I2CBus *bus, uint8_t *data, bool send); int i2c_send(I2CBus *bus, uint8_t data); int i2c_recv(I2CBus *bus); -- cgit v1.2.3-55-g7522