From patchwork Sat Dec 28 12:16:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 3413921 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2F1799F374 for ; Sat, 28 Dec 2013 12:17:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 47ECF2015D for ; Sat, 28 Dec 2013 12:17:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6B5652012B for ; Sat, 28 Dec 2013 12:17:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755271Ab3L1MQr (ORCPT ); Sat, 28 Dec 2013 07:16:47 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:50198 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755240Ab3L1MQ2 (ORCPT ); Sat, 28 Dec 2013 07:16:28 -0500 Received: from [177.28.171.132] (helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vwsoc-0002UQ-35; Sat, 28 Dec 2013 12:16:26 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.80.1) (envelope-from ) id 1VwsoU-0007sS-LA; Sat, 28 Dec 2013 10:16:18 -0200 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab Subject: [PATCH v3 08/24] em28xx: add warn messages for timeout Date: Sat, 28 Dec 2013 10:16:00 -0200 Message-Id: <1388232976-20061-9-git-send-email-mchehab@redhat.com> X-Mailer: git-send-email 1.8.3.1 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) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mauro Carvalho Chehab changeset 45f04e82d035 added a logic to check if em28xx got a timeout on an I2C transfer. That patch started to produce a series of errors that is present with HVR-950, like: [ 4032.218656] xc2028 19-0061: Error on line 1299: -19 However, as there are several places where -ENODEV is produced, there's no way to know what's happening. So, let's add a printk to report what error condition was reached: [ 4032.218652] em2882/3 #0: I2C transfer timeout on writing to addr 0xc2 [ 4032.218656] xc2028 19-0061: Error on line 1299: -19 Interesting enough, when connected to an USB3 port, the number of errors increase: [ 4249.941375] em2882/3 #0: I2C transfer timeout on writing to addr 0xb8 [ 4249.941378] tvp5150 19-005c: i2c i/o error: rc == -19 (should be 2) [ 4250.023854] em2882/3 #0: I2C transfer timeout on writing to addr 0xc2 [ 4250.023857] xc2028 19-0061: Error on line 1299: -19 Due to that, I suspect that the logic in the driver is wrong: instead of just returning an error if 0x10 is returned, it should be waiting for a while and read the I2C status register again. However, more tests are needed. For now, instead of just returning -ENODEV, output an error message to help debug what's happening. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/em28xx/em28xx-i2c.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c index c4ff9739a7ae..9e6a11d01858 100644 --- a/drivers/media/usb/em28xx/em28xx-i2c.c +++ b/drivers/media/usb/em28xx/em28xx-i2c.c @@ -80,6 +80,7 @@ static int em2800_i2c_send_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len) if (ret == 0x80 + len - 1) { return len; } else if (ret == 0x94 + len - 1) { + em28xx_warn("R05 returned 0x%02x: I2C timeout", ret); return -ENODEV; } else if (ret < 0) { em28xx_warn("failed to get i2c transfer status from bridge register (error=%i)\n", @@ -123,6 +124,7 @@ static int em2800_i2c_recv_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len) if (ret == 0x84 + len - 1) { break; } else if (ret == 0x94 + len - 1) { + em28xx_warn("R05 returned 0x%02x: I2C timeout", ret); return -ENODEV; } else if (ret < 0) { em28xx_warn("failed to get i2c transfer status from bridge register (error=%i)\n", @@ -198,6 +200,7 @@ static int em28xx_i2c_send_bytes(struct em28xx *dev, u16 addr, u8 *buf, if (ret == 0) { /* success */ return len; } else if (ret == 0x10) { + em28xx_warn("I2C transfer timeout on writing to addr 0x%02x", addr); return -ENODEV; } else if (ret < 0) { em28xx_warn("failed to read i2c transfer status from bridge (error=%i)\n", @@ -255,6 +258,7 @@ static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, u16 len) } if (ret > 0) { if (ret == 0x10) { + em28xx_warn("I2C transfer timeout on read from addr 0x%02x", addr); return -ENODEV; } else { em28xx_warn("unknown i2c error (status=%i)\n", ret); @@ -316,8 +320,10 @@ static int em25xx_bus_B_send_bytes(struct em28xx *dev, u16 addr, u8 *buf, */ if (!ret) return len; - else if (ret > 0) + else if (ret > 0) { + em28xx_warn("Bus B R08 returned 0x%02x: I2C timeout", ret); return -ENODEV; + } return ret; /* @@ -367,8 +373,10 @@ static int em25xx_bus_B_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, */ if (!ret) return len; - else if (ret > 0) + else if (ret > 0) { + em28xx_warn("Bus B R08 returned 0x%02x: I2C timeout", ret); return -ENODEV; + } return ret; /*