aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorErik Andr?n <erik.andren@gmail.com>2009-01-02 15:58:08 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-04-06 20:44:44 -0400
commit6b0555008e03209b1590054960b4a3506301071c (patch)
tree28141fb7ac686141ff26766e264ae08beffe14a0 /drivers/media
parent7136e705d8db46f22657523ee108be35c59ce3e9 (diff)
V4L/DVB (11420): gspca - m5602: Improve error handling in the ov9650 driver
Some errors were not propagated properly. Signed-off-by: Erik Andrén <erik.andren@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/gspca/m5602/m5602_ov9650.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/media/video/gspca/m5602/m5602_ov9650.c b/drivers/media/video/gspca/m5602/m5602_ov9650.c
index da6b72a7cf6f..292f2d41fba5 100644
--- a/drivers/media/video/gspca/m5602/m5602_ov9650.c
+++ b/drivers/media/video/gspca/m5602/m5602_ov9650.c
@@ -218,6 +218,7 @@ static void ov9650_dump_registers(struct sd *sd);
218 218
219int ov9650_probe(struct sd *sd) 219int ov9650_probe(struct sd *sd)
220{ 220{
221 int err = 0;
221 u8 prod_id = 0, ver_id = 0, i; 222 u8 prod_id = 0, ver_id = 0, i;
222 223
223 if (force_sensor) { 224 if (force_sensor) {
@@ -233,15 +234,18 @@ int ov9650_probe(struct sd *sd)
233 info("Probing for an ov9650 sensor"); 234 info("Probing for an ov9650 sensor");
234 235
235 /* Run the pre-init to actually probe the unit */ 236 /* Run the pre-init to actually probe the unit */
236 for (i = 0; i < ARRAY_SIZE(preinit_ov9650); i++) { 237 for (i = 0; i < ARRAY_SIZE(preinit_ov9650) && !err; i++) {
237 u8 data = preinit_ov9650[i][2]; 238 u8 data = preinit_ov9650[i][2];
238 if (preinit_ov9650[i][0] == SENSOR) 239 if (preinit_ov9650[i][0] == SENSOR)
239 m5602_write_sensor(sd, 240 err = m5602_write_sensor(sd,
240 preinit_ov9650[i][1], &data, 1); 241 preinit_ov9650[i][1], &data, 1);
241 else 242 else
242 m5602_write_bridge(sd, preinit_ov9650[i][1], data); 243 err = m5602_write_bridge(sd, preinit_ov9650[i][1], data);
243 } 244 }
244 245
246 if (err < 0)
247 return err;
248
245 if (m5602_read_sensor(sd, OV9650_PID, &prod_id, 1)) 249 if (m5602_read_sensor(sd, OV9650_PID, &prod_id, 1))
246 return -ENODEV; 250 return -ENODEV;
247 251
@@ -458,7 +462,10 @@ int ov9650_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
458 u8 i2c_data; 462 u8 i2c_data;
459 struct sd *sd = (struct sd *) gspca_dev; 463 struct sd *sd = (struct sd *) gspca_dev;
460 464
461 m5602_read_sensor(sd, OV9650_VREF, &i2c_data, 1); 465 err = m5602_read_sensor(sd, OV9650_VREF, &i2c_data, 1);
466 if (err < 0)
467 return err;
468
462 *val = (i2c_data & 0x03) << 8; 469 *val = (i2c_data & 0x03) << 8;
463 470
464 err = m5602_read_sensor(sd, OV9650_GAIN, &i2c_data, 1); 471 err = m5602_read_sensor(sd, OV9650_GAIN, &i2c_data, 1);
@@ -476,11 +483,16 @@ int ov9650_set_gain(struct gspca_dev *gspca_dev, __s32 val)
476 /* The 2 MSB */ 483 /* The 2 MSB */
477 /* Read the OV9650_VREF register first to avoid 484 /* Read the OV9650_VREF register first to avoid
478 corrupting the VREF high and low bits */ 485 corrupting the VREF high and low bits */
479 m5602_read_sensor(sd, OV9650_VREF, &i2c_data, 1); 486 err = m5602_read_sensor(sd, OV9650_VREF, &i2c_data, 1);
487 if (err < 0)
488 return err;
489
480 /* Mask away all uninteresting bits */ 490 /* Mask away all uninteresting bits */
481 i2c_data = ((val & 0x0300) >> 2) | 491 i2c_data = ((val & 0x0300) >> 2) |
482 (i2c_data & 0x3F); 492 (i2c_data & 0x3F);
483 err = m5602_write_sensor(sd, OV9650_VREF, &i2c_data, 1); 493 err = m5602_write_sensor(sd, OV9650_VREF, &i2c_data, 1);
494 if (err < 0)
495 return err;
484 496
485 /* The 8 LSBs */ 497 /* The 8 LSBs */
486 i2c_data = val & 0xff; 498 i2c_data = val & 0xff;