mirror of https://gitee.com/openkylin/linux.git
i2c: mux: pca954x: make use of __i2c_smbus_xfer
This simplifies the code, and you get retries for free if the adapter does not support ->master_xfer. Signed-off-by: Peter Rosin <peda@axentia.se> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
This commit is contained in:
parent
a5306b8034
commit
1bcb852f5b
|
@ -220,30 +220,11 @@ MODULE_DEVICE_TABLE(of, pca954x_of_match);
|
|||
static int pca954x_reg_write(struct i2c_adapter *adap,
|
||||
struct i2c_client *client, u8 val)
|
||||
{
|
||||
int ret = -ENODEV;
|
||||
union i2c_smbus_data dummy;
|
||||
|
||||
if (adap->algo->master_xfer) {
|
||||
struct i2c_msg msg;
|
||||
char buf[1];
|
||||
|
||||
msg.addr = client->addr;
|
||||
msg.flags = 0;
|
||||
msg.len = 1;
|
||||
buf[0] = val;
|
||||
msg.buf = buf;
|
||||
ret = __i2c_transfer(adap, &msg, 1);
|
||||
|
||||
if (ret >= 0 && ret != 1)
|
||||
ret = -EREMOTEIO;
|
||||
} else {
|
||||
union i2c_smbus_data data;
|
||||
ret = adap->algo->smbus_xfer(adap, client->addr,
|
||||
client->flags,
|
||||
I2C_SMBUS_WRITE,
|
||||
val, I2C_SMBUS_BYTE, &data);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return __i2c_smbus_xfer(adap, client->addr, client->flags,
|
||||
I2C_SMBUS_WRITE, val,
|
||||
I2C_SMBUS_BYTE, &dummy);
|
||||
}
|
||||
|
||||
static int pca954x_select_chan(struct i2c_mux_core *muxc, u32 chan)
|
||||
|
|
Loading…
Reference in New Issue