aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-diolan-u2c.c
diff options
context:
space:
mode:
authorPeter Rosin <peda@axentia.se>2018-05-16 09:16:47 +0200
committerWolfram Sang <wsa@the-dreams.de>2018-05-29 20:30:49 +0200
commit30a6475744cf11f31a296cb85b43bab40ebbea92 (patch)
tree655bc88b8866daf280ac5d3d14e07959499ccaf4 /drivers/i2c/busses/i2c-diolan-u2c.c
parenti2c: algos: make use of i2c_8bit_addr_from_msg (diff)
downloadlinux-dev-30a6475744cf11f31a296cb85b43bab40ebbea92.tar.xz
linux-dev-30a6475744cf11f31a296cb85b43bab40ebbea92.zip
i2c: busses: make use of i2c_8bit_addr_from_msg
Because it looks neater. For diolan, this allows factoring out some code that is now common between if and else. For eg20t, pch_i2c_writebytes is always called with a write in msgs->flags, and pch_i2c_readbytes with a read. For imx, i2c_imx_dma_write and i2c_imx_write are always called with a write in msgs->flags, and i2c_imx_read with a read. For qup, qup_i2c_write_tx_fifo_v1 is always called with a write in qup->msg->flags. For stu300, also restructure debug output for resends, since that code as a result is only handling debug output. Reviewed-by: Guenter Roeck <linux@roeck-us.net> [diolan] Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [efm32 and imx] Acked-by: Linus Walleij <linus.walleij@linaro.org> [stu300] Signed-off-by: Peter Rosin <peda@axentia.se> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c/busses/i2c-diolan-u2c.c')
-rw-r--r--drivers/i2c/busses/i2c-diolan-u2c.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/i2c/busses/i2c-diolan-u2c.c b/drivers/i2c/busses/i2c-diolan-u2c.c
index f718ee4e3332..3f28317cde39 100644
--- a/drivers/i2c/busses/i2c-diolan-u2c.c
+++ b/drivers/i2c/busses/i2c-diolan-u2c.c
@@ -360,11 +360,11 @@ static int diolan_usb_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs,
if (ret < 0)
goto abort;
}
+ ret = diolan_i2c_put_byte_ack(dev,
+ i2c_8bit_addr_from_msg(pmsg));
+ if (ret < 0)
+ goto abort;
if (pmsg->flags & I2C_M_RD) {
- ret =
- diolan_i2c_put_byte_ack(dev, (pmsg->addr << 1) | 1);
- if (ret < 0)
- goto abort;
for (j = 0; j < pmsg->len; j++) {
u8 byte;
bool ack = j < pmsg->len - 1;
@@ -393,9 +393,6 @@ static int diolan_usb_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs,
pmsg->buf[j] = byte;
}
} else {
- ret = diolan_i2c_put_byte_ack(dev, pmsg->addr << 1);
- if (ret < 0)
- goto abort;
for (j = 0; j < pmsg->len; j++) {
ret = diolan_i2c_put_byte_ack(dev,
pmsg->buf[j]);