From patchwork Wed Apr 19 23:13:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devin Heitmueller X-Patchwork-Id: 9689201 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 92ACA602DC for ; Wed, 19 Apr 2017 23:14:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 850192582C for ; Wed, 19 Apr 2017 23:14:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A0F828437; Wed, 19 Apr 2017 23:14:51 +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.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, 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 1A3842582C for ; Wed, 19 Apr 2017 23:14:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938415AbdDSXOs (ORCPT ); Wed, 19 Apr 2017 19:14:48 -0400 Received: from mail-qk0-f169.google.com ([209.85.220.169]:35020 "EHLO mail-qk0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S940326AbdDSXOp (ORCPT ); Wed, 19 Apr 2017 19:14:45 -0400 Received: by mail-qk0-f169.google.com with SMTP id f133so33324063qke.2 for ; Wed, 19 Apr 2017 16:14:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernellabs-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Mq1/Xd3pxSQ/A9VLGP6aYNKvN3RBk5VGW1kztCp4SUE=; b=qcUkT+Lj6CcH7vQzOXOqe7qj8kwfttJ0mbgGL+STydKokodDsLr/Wd/zu3UBNISYyl eQC0Rrukb7aKEQ35FmVY0JIdgGp2wjzTuACzLe5WEw4lmLfnTFcdeHpiRhFZ0BDsghHj ptHiSZmrNqxQimwMcMzR+Xe4Q4GMf/mAVjSLG6gWocTDCvfHodZthVPrZAw1u58C1Z4z A7CeA4yCwX8DaksvwikZXxFW2jTao8rNqYyydbbNGGlMsCHOF1mmCDSWF2BzopJUdV7J MFD8FG1ipdyjOAZdP1vkYXQtJ8UQGYZ/SuAESzc45QBv6/Z4/sqBqxkCqZfqHEDFDPmu jBkQ== 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=Mq1/Xd3pxSQ/A9VLGP6aYNKvN3RBk5VGW1kztCp4SUE=; b=pNbGGKQ544EMlcN1Lzkl7jbO4VnLt056PwWkLNo8xESWfHUXRsFrdTBIjtq2qZSBXL 5oeuQauoQ55k+0RcHXi6WnOsa1hgjy7M2dNBc1INHLNKQCC/wsI8hpQDa23P1+0BseGF zbbMrvXJZlOPtZ0cCsLaZUiRLm88nEcLU+15oC//I6h2PGEakB8uto/tHOjrz3SZLJnT Peluxdt5WxEKX+5XH/LIaKKCfoX8ja/XeDjcs99y0uwH8GWnHphEx6W2KV1mtHufXLw3 BsE0gy+z2FVI0h/Bos3rAW6kbdoOfweBYuWSpuCt4f6DjNyRS1uSR3jOgyXtQdvP0e7I eslg== X-Gm-Message-State: AN3rC/7R5b1Y0uOnlp8KpxvoYPx3elAJH4eW67+aVZhQlSAy21xkKgZX gKcUQHtPeHwR+321 X-Received: by 10.55.105.129 with SMTP id e123mr4718615qkc.184.1492643674565; Wed, 19 Apr 2017 16:14:34 -0700 (PDT) Received: from localhost.localdomain (cpe-74-71-114-159.nyc.res.rr.com. [74.71.114.159]) by smtp.gmail.com with ESMTPSA id 123sm2951916qkm.22.2017.04.19.16.14.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Apr 2017 16:14:34 -0700 (PDT) From: Devin Heitmueller To: linux-media@vger.kernel.org Cc: Devin Heitmueller Subject: [PATCH 09/12] xc5000: Don't spin waiting for analog lock Date: Wed, 19 Apr 2017 19:13:52 -0400 Message-Id: <1492643635-30823-10-git-send-email-dheitmueller@kernellabs.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1492643635-30823-1-git-send-email-dheitmueller@kernellabs.com> References: <1492643635-30823-1-git-send-email-dheitmueller@kernellabs.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 The xc5000 driver should not be spinning waiting for an analog lock. The ioctl() should be returning immediately and the application is responsible for polling for lock status. This behavior isn't very visible in cases where you tune to a valid channel, since lock is usually achieved much faster than 400ms. However it is highly visible where doing things like changing video standards, which sends tuning request for a frequency that is almost never going to have an actual channel on it. Also fixup the return values to treat zero as success and an actual error code on error (to be consistent with other functions). Note this change has no practical effect at this time as none of the callers inspect the return value. Signed-off-by: Devin Heitmueller --- drivers/media/tuners/xc5000.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/drivers/media/tuners/xc5000.c b/drivers/media/tuners/xc5000.c index e823aaf..e144627 100644 --- a/drivers/media/tuners/xc5000.c +++ b/drivers/media/tuners/xc5000.c @@ -565,38 +565,16 @@ static int xc_get_totalgain(struct xc5000_priv *priv, u16 *totalgain) return xc5000_readreg(priv, XREG_TOTALGAIN, totalgain); } -static u16 wait_for_lock(struct xc5000_priv *priv) -{ - u16 lock_state = 0; - int watch_dog_count = 40; - - while ((lock_state == 0) && (watch_dog_count > 0)) { - xc_get_lock_status(priv, &lock_state); - if (lock_state != 1) { - msleep(5); - watch_dog_count--; - } - } - return lock_state; -} - #define XC_TUNE_ANALOG 0 #define XC_TUNE_DIGITAL 1 static int xc_tune_channel(struct xc5000_priv *priv, u32 freq_hz, int mode) { - int found = 0; - dprintk(1, "%s(%u)\n", __func__, freq_hz); if (xc_set_rf_frequency(priv, freq_hz) != 0) - return 0; - - if (mode == XC_TUNE_ANALOG) { - if (wait_for_lock(priv) == 1) - found = 1; - } + return -EREMOTEIO; - return found; + return 0; } static int xc_set_xtal(struct dvb_frontend *fe)