Return-path: Received: from bombadil.infradead.org ([198.137.202.9]:50191 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755229Ab3L1MQ1 (ORCPT ); Sat, 28 Dec 2013 07:16:27 -0500 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab Subject: [PATCH v3 22/24] em28xx: use a better value for I2C timeouts Date: Sat, 28 Dec 2013 10:16:14 -0200 Message-Id: <1388232976-20061-23-git-send-email-mchehab@redhat.com> In-Reply-To: <1388232976-20061-1-git-send-email-mchehab@redhat.com> References: <1388232976-20061-1-git-send-email-mchehab@redhat.com> To: unlisted-recipients:; (no To-header on input)@casper.infradead.org Sender: linux-media-owner@vger.kernel.org List-ID: From: Mauro Carvalho Chehab In the lack of a better spec, let's assume the timeout values compatible with SMBus spec: http://smbus.org/specs/smbus110.pdf at chapter 8 - Electrical Characteristics of SMBus devices Ok, SMBus is a subset of I2C, and not all devices will be following it, but the timeout value before this patch was not even following the spec. So, while we don't have a better guess for it, use 35 + 1 ms as the timeout. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/em28xx/em28xx.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h index db47c2236ca4..9af19332b0f1 100644 --- a/drivers/media/usb/em28xx/em28xx.h +++ b/drivers/media/usb/em28xx/em28xx.h @@ -183,8 +183,21 @@ #define EM28XX_INTERLACED_DEFAULT 1 -/* time in msecs to wait for i2c xfers to finish */ -#define EM2800_I2C_XFER_TIMEOUT 20 +/* + * Time in msecs to wait for i2c xfers to finish. + * 35ms is the maximum time a SMBUS device could wait when + * clock stretching is used. As the transfer itself will take + * some time to happen, set it to 35 ms. + * + * Ok, I2C doesn't specify any limit. So, eventually, we may need + * to increase this timeout. + * + * FIXME: this assumes that an I2C message is not longer than 1ms. + * This is actually dependent on the I2C bus speed, although most + * devices use a 100kHz clock. So, this assumtion is true most of + * the time. + */ +#define EM2800_I2C_XFER_TIMEOUT 36 /* time in msecs to wait for AC97 xfers to finish */ #define EM2800_AC97_XFER_TIMEOUT 100 -- 1.8.3.1