diff options
author | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2018-03-23 07:10:12 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2018-03-23 07:10:12 -0400 |
commit | c3902dab05a2a256607764ac0b5688f29ac544c7 (patch) | |
tree | dd0367710db6cb36be6a5e417fdc16c9fde2cab7 | |
parent | 5fd46ac9291402ba1d04e2c5ce3b295e1c13143e (diff) |
media: ir-kbd-i2c: improve error handling code
The current I2C error handling logic makes static analyzers
confused, and it doesn't follow the coding style we're using:
drivers/media/i2c/ir-kbd-i2c.c:180 get_key_pixelview() error: uninitialized symbol 'b'.
drivers/media/i2c/ir-kbd-i2c.c:224 get_key_knc1() error: uninitialized symbol 'b'.
drivers/media/i2c/ir-kbd-i2c.c:226 get_key_knc1() error: uninitialized symbol 'b'.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r-- | drivers/media/i2c/ir-kbd-i2c.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c index 193020d64e51..1d11aab1817a 100644 --- a/drivers/media/i2c/ir-kbd-i2c.c +++ b/drivers/media/i2c/ir-kbd-i2c.c | |||
@@ -168,11 +168,15 @@ static int get_key_haup_xvr(struct IR_i2c *ir, enum rc_proto *protocol, | |||
168 | static int get_key_pixelview(struct IR_i2c *ir, enum rc_proto *protocol, | 168 | static int get_key_pixelview(struct IR_i2c *ir, enum rc_proto *protocol, |
169 | u32 *scancode, u8 *toggle) | 169 | u32 *scancode, u8 *toggle) |
170 | { | 170 | { |
171 | int rc; | ||
171 | unsigned char b; | 172 | unsigned char b; |
172 | 173 | ||
173 | /* poll IR chip */ | 174 | /* poll IR chip */ |
174 | if (1 != i2c_master_recv(ir->c, &b, 1)) { | 175 | rc = i2c_master_recv(ir->c, &b, 1); |
176 | if (rc != 1) { | ||
175 | dev_dbg(&ir->rc->dev, "read error\n"); | 177 | dev_dbg(&ir->rc->dev, "read error\n"); |
178 | if (rc < 0) | ||
179 | return rc; | ||
176 | return -EIO; | 180 | return -EIO; |
177 | } | 181 | } |
178 | 182 | ||
@@ -185,11 +189,15 @@ static int get_key_pixelview(struct IR_i2c *ir, enum rc_proto *protocol, | |||
185 | static int get_key_fusionhdtv(struct IR_i2c *ir, enum rc_proto *protocol, | 189 | static int get_key_fusionhdtv(struct IR_i2c *ir, enum rc_proto *protocol, |
186 | u32 *scancode, u8 *toggle) | 190 | u32 *scancode, u8 *toggle) |
187 | { | 191 | { |
192 | int rc; | ||
188 | unsigned char buf[4]; | 193 | unsigned char buf[4]; |
189 | 194 | ||
190 | /* poll IR chip */ | 195 | /* poll IR chip */ |
191 | if (4 != i2c_master_recv(ir->c, buf, 4)) { | 196 | rc = i2c_master_recv(ir->c, buf, 4); |
197 | if (rc != 4) { | ||
192 | dev_dbg(&ir->rc->dev, "read error\n"); | 198 | dev_dbg(&ir->rc->dev, "read error\n"); |
199 | if (rc < 0) | ||
200 | return rc; | ||
193 | return -EIO; | 201 | return -EIO; |
194 | } | 202 | } |
195 | 203 | ||
@@ -209,11 +217,15 @@ static int get_key_fusionhdtv(struct IR_i2c *ir, enum rc_proto *protocol, | |||
209 | static int get_key_knc1(struct IR_i2c *ir, enum rc_proto *protocol, | 217 | static int get_key_knc1(struct IR_i2c *ir, enum rc_proto *protocol, |
210 | u32 *scancode, u8 *toggle) | 218 | u32 *scancode, u8 *toggle) |
211 | { | 219 | { |
220 | int rc; | ||
212 | unsigned char b; | 221 | unsigned char b; |
213 | 222 | ||
214 | /* poll IR chip */ | 223 | /* poll IR chip */ |
215 | if (1 != i2c_master_recv(ir->c, &b, 1)) { | 224 | rc = i2c_master_recv(ir->c, &b, 1); |
225 | if (rc != 1) { | ||
216 | dev_dbg(&ir->rc->dev, "read error\n"); | 226 | dev_dbg(&ir->rc->dev, "read error\n"); |
227 | if (rc < 0) | ||
228 | return rc; | ||
217 | return -EIO; | 229 | return -EIO; |
218 | } | 230 | } |
219 | 231 | ||