From patchwork Sun Jan 19 21:48:35 2014 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: 3510421 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 86FB6C02DC for ; Sun, 19 Jan 2014 21:47:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AFB6C2010E for ; Sun, 19 Jan 2014 21:47:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D55342010B for ; Sun, 19 Jan 2014 21:47:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752195AbaASVrq (ORCPT ); Sun, 19 Jan 2014 16:47:46 -0500 Received: from mail-ee0-f50.google.com ([74.125.83.50]:50760 "EHLO mail-ee0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752185AbaASVrp (ORCPT ); Sun, 19 Jan 2014 16:47:45 -0500 Received: by mail-ee0-f50.google.com with SMTP id d17so3071817eek.23 for ; Sun, 19 Jan 2014 13:47:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=+FyalYHmroAqgwjhzCFRrmmGLn1AVNSXpEH7Aw/FJh8=; b=cQwH6acOv6KOwyMZydXMHM8oXRWOCpEI+pW1OjO8Ebyh3EBfUqvKatHbDxl5g8iZal 8QSjSx4FkFiZ58rsJo2Z4Mwp5HjhPq/oVJ337HaWU+9qAI5u1G8IOJFf8MR3FVAdxG+n 089djyUulLRMXUm6T1+BaO6e5IENgdFaPOLruRp5dQwih8hkVu0CNaHj71+TOTT7pATN jdXDFAipgxTzGr/LC7EieeiLO92YNpQWVCAzpDAC+rc81uWLzi3IZA4REyPlDE/wd9lr bTGtOxvaUfVR6fkM0wvQXh1wIA6sHCvvyWAKXqJ8xM3PP0pgWmg1BRW8JeArIjmrA9Xx FAHg== X-Received: by 10.15.51.204 with SMTP id n52mr14606472eew.26.1390168064141; Sun, 19 Jan 2014 13:47:44 -0800 (PST) Received: from Athlon64X2-5000.site (ip-178-201-83-195.unitymediagroup.de. [178.201.83.195]) by mx.google.com with ESMTPSA id j46sm47007878eew.18.2014.01.19.13.47.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Jan 2014 13:47:43 -0800 (PST) From: =?UTF-8?q?Frank=20Sch=C3=A4fer?= To: m.chehab@samsung.com Cc: linux-media@vger.kernel.org, =?UTF-8?q?Frank=20Sch=C3=A4fer?= Subject: [PATCH 2/4] em28xx-i2c: fix the error code for unknown errors Date: Sun, 19 Jan 2014 22:48:35 +0100 Message-Id: <1390168117-2925-3-git-send-email-fschaefer.oss@googlemail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1390168117-2925-1-git-send-email-fschaefer.oss@googlemail.com> References: <1390168117-2925-1-git-send-email-fschaefer.oss@googlemail.com> MIME-Version: 1.0 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.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Commit e63b009d6e "em28xx-i2c: Fix error code for I2C error transfers" changed the code to return -ETIMEDOUT on all unknown errors. But the proper error code for unknown errors is -EIO. So only report -ETIMEDOUT in case of the errors 0x02 and 0x04, which are according to Mauro Carvalho Chehabs tests related to i2c clock stretching and return -EIO for the rest. Signed-off-by: Frank Schäfer --- drivers/media/usb/em28xx/em28xx-i2c.c | 29 +++++++++++++++++++++++------ 1 Datei geändert, 23 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-) diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c index bd8101d..ba6433c 100644 --- a/drivers/media/usb/em28xx/em28xx-i2c.c +++ b/drivers/media/usb/em28xx/em28xx-i2c.c @@ -226,10 +226,18 @@ static int em28xx_i2c_send_bytes(struct em28xx *dev, u16 addr, u8 *buf, * (even with high payload) ... */ } - if (i2c_debug) - em28xx_warn("write to i2c device at 0x%x timed out (status=%i)\n", - addr, ret); - return -ETIMEDOUT; + + if (ret == 0x02 || ret == 0x04) { + /* NOTE: these errors seem to be related to clock stretching */ + if (i2c_debug) + em28xx_warn("write to i2c device at 0x%x timed out (status=%i)\n", + addr, ret); + return -ETIMEDOUT; + } + + em28xx_warn("write to i2c device at 0x%x failed with unknown error (status=%i)\n", + addr, ret); + return -EIO; } /* @@ -279,8 +287,17 @@ static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, u16 len) return -ENXIO; } - em28xx_warn("unknown i2c error (status=%i)\n", ret); - return -ETIMEDOUT; + if (ret == 0x02 || ret == 0x04) { + /* NOTE: these errors seem to be related to clock stretching */ + if (i2c_debug) + em28xx_warn("write to i2c device at 0x%x timed out (status=%i)\n", + addr, ret); + return -ETIMEDOUT; + } + + em28xx_warn("write to i2c device at 0x%x failed with unknown error (status=%i)\n", + addr, ret); + return -EIO; } /*