From patchwork Sun Apr 9 19:38:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 9671717 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1940160381 for ; Sun, 9 Apr 2017 19:38:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05D1426E8A for ; Sun, 9 Apr 2017 19:38:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE6A127F10; Sun, 9 Apr 2017 19:38:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A916326E8A for ; Sun, 9 Apr 2017 19:38:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752553AbdDITih (ORCPT ); Sun, 9 Apr 2017 15:38:37 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:34066 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752427AbdDITie (ORCPT ); Sun, 9 Apr 2017 15:38:34 -0400 Received: by mail-wr0-f195.google.com with SMTP id u18so18615244wrc.1 for ; Sun, 09 Apr 2017 12:38:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=22MuqAzaDBzB08FVjKUkUg0RHlWB0WW40Y7UwMWli3A=; b=BJaDG3tvguGOqxttXFNuBXeM942K/VaIhD8vIbimhmRoMsgM4CxaViicdJmNpNL++w hACyDXNjMESN6lCez3vWhRkGMVnINtIluF0w37CmmcnE8rYzWGw4HLFc03cF+ZVvhvQu 7JyS4nc3p/AyUN1Yf+RAuiw5ree0A1dLVfqg9V1DLiMWXotJ/8BXdQ3uI8DYxlqMpczX 33LPbzsNwbLmbWnXyvltVOgyt8v1z9WD/5kbbi7Aj1El2suSrI92/iAZxGD+WaW4yaJt o+7BvZyGHXOR5ENcFpeiOnsrx0zqnyWgIp36aSXeFvP4eRQhtryC617CvorjANtoqzCO uIfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=22MuqAzaDBzB08FVjKUkUg0RHlWB0WW40Y7UwMWli3A=; b=OdYEYwxenYbcwudrE8uevlAZulZ0EeSNKyN14Xn3vtA1kF+EldbfFLnrfAOGNYF5Ll Z2EU16mF16nSopcJXjygqqocTP8MInKTCrCmZmj46gy2nw0gP66tL2ogT7BXC5uxsQQK iXyy18bV5gt4pWNweiM+R6DHJh2BxRRias1kNoPULj39XWVMvQCGdkfAXOlkGT/Xkr8g e3zXqryKhT40Ir8BJKf3leeH0z0eg3NtlBlFZaFwHCayq6cKrs+h1OVt3BZTMfg+KaV8 SMfNd3OyTHL0cRIG0I5L03hySf583OR5AAt63LqGNoqeJjayJTZBWTq58JC1plTkq33n +i8w== X-Gm-Message-State: AFeK/H3FsPALh3ELnA3faNlrdKwxwRsGZj64CHRE7bceQZ+vnj6gqMcrsVB19dNveAZpIQ== X-Received: by 10.223.153.233 with SMTP id y96mr26500012wrb.96.1491766712948; Sun, 09 Apr 2017 12:38:32 -0700 (PDT) Received: from dvbdev.wuest.de (ip-37-24-178-151.hsi14.unitymediagroup.de. [37.24.178.151]) by smtp.gmail.com with ESMTPSA id f135sm7441407wmd.7.2017.04.09.12.38.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 09 Apr 2017 12:38:32 -0700 (PDT) From: Daniel Scheller To: aospan@netup.ru, serjk@netup.ru, mchehab@kernel.org, linux-media@vger.kernel.org Cc: rjkm@metzlerbros.de Subject: [PATCH 02/19] [media] dvb-frontends/cxd2841er: do I2C reads in one go Date: Sun, 9 Apr 2017 21:38:11 +0200 Message-Id: <20170409193828.18458-3-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170409193828.18458-1-d.scheller.oss@gmail.com> References: <20170409193828.18458-1-d.scheller.oss@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Daniel Scheller Doing the I2C read operation with two calls to i2c_transfer() causes the exclusive I2C bus lock of the underlying adapter to be released. While this isn't an issue if only one demodulator is attached to the bus, having two or even more causes troubles in that concurrent accesses to the different demods will cause all kinds of issues due to wrong data being returned on read operations (for example, the TS config register will be set wrong). This changes the read_regs() function to do the operation in one go (by calling i2c_transfer with the whole msg list instead of one by one) to not loose the I2C bus lock, fixing all sorts of random runtime failures. Signed-off-by: Daniel Scheller Acked-by: Abylay Ospan --- drivers/media/dvb-frontends/cxd2841er.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/media/dvb-frontends/cxd2841er.c b/drivers/media/dvb-frontends/cxd2841er.c index 60d85ce..525d006 100644 --- a/drivers/media/dvb-frontends/cxd2841er.c +++ b/drivers/media/dvb-frontends/cxd2841er.c @@ -282,17 +282,8 @@ static int cxd2841er_read_regs(struct cxd2841er_priv *priv, } }; - ret = i2c_transfer(priv->i2c, &msg[0], 1); - if (ret >= 0 && ret != 1) - ret = -EIO; - if (ret < 0) { - dev_warn(&priv->i2c->dev, - "%s: i2c rw failed=%d addr=%02x reg=%02x\n", - KBUILD_MODNAME, ret, i2c_addr, reg); - return ret; - } - ret = i2c_transfer(priv->i2c, &msg[1], 1); - if (ret >= 0 && ret != 1) + ret = i2c_transfer(priv->i2c, msg, 2); + if (ret >= 0 && ret != 2) ret = -EIO; if (ret < 0) { dev_warn(&priv->i2c->dev,