aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb-frontends
diff options
context:
space:
mode:
authorRémi Cardona <remi.cardona@smartjog.com>2012-09-28 07:59:29 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-12-27 16:43:46 -0500
commitd58f4f27282e10b25daee53045a7e839bd4178a5 (patch)
treef106b7164df7cb6bfbb5c4dc1feeb946e2f6a82b /drivers/media/dvb-frontends
parent7e5d74ee116d9622fc4ef9f5100692485ae286cf (diff)
[media] ds3000: bail out early on i2c failures during firmware load
- if kmalloc() returns NULL, we can return immediately without trying to kfree() a NULL pointer. - if i2c_transfer() fails, error out immediately instead of trying to upload the remaining bytes of the firmware. - the error code is then properly propagated down to ds3000_initfe(). Signed-off-by: Rémi Cardona <remi.cardona@smartjog.com> Reviewed-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb-frontends')
-rw-r--r--drivers/media/dvb-frontends/ds3000.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/media/dvb-frontends/ds3000.c b/drivers/media/dvb-frontends/ds3000.c
index bc17e29b54d1..fded9b67456c 100644
--- a/drivers/media/dvb-frontends/ds3000.c
+++ b/drivers/media/dvb-frontends/ds3000.c
@@ -272,15 +272,14 @@ static int ds3000_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
272static int ds3000_writeFW(struct ds3000_state *state, int reg, 272static int ds3000_writeFW(struct ds3000_state *state, int reg,
273 const u8 *data, u16 len) 273 const u8 *data, u16 len)
274{ 274{
275 int i, ret = -EREMOTEIO; 275 int i, ret = 0;
276 struct i2c_msg msg; 276 struct i2c_msg msg;
277 u8 *buf; 277 u8 *buf;
278 278
279 buf = kmalloc(33, GFP_KERNEL); 279 buf = kmalloc(33, GFP_KERNEL);
280 if (buf == NULL) { 280 if (buf == NULL) {
281 printk(KERN_ERR "Unable to kmalloc\n"); 281 printk(KERN_ERR "Unable to kmalloc\n");
282 ret = -ENOMEM; 282 return -ENOMEM;
283 goto error;
284 } 283 }
285 284
286 *(buf) = reg; 285 *(buf) = reg;
@@ -300,8 +299,10 @@ static int ds3000_writeFW(struct ds3000_state *state, int reg,
300 printk(KERN_ERR "%s: write error(err == %i, " 299 printk(KERN_ERR "%s: write error(err == %i, "
301 "reg == 0x%02x\n", __func__, ret, reg); 300 "reg == 0x%02x\n", __func__, ret, reg);
302 ret = -EREMOTEIO; 301 ret = -EREMOTEIO;
302 goto error;
303 } 303 }
304 } 304 }
305 ret = 0;
305 306
306error: 307error:
307 kfree(buf); 308 kfree(buf);
@@ -384,6 +385,7 @@ static int ds3000_load_firmware(struct dvb_frontend *fe,
384 const struct firmware *fw) 385 const struct firmware *fw)
385{ 386{
386 struct ds3000_state *state = fe->demodulator_priv; 387 struct ds3000_state *state = fe->demodulator_priv;
388 int ret = 0;
387 389
388 dprintk("%s\n", __func__); 390 dprintk("%s\n", __func__);
389 dprintk("Firmware is %zu bytes (%02x %02x .. %02x %02x)\n", 391 dprintk("Firmware is %zu bytes (%02x %02x .. %02x %02x)\n",
@@ -396,10 +398,10 @@ static int ds3000_load_firmware(struct dvb_frontend *fe,
396 /* Begin the firmware load process */ 398 /* Begin the firmware load process */
397 ds3000_writereg(state, 0xb2, 0x01); 399 ds3000_writereg(state, 0xb2, 0x01);
398 /* write the entire firmware */ 400 /* write the entire firmware */
399 ds3000_writeFW(state, 0xb0, fw->data, fw->size); 401 ret = ds3000_writeFW(state, 0xb0, fw->data, fw->size);
400 ds3000_writereg(state, 0xb2, 0x00); 402 ds3000_writereg(state, 0xb2, 0x00);
401 403
402 return 0; 404 return ret;
403} 405}
404 406
405static int ds3000_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) 407static int ds3000_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)