From patchwork Sat Dec 28 12:16:15 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: 3413891 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 683D4C02DC for ; Sat, 28 Dec 2013 12:17:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6A32E2015D for ; Sat, 28 Dec 2013 12:17:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E30C2012B for ; Sat, 28 Dec 2013 12:17:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755237Ab3L1MQs (ORCPT ); Sat, 28 Dec 2013 07:16:48 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:50194 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755238Ab3L1MQ2 (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-0002UN-2l; 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 1VwsoV-0007tQ-1m; Sat, 28 Dec 2013 10:16:19 -0200 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab Subject: [PATCH v3 23/24] em28xx: don't return -ENODEV for I2C xfer errors Date: Sat, 28 Dec 2013 10:16:15 -0200 Message-Id: <1388232976-20061-24-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 -ENODEV reports a permanent condition where a device is not found. Except during device detection, this is not the case of I2C transfer timeout errors. So, change them to return -EIO instead. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/em28xx/em28xx-i2c.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c index 420fddf7da3a..16862c4cc745 100644 --- a/drivers/media/usb/em28xx/em28xx-i2c.c +++ b/drivers/media/usb/em28xx/em28xx-i2c.c @@ -81,7 +81,7 @@ static int em2800_i2c_send_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len) return len; if (ret == 0x94 + len - 1) { em28xx_warn("R05 returned 0x%02x: I2C timeout", ret); - return -ENODEV; + return -EIO; } if (ret < 0) { em28xx_warn("failed to get i2c transfer status from bridge register (error=%i)\n", @@ -125,7 +125,7 @@ static int em2800_i2c_recv_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len) break; if (ret == 0x94 + len - 1) { em28xx_warn("R05 returned 0x%02x: I2C timeout", ret); - return -ENODEV; + return -EIO; } if (ret < 0) { em28xx_warn("failed to get i2c transfer status from bridge register (error=%i)\n", @@ -214,7 +214,7 @@ retry: if (ret == 0x10) { em28xx_warn("I2C transfer timeout on writing to addr 0x%02x", addr); - return -ENODEV; + return -EIO; } em28xx_warn("write to i2c device at 0x%x timed out (ret=0x%02x)\n", addr, ret); @@ -250,7 +250,7 @@ static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, u16 len) * bytes if we are on bus B AND there was no write attempt to the * specified slave address before AND no device is present at the * requested slave address. - * Anyway, the next check will fail with -ENODEV in this case, so avoid + * Anyway, the next check will fail with -EIO in this case, so avoid * spamming the system log on device probing and do nothing here. */ @@ -270,7 +270,7 @@ static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, u16 len) if (ret == 0x10) { em28xx_warn("I2C transfer timeout on read from addr 0x%02x", addr); - return -ENODEV; + return -EIO; } em28xx_warn("unknown i2c error (status=%i)\n", ret); @@ -331,7 +331,7 @@ static int em25xx_bus_B_send_bytes(struct em28xx *dev, u16 addr, u8 *buf, return len; else if (ret > 0) { em28xx_warn("Bus B R08 returned 0x%02x: I2C timeout", ret); - return -ENODEV; + return -EIO; } return ret; @@ -370,8 +370,6 @@ static int em25xx_bus_B_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, * bytes if we are on bus B AND there was no write attempt to the * specified slave address before AND no device is present at the * requested slave address. - * Anyway, the next check will fail with -ENODEV in this case, so avoid - * spamming the system log on device probing and do nothing here. */ /* Check success */ @@ -384,7 +382,7 @@ static int em25xx_bus_B_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, return len; else if (ret > 0) { em28xx_warn("Bus B R08 returned 0x%02x: I2C timeout", ret); - return -ENODEV; + return -EIO; } return ret; @@ -426,7 +424,7 @@ static inline int i2c_check_for_device(struct em28xx_i2c_bus *i2c_bus, u16 addr) rc = em2800_i2c_check_for_device(dev, addr); else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM25XX_BUS_B) rc = em25xx_bus_B_check_for_device(dev, addr); - if (rc == -ENODEV) { + if (rc < 0) { if (i2c_debug) printk(" no device\n"); } @@ -516,7 +514,7 @@ static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap, addr, msgs[i].len); if (!msgs[i].len) { /* no len: check only for device presence */ rc = i2c_check_for_device(i2c_bus, addr); - if (rc == -ENODEV) { + if (rc < 0) { rt_mutex_unlock(&dev->i2c_bus_lock); return rc; }