mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-19 06:36:44 +07:00
media: dvb-frontends/stv0910: cleanup I2C access functions
write_reg() and i2c_write_reg16() only act as a proxy to i2c_write(), which isn't called from anywhere else throughout the driver. Clean this up by moving the message setup and the i2c_transfer() into write_reg() so it becomes the only I2C write function. While touching those parts, fix the error codes from EREMOTEIO to EIO. The I2C cleanup is picked from the upstream dddvb. Cc: Ralph Metzler <rjkm@metzlerbros.de> Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:
parent
4b596bd70a
commit
8042e98c38
@ -137,33 +137,21 @@ struct slookup {
|
||||
u32 reg_value;
|
||||
};
|
||||
|
||||
static inline int i2c_write(struct i2c_adapter *adap, u8 adr,
|
||||
u8 *data, int len)
|
||||
static int write_reg(struct stv *state, u16 reg, u8 val)
|
||||
{
|
||||
struct i2c_msg msg = {.addr = adr, .flags = 0,
|
||||
.buf = data, .len = len};
|
||||
struct i2c_adapter *adap = state->base->i2c;
|
||||
u8 data[3] = {reg >> 8, reg & 0xff, val};
|
||||
struct i2c_msg msg = {.addr = state->base->adr, .flags = 0,
|
||||
.buf = data, .len = 3};
|
||||
|
||||
if (i2c_transfer(adap, &msg, 1) != 1) {
|
||||
dev_warn(&adap->dev, "i2c write error ([%02x] %04x: %02x)\n",
|
||||
adr, (data[0] << 8) | data[1],
|
||||
(len > 2 ? data[2] : 0));
|
||||
return -EREMOTEIO;
|
||||
state->base->adr, reg, val);
|
||||
return -EIO;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int i2c_write_reg16(struct i2c_adapter *adap, u8 adr, u16 reg, u8 val)
|
||||
{
|
||||
u8 msg[3] = {reg >> 8, reg & 0xff, val};
|
||||
|
||||
return i2c_write(adap, adr, msg, 3);
|
||||
}
|
||||
|
||||
static int write_reg(struct stv *state, u16 reg, u8 val)
|
||||
{
|
||||
return i2c_write_reg16(state->base->i2c, state->base->adr, reg, val);
|
||||
}
|
||||
|
||||
static inline int i2c_read_regs16(struct i2c_adapter *adapter, u8 adr,
|
||||
u16 reg, u8 *val, int count)
|
||||
{
|
||||
@ -176,7 +164,7 @@ static inline int i2c_read_regs16(struct i2c_adapter *adapter, u8 adr,
|
||||
if (i2c_transfer(adapter, msgs, 2) != 2) {
|
||||
dev_warn(&adapter->dev, "i2c read error ([%02x] %04x)\n",
|
||||
adr, reg);
|
||||
return -EREMOTEIO;
|
||||
return -EIO;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user