From patchwork Sun Mar 10 11:25:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Frank_Sch=C3=A4fer?= X-Patchwork-Id: 2244161 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 81743DF24C for ; Sun, 10 Mar 2013 11:24:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751768Ab3CJLYs (ORCPT ); Sun, 10 Mar 2013 07:24:48 -0400 Received: from mail-ee0-f53.google.com ([74.125.83.53]:42921 "EHLO mail-ee0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751338Ab3CJLYr (ORCPT ); Sun, 10 Mar 2013 07:24:47 -0400 Received: by mail-ee0-f53.google.com with SMTP id e53so1705897eek.12 for ; Sun, 10 Mar 2013 04:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:mime-version :content-type:content-transfer-encoding; bh=SeGZFPHEYhnUky7/B6fxl4Ulu5U124yYChdbaUGzVXw=; b=ntTmV/xkgCAh6ckVykKXOECJ6aZwrJfnbrm94OCjCwdW1dwUtuY+C3OV+WcIRA+0Mu /aNgdPWQ7dB3yoAdorP9c4+tCvG9POrEhhdV6whFfrmkqf+/hGQXq3lsjBfK+Jel5YsN wu18NVmuld+hAoISe9+fZgnsprvtLOAuqXaOz8iee2dZwCMlw/HCimoLuhMR7Zv+kIWk qZWHHIvsi6pOQVhKMajCynduGD9/o2qtsd71G5DqP1RucVLU6u3Gp74k6U32VlazfNxA E+HN0uXz4OH+BfsWtXj2a6izhDjJR1K1CYD5+MiSto/DoQcqT0Xn9crx7KXbl/hdyYrV PWGQ== X-Received: by 10.14.215.193 with SMTP id e41mr25363860eep.32.1362914686168; Sun, 10 Mar 2013 04:24:46 -0700 (PDT) Received: from Athlon64X2-5000.site (ip-178-200-115-25.unitymediagroup.de. [178.200.115.25]) by mx.google.com with ESMTPS id f47sm17799695eep.13.2013.03.10.04.24.44 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 10 Mar 2013 04:24:44 -0700 (PDT) From: =?UTF-8?q?Frank=20Sch=C3=A4fer?= To: mchehab@redhat.com Cc: linux-media@vger.kernel.org, =?UTF-8?q?Frank=20Sch=C3=A4fer?= Subject: [PATCH] em28xx-i2c: relax error check in em28xx_i2c_recv_bytes() Date: Sun, 10 Mar 2013 12:25:25 +0100 Message-Id: <1362914725-5172-1-git-send-email-fschaefer.oss@googlemail.com> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org It turned out that some devices return less bytes then requested via i2c when ALL of the following 3 conditions are met: - i2c bus B is used - there was no attempt to write to the specified slave address before - no device present at the specified slave address With the current code, this triggers an -EIO error and prints a message to the system log. Because it can happen very often during device probing, it is better to ignore this error and bail out silently after the follwing i2c transaction success check with -ENODEV. Signed-off-by: Frank Schäfer --- drivers/media/usb/em28xx/em28xx-i2c.c | 22 +++++++++++----------- 1 Datei geändert, 11 Zeilen hinzugefügt(+), 11 Zeilen entfernt(-) diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c index 6152423..94521bf 100644 --- a/drivers/media/usb/em28xx/em28xx-i2c.c +++ b/drivers/media/usb/em28xx/em28xx-i2c.c @@ -227,18 +227,18 @@ static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, u16 len) /* Read data from i2c device */ ret = dev->em28xx_read_reg_req_len(dev, 2, addr, buf, len); - if (ret != len) { - if (ret < 0) { - em28xx_warn("reading from i2c device at 0x%x failed " - "(error=%i)\n", addr, ret); - return ret; - } else { - em28xx_warn("%i bytes requested from i2c device at " - "0x%x, but %i bytes received\n", - len, addr, ret); - return -EIO; - } + if (ret < 0) { + em28xx_warn("reading from i2c device at 0x%x failed " + "(error=%i)\n", addr, ret); + return ret; } + /* NOTE: some devices with two i2c busses have the bad habit to return 0 + * 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 of the i2c operation */ ret = dev->em28xx_read_reg(dev, 0x05);