diff options
author | Jean Delvare <khali@linux-fr.org> | 2010-09-10 17:03:07 (GMT) |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-10-21 03:06:09 (GMT) |
commit | 24764107ec78230304811b11334090f65d1bc352 (patch) | |
tree | f16ecc8a9fe614719e7f8b8bb3c8aec639ea11cd | |
parent | a0a4714c404dfd0c28092743dd8bc244fcda357a (diff) | |
download | linux-fsl-qoriq-24764107ec78230304811b11334090f65d1bc352.tar.xz |
V4L/DVB: cx22702: Clean up register access functions
* Avoid temporary variables.
* Optimize success paths.
* Make error messages consistently verbose.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/dvb/frontends/cx22702.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/media/dvb/frontends/cx22702.c b/drivers/media/dvb/frontends/cx22702.c index 00b5c7e..c799fdf 100644 --- a/drivers/media/dvb/frontends/cx22702.c +++ b/drivers/media/dvb/frontends/cx22702.c @@ -92,33 +92,36 @@ static int cx22702_writereg(struct cx22702_state *state, u8 reg, u8 data) ret = i2c_transfer(state->i2c, &msg, 1); - if (ret != 1) + if (unlikely(ret != 1)) { printk(KERN_ERR "%s: error (reg == 0x%02x, val == 0x%02x, ret == %i)\n", __func__, reg, data, ret); + return -1; + } - return (ret != 1) ? -1 : 0; + return 0; } static u8 cx22702_readreg(struct cx22702_state *state, u8 reg) { int ret; - u8 b0[] = { reg }; - u8 b1[] = { 0 }; + u8 data; struct i2c_msg msg[] = { { .addr = state->config->demod_address, .flags = 0, - .buf = b0, .len = 1 }, + .buf = ®, .len = 1 }, { .addr = state->config->demod_address, .flags = I2C_M_RD, - .buf = b1, .len = 1 } }; + .buf = &data, .len = 1 } }; ret = i2c_transfer(state->i2c, msg, 2); - if (ret != 2) - printk(KERN_ERR "%s: readreg error (ret == %i)\n", - __func__, ret); + if (unlikely(ret != 2)) { + printk(KERN_ERR "%s: error (reg == 0x%02x, ret == %i)\n", + __func__, reg, ret); + return 0; + } - return b1[0]; + return data; } static int cx22702_set_inversion(struct cx22702_state *state, int inversion) |