From patchwork Sun Apr 9 19:38:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 9671719 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 A84B2600CB for ; Sun, 9 Apr 2017 19:38:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 949AD26E8A for ; Sun, 9 Apr 2017 19:38:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8988D27F10; Sun, 9 Apr 2017 19:38:41 +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 2206226E8A for ; Sun, 9 Apr 2017 19:38:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752569AbdDITij (ORCPT ); Sun, 9 Apr 2017 15:38:39 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:32886 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752440AbdDITif (ORCPT ); Sun, 9 Apr 2017 15:38:35 -0400 Received: by mail-wr0-f195.google.com with SMTP id l28so1779974wre.0 for ; Sun, 09 Apr 2017 12:38:34 -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=4Ngo6Az6wTK9XpimD4707V+OZ7ENZeZ+js46alwuuNM=; b=KL6w+w85WYm3w48Ezetb6qOL0wvh6Pul1v/HcnO8vgg7SR3MudtiQbQgikI4XWAuqz KP0Lsn0Sy4YOmQn5S30xQtZKqXYYUIOgPNGchGiQrlidOQJ8naamaDNusKJSt1i4GKM5 bKn2LLa8nCCmgfFB1yy4X+bzuVsOBSqEUVau8DKSEsDysUb2R5wu7A4fdx2+7q1GzHvg qwamx6rWQNjHjWVZ11gJ1mY/ZA3Av+vFsh/QpXow8R2daMT4U3Qe3hipwDx8cUljUmbt GnnsKhXE8GABk7yFLCzpnRa8QYuCmyXNYiD0fKaNhSZWBAsSvfJ6i01tlk9v38vofavB G7Nw== 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=4Ngo6Az6wTK9XpimD4707V+OZ7ENZeZ+js46alwuuNM=; b=FcOVfyprDa8iVtKIjGO1w64XMzk5ly8L+W66B6axAZl7qwfKjVYQb3XZXPP0Z0m897 /kvFi3CCvYXckuL6n9R6Q49QpsAHpZV9/Y6uh6qQ2G45FhRy0GyhQ3Fog80t+rfywKtf HiueZqUlLyFXfJRrojmgN3cCKDrhbDtFf1MPZHQMjhRYXlSVV4dzmPIYgPOCe4k61if4 igl+Uc0lfT+u8B7gmWJnyRMJNHfrb6waayTDuwxOW/cUzUv9bcGH3dE4c1rFPz1A3W0R CmxbFhEq0pSfddAKJUaUPJRWAxko0cw52DLsV+/iJXGUm9reGyt5lrO0mNDcnAfSd2ob mpQA== X-Gm-Message-State: AN3rC/7yXx4W/N3QtE1gmoezj1b5hzXi6H2lhR+adSBN23uXJUUeIE2H+3AmaD1PCp+ASw== X-Received: by 10.223.183.6 with SMTP id l6mr9392755wre.42.1491766713865; Sun, 09 Apr 2017 12:38:33 -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:33 -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 03/19] [media] dvb-frontends/cxd2841er: immediately unfreeze regs when done Date: Sun, 9 Apr 2017 21:38:12 +0200 Message-Id: <20170409193828.18458-4-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 Do unfreeze_regs() directly when accessing the demod registers is done, and don't have multiple unfreeze's on different conditions, which even can get prone to errors. Signed-off-by: Daniel Scheller Acked-by: Abylay Ospan --- drivers/media/dvb-frontends/cxd2841er.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/media/dvb-frontends/cxd2841er.c b/drivers/media/dvb-frontends/cxd2841er.c index 525d006..09c25d7 100644 --- a/drivers/media/dvb-frontends/cxd2841er.c +++ b/drivers/media/dvb-frontends/cxd2841er.c @@ -1410,11 +1410,11 @@ static int cxd2841er_read_ber_i(struct cxd2841er_priv *priv, cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x60); cxd2841er_read_regs(priv, I2C_SLVT, 0x5B, pktnum, sizeof(pktnum)); cxd2841er_read_regs(priv, I2C_SLVT, 0x16, data, sizeof(data)); + cxd2841er_unfreeze_regs(priv); if (!pktnum[0] && !pktnum[1]) { dev_dbg(&priv->i2c->dev, "%s(): no valid BER data\n", __func__); - cxd2841er_unfreeze_regs(priv); return -EINVAL; } @@ -1424,7 +1424,6 @@ static int cxd2841er_read_ber_i(struct cxd2841er_priv *priv, dev_dbg(&priv->i2c->dev, "%s(): bit_error=%u bit_count=%u\n", __func__, *bit_error, *bit_count); - cxd2841er_unfreeze_regs(priv); return 0; } @@ -1634,6 +1633,8 @@ static u32 cxd2841er_dvbs_read_snr(struct cxd2841er_priv *priv, * A1h 12h [7:0] ICPM_QUICKCNDT[7:0] */ cxd2841er_read_regs(priv, I2C_SLVT, 0x10, data, 3); + cxd2841er_unfreeze_regs(priv); + if (data[0] & 0x01) { value = ((u32)(data[1] & 0x1F) << 8) | (u32)(data[2] & 0xFF); min_index = 0; @@ -1676,11 +1677,9 @@ static u32 cxd2841er_dvbs_read_snr(struct cxd2841er_priv *priv, } else { dev_dbg(&priv->i2c->dev, "%s(): no data available\n", __func__); - cxd2841er_unfreeze_regs(priv); return -EINVAL; } done: - cxd2841er_unfreeze_regs(priv); *snr = res; return 0; } @@ -1709,12 +1708,12 @@ static int cxd2841er_read_snr_c(struct cxd2841er_priv *priv, u32 *snr) cxd2841er_read_regs(priv, I2C_SLVT, 0x19, data, 1); qam = (enum sony_dvbc_constellation_t) (data[0] & 0x07); cxd2841er_read_regs(priv, I2C_SLVT, 0x4C, data, 2); + cxd2841er_unfreeze_regs(priv); reg = ((u32)(data[0]&0x1f) << 8) | (u32)data[1]; if (reg == 0) { dev_dbg(&priv->i2c->dev, "%s(): reg value out of range\n", __func__); - cxd2841er_unfreeze_regs(priv); return 0; } @@ -1735,11 +1734,9 @@ static int cxd2841er_read_snr_c(struct cxd2841er_priv *priv, u32 *snr) *snr = -88 * (int32_t)sony_log(reg) + 86999; break; default: - cxd2841er_unfreeze_regs(priv); return -EINVAL; } - cxd2841er_unfreeze_regs(priv); return 0; } @@ -1758,17 +1755,17 @@ static int cxd2841er_read_snr_t(struct cxd2841er_priv *priv, u32 *snr) cxd2841er_freeze_regs(priv); cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10); cxd2841er_read_regs(priv, I2C_SLVT, 0x28, data, sizeof(data)); + cxd2841er_unfreeze_regs(priv); + reg = ((u32)data[0] << 8) | (u32)data[1]; if (reg == 0) { dev_dbg(&priv->i2c->dev, "%s(): reg value out of range\n", __func__); - cxd2841er_unfreeze_regs(priv); return 0; } if (reg > 4996) reg = 4996; *snr = 10000 * ((intlog10(reg) - intlog10(5350 - reg)) >> 24) + 28500; - cxd2841er_unfreeze_regs(priv); return 0; } @@ -1787,18 +1784,18 @@ static int cxd2841er_read_snr_t2(struct cxd2841er_priv *priv, u32 *snr) cxd2841er_freeze_regs(priv); cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x20); cxd2841er_read_regs(priv, I2C_SLVT, 0x28, data, sizeof(data)); + cxd2841er_unfreeze_regs(priv); + reg = ((u32)data[0] << 8) | (u32)data[1]; if (reg == 0) { dev_dbg(&priv->i2c->dev, "%s(): reg value out of range\n", __func__); - cxd2841er_unfreeze_regs(priv); return 0; } if (reg > 10876) reg = 10876; *snr = 10000 * ((intlog10(reg) - intlog10(12600 - reg)) >> 24) + 32000; - cxd2841er_unfreeze_regs(priv); return 0; } @@ -1818,15 +1815,15 @@ static int cxd2841er_read_snr_i(struct cxd2841er_priv *priv, u32 *snr) cxd2841er_freeze_regs(priv); cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x60); cxd2841er_read_regs(priv, I2C_SLVT, 0x28, data, sizeof(data)); + cxd2841er_unfreeze_regs(priv); + reg = ((u32)data[0] << 8) | (u32)data[1]; if (reg == 0) { dev_dbg(&priv->i2c->dev, "%s(): reg value out of range\n", __func__); - cxd2841er_unfreeze_regs(priv); return 0; } *snr = 10000 * (intlog10(reg) >> 24) - 9031; - cxd2841er_unfreeze_regs(priv); return 0; }