提交 ac6d5298 编写于 作者: P Peter Rosin 提交者: Wolfram Sang

i2c: algos: make use of i2c_8bit_addr_from_msg

Because it looks neater.
Signed-off-by: NPeter Rosin <peda@axentia.se>
Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
上级 b80646be
...@@ -519,9 +519,7 @@ static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) ...@@ -519,9 +519,7 @@ static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
} }
} }
} else { /* normal 7bit address */ } else { /* normal 7bit address */
addr = msg->addr << 1; addr = i2c_8bit_addr_from_msg(msg);
if (flags & I2C_M_RD)
addr |= 1;
if (flags & I2C_M_REV_DIR_ADDR) if (flags & I2C_M_REV_DIR_ADDR)
addr ^= 1; addr ^= 1;
ret = try_address(i2c_adap, addr, retries); ret = try_address(i2c_adap, addr, retries);
......
...@@ -112,11 +112,8 @@ static int pca_address(struct i2c_algo_pca_data *adap, ...@@ -112,11 +112,8 @@ static int pca_address(struct i2c_algo_pca_data *adap,
struct i2c_msg *msg) struct i2c_msg *msg)
{ {
int sta = pca_get_con(adap); int sta = pca_get_con(adap);
int addr; int addr = i2c_8bit_addr_from_msg(msg);
addr = ((0x7f & msg->addr) << 1);
if (msg->flags & I2C_M_RD)
addr |= 1;
DEB2("=== SLAVE ADDRESS %#04x+%c=%#04x\n", DEB2("=== SLAVE ADDRESS %#04x+%c=%#04x\n",
msg->addr, msg->flags & I2C_M_RD ? 'R' : 'W', addr); msg->addr, msg->flags & I2C_M_RD ? 'R' : 'W', addr);
......
...@@ -291,13 +291,9 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf, ...@@ -291,13 +291,9 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf,
static int pcf_doAddress(struct i2c_algo_pcf_data *adap, static int pcf_doAddress(struct i2c_algo_pcf_data *adap,
struct i2c_msg *msg) struct i2c_msg *msg)
{ {
unsigned short flags = msg->flags; unsigned char addr = i2c_8bit_addr_from_msg(msg);
unsigned char addr;
addr = msg->addr << 1; if (msg->flags & I2C_M_REV_DIR_ADDR)
if (flags & I2C_M_RD)
addr |= 1;
if (flags & I2C_M_REV_DIR_ADDR)
addr ^= 1; addr ^= 1;
i2c_outb(adap, addr); i2c_outb(adap, addr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册