From patchwork Tue Mar 13 23:39:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antti Palosaari X-Patchwork-Id: 10281237 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 CA0E9601A0 for ; Tue, 13 Mar 2018 23:40:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B85D5285CA for ; Tue, 13 Mar 2018 23:40:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8384285CC; Tue, 13 Mar 2018 23:40:13 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI 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 73875285CA for ; Tue, 13 Mar 2018 23:40:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932783AbeCMXkL (ORCPT ); Tue, 13 Mar 2018 19:40:11 -0400 Received: from mail.kapsi.fi ([91.232.154.25]:56611 "EHLO mail.kapsi.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932443AbeCMXkK (ORCPT ); Tue, 13 Mar 2018 19:40:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kapsi.fi; s=20161220; h=Message-Id:Date:Subject:Cc:To:From; bh=zQS1IQjH/Ic+fyVvRBWbZVwdHFVcmN+WHusBTIpJnE0=; b=Ga6uU0KqxWFzvErZfCVCX18V8eDOFSYoCU8m2pkI4uU18cmqFQhj46qQTiwOZOwrEa7JCotZKdzKV/5eTNRnvsJRJhaytKqWNzW5FTHVfViZRNqtVUFAopWONmdl7bh9edQjSBIGN1aKlAxBuweO/X0e18/HnnosxDZwUptwjsBU+BBaQNjBY/waiKV5nNwggp9hSeWchGpwiqRDT+Nxfak+qHFIrg584Mja3oQgKTG7xS8ua70DVDFg2HYmGUtAk+8u9hwpDPnDW5DJQhKvXQlsJHDOrRqqSOD2dEqNHDCo7PZ8gLevREE/ZE7A2JueyvBe6m4+7XiQpxrCjNLnGA==; Received: from mobile-access-6df048-240.dhcp.inet.fi ([109.240.72.240] helo=localhost.localdomain) by mail.kapsi.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1evtWb-0005Ww-1D; Wed, 14 Mar 2018 01:40:09 +0200 From: Antti Palosaari To: linux-media@vger.kernel.org Cc: Antti Palosaari Subject: [PATCH 01/18] af9013: change lock detection slightly Date: Wed, 14 Mar 2018 01:39:27 +0200 Message-Id: <20180313233944.7234-1-crope@iki.fi> X-Mailer: git-send-email 2.14.3 X-SA-Exim-Connect-IP: 109.240.72.240 X-SA-Exim-Mail-From: crope@iki.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false 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 Whilst rewritten largely, the basic logic remains same with one exception: do not return immediately on success case. We are going to add statistics that function and cannot return too early. Signed-off-by: Antti Palosaari --- drivers/media/dvb-frontends/af9013.c | 55 ++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/drivers/media/dvb-frontends/af9013.c b/drivers/media/dvb-frontends/af9013.c index b8f3ebfc3e27..30cf837058da 100644 --- a/drivers/media/dvb-frontends/af9013.c +++ b/drivers/media/dvb-frontends/af9013.c @@ -752,45 +752,44 @@ static int af9013_read_status(struct dvb_frontend *fe, enum fe_status *status) struct af9013_state *state = fe->demodulator_priv; struct i2c_client *client = state->client; int ret; - unsigned int utmp; + unsigned int utmp, utmp1; /* * Return status from the cache if it is younger than 2000ms with the * exception of last tune is done during 4000ms. */ - if (time_is_after_jiffies( - state->read_status_jiffies + msecs_to_jiffies(2000)) && - time_is_before_jiffies( - state->set_frontend_jiffies + msecs_to_jiffies(4000)) - ) { - *status = state->fe_status; - return 0; + if (time_is_after_jiffies(state->read_status_jiffies + msecs_to_jiffies(2000)) && + time_is_before_jiffies(state->set_frontend_jiffies + msecs_to_jiffies(4000))) { + *status = state->fe_status; } else { - *status = 0; - } + /* MPEG2 lock */ + ret = regmap_read(state->regmap, 0xd507, &utmp); + if (ret) + goto err; - /* MPEG2 lock */ - ret = regmap_read(state->regmap, 0xd507, &utmp); - if (ret) - goto err; + if ((utmp >> 6) & 0x01) { + utmp1 = FE_HAS_SIGNAL | FE_HAS_CARRIER | + FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK; + } else { + /* TPS lock */ + ret = regmap_read(state->regmap, 0xd330, &utmp); + if (ret) + goto err; - if ((utmp >> 6) & 0x01) - *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | - FE_HAS_SYNC | FE_HAS_LOCK; + if ((utmp >> 3) & 0x01) + utmp1 = FE_HAS_SIGNAL | FE_HAS_CARRIER | + FE_HAS_VITERBI; + else + utmp1 = 0; + } - if (!*status) { - /* TPS lock */ - ret = regmap_read(state->regmap, 0xd330, &utmp); - if (ret) - goto err; + dev_dbg(&client->dev, "fe_status %02x\n", utmp1); - if ((utmp >> 3) & 0x01) - *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER | - FE_HAS_VITERBI; - } + state->read_status_jiffies = jiffies; - state->fe_status = *status; - state->read_status_jiffies = jiffies; + state->fe_status = utmp1; + *status = utmp1; + } return 0; err: