diff options
author | Peter Rosin <peda@axentia.se> | 2018-05-16 03:16:46 -0400 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2018-05-29 14:30:06 -0400 |
commit | ac6d5298f6af763b587495d62041fe57a2fb89e6 (patch) | |
tree | b3b8e1606dc0f5cfc1e9c241cf4ca14eb0b541b4 | |
parent | b80646be4c171f6b59f3145ee3b8872b56e0ac4c (diff) |
i2c: algos: make use of i2c_8bit_addr_from_msg
Because it looks neater.
Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r-- | drivers/i2c/algos/i2c-algo-bit.c | 4 | ||||
-rw-r--r-- | drivers/i2c/algos/i2c-algo-pca.c | 5 | ||||
-rw-r--r-- | drivers/i2c/algos/i2c-algo-pcf.c | 8 |
3 files changed, 4 insertions, 13 deletions
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index 3df0efd69ae3..4a34f311e1ff 100644 --- a/drivers/i2c/algos/i2c-algo-bit.c +++ b/drivers/i2c/algos/i2c-algo-bit.c | |||
@@ -519,9 +519,7 @@ static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) | |||
519 | } | 519 | } |
520 | } | 520 | } |
521 | } else { /* normal 7bit address */ | 521 | } else { /* normal 7bit address */ |
522 | addr = msg->addr << 1; | 522 | addr = i2c_8bit_addr_from_msg(msg); |
523 | if (flags & I2C_M_RD) | ||
524 | addr |= 1; | ||
525 | if (flags & I2C_M_REV_DIR_ADDR) | 523 | if (flags & I2C_M_REV_DIR_ADDR) |
526 | addr ^= 1; | 524 | addr ^= 1; |
527 | ret = try_address(i2c_adap, addr, retries); | 525 | ret = try_address(i2c_adap, addr, retries); |
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c index e370804ec8bc..883a290f6a4d 100644 --- a/drivers/i2c/algos/i2c-algo-pca.c +++ b/drivers/i2c/algos/i2c-algo-pca.c | |||
@@ -112,11 +112,8 @@ static int pca_address(struct i2c_algo_pca_data *adap, | |||
112 | struct i2c_msg *msg) | 112 | struct i2c_msg *msg) |
113 | { | 113 | { |
114 | int sta = pca_get_con(adap); | 114 | int sta = pca_get_con(adap); |
115 | int addr; | 115 | int addr = i2c_8bit_addr_from_msg(msg); |
116 | 116 | ||
117 | addr = ((0x7f & msg->addr) << 1); | ||
118 | if (msg->flags & I2C_M_RD) | ||
119 | addr |= 1; | ||
120 | DEB2("=== SLAVE ADDRESS %#04x+%c=%#04x\n", | 117 | DEB2("=== SLAVE ADDRESS %#04x+%c=%#04x\n", |
121 | msg->addr, msg->flags & I2C_M_RD ? 'R' : 'W', addr); | 118 | msg->addr, msg->flags & I2C_M_RD ? 'R' : 'W', addr); |
122 | 119 | ||
diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c index 270d84bfc2c6..5c29a4d397cf 100644 --- a/drivers/i2c/algos/i2c-algo-pcf.c +++ b/drivers/i2c/algos/i2c-algo-pcf.c | |||
@@ -291,13 +291,9 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf, | |||
291 | static int pcf_doAddress(struct i2c_algo_pcf_data *adap, | 291 | static int pcf_doAddress(struct i2c_algo_pcf_data *adap, |
292 | struct i2c_msg *msg) | 292 | struct i2c_msg *msg) |
293 | { | 293 | { |
294 | unsigned short flags = msg->flags; | 294 | unsigned char addr = i2c_8bit_addr_from_msg(msg); |
295 | unsigned char addr; | ||
296 | 295 | ||
297 | addr = msg->addr << 1; | 296 | if (msg->flags & I2C_M_REV_DIR_ADDR) |
298 | if (flags & I2C_M_RD) | ||
299 | addr |= 1; | ||
300 | if (flags & I2C_M_REV_DIR_ADDR) | ||
301 | addr ^= 1; | 297 | addr ^= 1; |
302 | i2c_outb(adap, addr); | 298 | i2c_outb(adap, addr); |
303 | 299 | ||