aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorOliver Endriss <o.endriss@gmx.de>2009-02-28 08:35:48 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:43:08 -0400
commit632fe9fe440249642845675d97436c667cbbd21e (patch)
tree2c247394a041a927e1a282b1488ddd249794ee36 /drivers
parent7c9e34aaab50a6c8f69ce59816dd76a283090667 (diff)
V4L/DVB (10843): saa7146: Clean-up i2c error handling
saa7146: Clean-up i2c error handling Simplify i2c error handling and fix incorrect handling of address errors in poll mode. Signed-off-by: Oliver Endriss <o.endriss@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/common/saa7146_i2c.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/drivers/media/common/saa7146_i2c.c b/drivers/media/common/saa7146_i2c.c
index 76229f992275..7e8f56815998 100644
--- a/drivers/media/common/saa7146_i2c.c
+++ b/drivers/media/common/saa7146_i2c.c
@@ -293,7 +293,6 @@ static int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *m
293 int i = 0, count = 0; 293 int i = 0, count = 0;
294 __le32 *buffer = dev->d_i2c.cpu_addr; 294 __le32 *buffer = dev->d_i2c.cpu_addr;
295 int err = 0; 295 int err = 0;
296 int address_err = 0;
297 int short_delay = 0; 296 int short_delay = 0;
298 297
299 if (mutex_lock_interruptible(&dev->i2c_lock)) 298 if (mutex_lock_interruptible(&dev->i2c_lock))
@@ -333,17 +332,10 @@ static int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *m
333 i2c address probing, however, and address errors indicate that a 332 i2c address probing, however, and address errors indicate that a
334 device is really *not* there. retrying in that case 333 device is really *not* there. retrying in that case
335 increases the time the device needs to probe greatly, so 334 increases the time the device needs to probe greatly, so
336 it should be avoided. because of the fact, that only 335 it should be avoided. So we bail out in irq mode after an
337 analog based cards use irq based i2c transactions (for dvb 336 address error and trust the saa7146 address error detection. */
338 cards, this screwes up other interrupt sources), we bail out 337 if (-EREMOTEIO == err && 0 != (SAA7146_USE_I2C_IRQ & dev->ext->flags))
339 completely for analog cards after an address error and trust 338 goto out;
340 the saa7146 address error detection. */
341 if ( -EREMOTEIO == err ) {
342 if( 0 != (SAA7146_USE_I2C_IRQ & dev->ext->flags)) {
343 goto out;
344 }
345 address_err++;
346 }
347 DEB_I2C(("error while sending message(s). starting again.\n")); 339 DEB_I2C(("error while sending message(s). starting again.\n"));
348 break; 340 break;
349 } 341 }
@@ -358,10 +350,9 @@ static int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *m
358 350
359 } while (err != num && retries--); 351 } while (err != num && retries--);
360 352
361 /* if every retry had an address error, exit right away */ 353 /* quit if any error occurred */
362 if (address_err == retries) { 354 if (err != num)
363 goto out; 355 goto out;
364 }
365 356
366 /* if any things had to be read, get the results */ 357 /* if any things had to be read, get the results */
367 if ( 0 != saa7146_i2c_msg_cleanup(msgs, num, buffer)) { 358 if ( 0 != saa7146_i2c_msg_cleanup(msgs, num, buffer)) {