media: bttv-input: better handle errors at I2C transfer
authorMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 23 Mar 2018 10:36:26 +0000 (06:36 -0400)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 23 Mar 2018 10:54:32 +0000 (06:54 -0400)
The error handling logic at get_key_pv951() is a little bit
akward, with produces this false positive warning:

drivers/media/pci/bt8xx/bttv-input.c:344 get_key_pv951() error: uninitialized symbol 'b'.

Do a cleanup. As a side effect, it also improves its coding
style.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/pci/bt8xx/bttv-input.c

index da49c5567db5045eb33842a7cb923db1826d6db3..08266b23826e10418a0d0a91a0603199f0d7124c 100644 (file)
@@ -332,11 +332,15 @@ static void bttv_ir_stop(struct bttv *btv)
 static int get_key_pv951(struct IR_i2c *ir, enum rc_proto *protocol,
                         u32 *scancode, u8 *toggle)
 {
+       int rc;
        unsigned char b;
 
        /* poll IR chip */
-       if (1 != i2c_master_recv(ir->c, &b, 1)) {
+       rc = i2c_master_recv(ir->c, &b, 1);
+       if (rc != 1) {
                dprintk("read error\n");
+               if (rc < 0)
+                       return rc;
                return -EIO;
        }