提交 5fd46ac9 编写于 作者: M Mauro Carvalho Chehab

media: saa7134-input: improve error handling

Currently, the code produces those false-positives:
	drivers/media/pci/saa7134/saa7134-input.c:203 get_key_msi_tvanywhere_plus() error: uninitialized symbol 'b'.
	drivers/media/pci/saa7134/saa7134-input.c:251 get_key_kworld_pc150u() error: uninitialized symbol 'b'.
	drivers/media/pci/saa7134/saa7134-input.c:275 get_key_purpletv() error: uninitialized symbol 'b'.

Improve the error handling code, making it to look like our
coding style.
Signed-off-by: NMauro Carvalho Chehab <mchehab@s-opensource.com>
上级 86f181c7
...@@ -115,7 +115,7 @@ static int build_key(struct saa7134_dev *dev) ...@@ -115,7 +115,7 @@ static int build_key(struct saa7134_dev *dev)
static int get_key_flydvb_trio(struct IR_i2c *ir, enum rc_proto *protocol, static int get_key_flydvb_trio(struct IR_i2c *ir, enum rc_proto *protocol,
u32 *scancode, u8 *toggle) u32 *scancode, u8 *toggle)
{ {
int gpio; int gpio, rc;
int attempt = 0; int attempt = 0;
unsigned char b; unsigned char b;
...@@ -153,8 +153,11 @@ static int get_key_flydvb_trio(struct IR_i2c *ir, enum rc_proto *protocol, ...@@ -153,8 +153,11 @@ static int get_key_flydvb_trio(struct IR_i2c *ir, enum rc_proto *protocol,
attempt); attempt);
return -EIO; return -EIO;
} }
if (1 != i2c_master_recv(ir->c, &b, 1)) { rc = i2c_master_recv(ir->c, &b, 1);
if (rc != 1) {
ir_dbg(ir, "read error\n"); ir_dbg(ir, "read error\n");
if (rc < 0)
return rc;
return -EIO; return -EIO;
} }
...@@ -169,7 +172,7 @@ static int get_key_msi_tvanywhere_plus(struct IR_i2c *ir, ...@@ -169,7 +172,7 @@ static int get_key_msi_tvanywhere_plus(struct IR_i2c *ir,
u32 *scancode, u8 *toggle) u32 *scancode, u8 *toggle)
{ {
unsigned char b; unsigned char b;
int gpio; int gpio, rc;
/* <dev> is needed to access GPIO. Used by the saa_readl macro. */ /* <dev> is needed to access GPIO. Used by the saa_readl macro. */
struct saa7134_dev *dev = ir->c->adapter->algo_data; struct saa7134_dev *dev = ir->c->adapter->algo_data;
...@@ -193,8 +196,11 @@ static int get_key_msi_tvanywhere_plus(struct IR_i2c *ir, ...@@ -193,8 +196,11 @@ static int get_key_msi_tvanywhere_plus(struct IR_i2c *ir,
/* GPIO says there is a button press. Get it. */ /* GPIO says there is a button press. Get it. */
if (1 != i2c_master_recv(ir->c, &b, 1)) { rc = i2c_master_recv(ir->c, &b, 1);
if (rc != 1) {
ir_dbg(ir, "read error\n"); ir_dbg(ir, "read error\n");
if (rc < 0)
return rc;
return -EIO; return -EIO;
} }
...@@ -218,6 +224,7 @@ static int get_key_kworld_pc150u(struct IR_i2c *ir, enum rc_proto *protocol, ...@@ -218,6 +224,7 @@ static int get_key_kworld_pc150u(struct IR_i2c *ir, enum rc_proto *protocol,
{ {
unsigned char b; unsigned char b;
unsigned int gpio; unsigned int gpio;
int rc;
/* <dev> is needed to access GPIO. Used by the saa_readl macro. */ /* <dev> is needed to access GPIO. Used by the saa_readl macro. */
struct saa7134_dev *dev = ir->c->adapter->algo_data; struct saa7134_dev *dev = ir->c->adapter->algo_data;
...@@ -241,8 +248,11 @@ static int get_key_kworld_pc150u(struct IR_i2c *ir, enum rc_proto *protocol, ...@@ -241,8 +248,11 @@ static int get_key_kworld_pc150u(struct IR_i2c *ir, enum rc_proto *protocol,
/* GPIO says there is a button press. Get it. */ /* GPIO says there is a button press. Get it. */
if (1 != i2c_master_recv(ir->c, &b, 1)) { rc = i2c_master_recv(ir->c, &b, 1);
if (rc != 1) {
ir_dbg(ir, "read error\n"); ir_dbg(ir, "read error\n");
if (rc < 0)
return rc;
return -EIO; return -EIO;
} }
...@@ -263,11 +273,15 @@ static int get_key_kworld_pc150u(struct IR_i2c *ir, enum rc_proto *protocol, ...@@ -263,11 +273,15 @@ static int get_key_kworld_pc150u(struct IR_i2c *ir, enum rc_proto *protocol,
static int get_key_purpletv(struct IR_i2c *ir, enum rc_proto *protocol, static int get_key_purpletv(struct IR_i2c *ir, enum rc_proto *protocol,
u32 *scancode, u8 *toggle) u32 *scancode, u8 *toggle)
{ {
int rc;
unsigned char b; unsigned char b;
/* poll IR chip */ /* poll IR chip */
if (1 != i2c_master_recv(ir->c, &b, 1)) { rc = i2c_master_recv(ir->c, &b, 1);
if (rc != 1) {
ir_dbg(ir, "read error\n"); ir_dbg(ir, "read error\n");
if (rc < 0)
return rc;
return -EIO; return -EIO;
} }
...@@ -288,11 +302,17 @@ static int get_key_purpletv(struct IR_i2c *ir, enum rc_proto *protocol, ...@@ -288,11 +302,17 @@ static int get_key_purpletv(struct IR_i2c *ir, enum rc_proto *protocol,
static int get_key_hvr1110(struct IR_i2c *ir, enum rc_proto *protocol, static int get_key_hvr1110(struct IR_i2c *ir, enum rc_proto *protocol,
u32 *scancode, u8 *toggle) u32 *scancode, u8 *toggle)
{ {
int rc;
unsigned char buf[5]; unsigned char buf[5];
/* poll IR chip */ /* poll IR chip */
if (5 != i2c_master_recv(ir->c, buf, 5)) rc = i2c_master_recv(ir->c, buf, 5);
if (rc != 5) {
ir_dbg(ir, "read error\n");
if (rc < 0)
return rc;
return -EIO; return -EIO;
}
/* Check if some key were pressed */ /* Check if some key were pressed */
if (!(buf[0] & 0x80)) if (!(buf[0] & 0x80))
...@@ -319,6 +339,7 @@ static int get_key_hvr1110(struct IR_i2c *ir, enum rc_proto *protocol, ...@@ -319,6 +339,7 @@ static int get_key_hvr1110(struct IR_i2c *ir, enum rc_proto *protocol,
static int get_key_beholdm6xx(struct IR_i2c *ir, enum rc_proto *protocol, static int get_key_beholdm6xx(struct IR_i2c *ir, enum rc_proto *protocol,
u32 *scancode, u8 *toggle) u32 *scancode, u8 *toggle)
{ {
int rc;
unsigned char data[12]; unsigned char data[12];
u32 gpio; u32 gpio;
...@@ -335,8 +356,11 @@ static int get_key_beholdm6xx(struct IR_i2c *ir, enum rc_proto *protocol, ...@@ -335,8 +356,11 @@ static int get_key_beholdm6xx(struct IR_i2c *ir, enum rc_proto *protocol,
ir->c->addr = 0x5a >> 1; ir->c->addr = 0x5a >> 1;
if (12 != i2c_master_recv(ir->c, data, 12)) { rc = i2c_master_recv(ir->c, data, 12);
if (rc != 12) {
ir_dbg(ir, "read error\n"); ir_dbg(ir, "read error\n");
if (rc < 0)
return rc;
return -EIO; return -EIO;
} }
...@@ -356,12 +380,16 @@ static int get_key_pinnacle(struct IR_i2c *ir, enum rc_proto *protocol, ...@@ -356,12 +380,16 @@ static int get_key_pinnacle(struct IR_i2c *ir, enum rc_proto *protocol,
u32 *scancode, u8 *toggle, int parity_offset, u32 *scancode, u8 *toggle, int parity_offset,
int marker, int code_modulo) int marker, int code_modulo)
{ {
int rc;
unsigned char b[4]; unsigned char b[4];
unsigned int start = 0,parity = 0,code = 0; unsigned int start = 0,parity = 0,code = 0;
/* poll IR chip */ /* poll IR chip */
if (4 != i2c_master_recv(ir->c, b, 4)) { rc = i2c_master_recv(ir->c, b, 4);
if (rc != 4) {
ir_dbg(ir, "read error\n"); ir_dbg(ir, "read error\n");
if (rc < 0)
return rc;
return -EIO; return -EIO;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册