aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Scheller2017-12-26 18:37:57 -0500
committerMauro Carvalho Chehab2018-01-03 04:46:59 -0500
commit8042e98c387b02fc4239eee0075d0f318efcf1d7 (patch)
treec3bc68e4a465cba0f6f9a6b5689cf1ef4c451a9a
parent4b596bd70a396dfeb55f38b6bd1c21b8e77ebe77 (diff)
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>
-rw-r--r--drivers/media/dvb-frontends/stv0910.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/drivers/media/dvb-frontends/stv0910.c b/drivers/media/dvb-frontends/stv0910.c
index 9f38ebeec853..fa6bb7436b86 100644
--- a/drivers/media/dvb-frontends/stv0910.c
+++ b/drivers/media/dvb-frontends/stv0910.c
@@ -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;
}