From patchwork Tue Mar 27 15:16:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiro TSUKADA X-Patchwork-Id: 10310459 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 A7AC960353 for ; Tue, 27 Mar 2018 15:17:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97BC528EB9 for ; Tue, 27 Mar 2018 15:17:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C6082940F; Tue, 27 Mar 2018 15:17:25 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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 1D48128EB9 for ; Tue, 27 Mar 2018 15:17:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752425AbeC0PRY (ORCPT ); Tue, 27 Mar 2018 11:17:24 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:33664 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752338AbeC0PRX (ORCPT ); Tue, 27 Mar 2018 11:17:23 -0400 Received: by mail-pl0-f66.google.com with SMTP id c11-v6so14277345plo.0 for ; Tue, 27 Mar 2018 08:17:23 -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=VqiTiPzV2Xt4pjIqKKAIFzNfHr2nfsPb96AQ+Mg6vQs=; b=bbZ1yjj8lmsyjUbxH567vDk01zCBufGCGNtduDtb9c3IgY8LOOg8gFoRp0ViACMb5g XZdvAbhrUc+8p8vP676/I4vulioOINIi/UKAkH7RNOl+bfQMTDLsGevVjNmsgIPzD55i a7kspbyKNfkqVbK4f6yPh7L7mduGSr+jmOVtgH6J+QgtNDCAIjNTtRszLrbE5OC4SywE L4e3UJQaIMNvd4Dix1AzE8pAjxLnITcClr8dAqxkQJ/NRRl/iPDJOOmhrCH4Z08kKm0F 2Fd3XQqbhe+TMWxjmh4RhTYgLEaA+4wesAvPCgdzLcC0LMBthjtn4UqPfIZWRv5qB4xq z1lg== 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=VqiTiPzV2Xt4pjIqKKAIFzNfHr2nfsPb96AQ+Mg6vQs=; b=BoQ71+FtI7S0WG74bWptQwl0pMGV0jozGoITEuhTwwntDPSdJZLSUIik9WLm4RnttX mKXmheSS90QG42e8RcMKxsqFQArw3YgkPJ6gQG2QHiN0f8nHaj2noenkOs4KnZ9JWUQi xER2tKeSx1v0dl9TzcbEUcoZ7USPm/ge8l6C0xOnLPRfDHV7n8PrUMVJjU+3u/DJC5Mo 1H7VXpfwMI53xJdn1Baboe/k+H5FGQpCHQbEYwJYZuGGFVV5dRQDoNzSU0yb6yXqX1s3 frm424+mJh1rHhUvK60sX641imZTeDYa2ecNLJqpqf0NLFTA2Ua6w33IyCKYLnJaZTcx IJnQ== X-Gm-Message-State: AElRT7EZQb0DktMsc1gnaUvwVHTW5LeQdhg9ki/fOl2uyq5dUoinYw+n 5cWEZ/rAOCply2xIOL4dvlkLlA== X-Google-Smtp-Source: AG47ELtjmqkgSIGjRfobzioZioRNx9KzrHQKHo7eG2U0qTmCyHw3xR8YWruhAwLd+xX8he0F0XrofQ== X-Received: by 2002:a17:902:2e43:: with SMTP id q61-v6mr44817762plb.404.1522163842803; Tue, 27 Mar 2018 08:17:22 -0700 (PDT) Received: from localhost.localdomain (softbank219203027033.bbtec.net. [219.203.27.33]) by smtp.googlemail.com with ESMTPSA id c15sm3957419pfm.114.2018.03.27.08.17.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 08:17:22 -0700 (PDT) From: tskd08@gmail.com To: linux-media@vger.kernel.org Cc: mchehab@s-opensource.com, hiranotaka@zng.info, Akihiro Tsukada Subject: [PATCH 5/5] dvb: earth-pt1: replace schedule_timeout with usleep_range Date: Wed, 28 Mar 2018 00:16:02 +0900 Message-Id: <20180327151602.12250-6-tskd08@gmail.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327151602.12250-1-tskd08@gmail.com> References: <20180327151602.12250-1-tskd08@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: Akihiro Tsukada As described in Document/timers/timers-howto.txt, hrtimer-based delay should be used for small sleeps. Signed-off-by: Akihiro Tsukada --- drivers/media/pci/pt1/pt1.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/media/pci/pt1/pt1.c b/drivers/media/pci/pt1/pt1.c index 1a83a624776..4f84672974d 100644 --- a/drivers/media/pci/pt1/pt1.c +++ b/drivers/media/pci/pt1/pt1.c @@ -18,7 +18,10 @@ */ #include +#include #include +#include +#include #include #include #include @@ -327,7 +330,7 @@ static int pt1_unlock(struct pt1 *pt1) for (i = 0; i < 3; i++) { if (pt1_read_reg(pt1, 0) & 0x80000000) return 0; - schedule_timeout_uninterruptible((HZ + 999) / 1000); + usleep_range(1000, 2000); } dev_err(&pt1->pdev->dev, "could not unlock\n"); return -EIO; @@ -341,7 +344,7 @@ static int pt1_reset_pci(struct pt1 *pt1) for (i = 0; i < 10; i++) { if (pt1_read_reg(pt1, 0) & 0x00000001) return 0; - schedule_timeout_uninterruptible((HZ + 999) / 1000); + usleep_range(1000, 2000); } dev_err(&pt1->pdev->dev, "could not reset PCI\n"); return -EIO; @@ -355,7 +358,7 @@ static int pt1_reset_ram(struct pt1 *pt1) for (i = 0; i < 10; i++) { if (pt1_read_reg(pt1, 0) & 0x00000002) return 0; - schedule_timeout_uninterruptible((HZ + 999) / 1000); + usleep_range(1000, 2000); } dev_err(&pt1->pdev->dev, "could not reset RAM\n"); return -EIO; @@ -372,7 +375,7 @@ static int pt1_do_enable_ram(struct pt1 *pt1) if ((pt1_read_reg(pt1, 0) & 0x00000004) != status) return 0; } - schedule_timeout_uninterruptible((HZ + 999) / 1000); + usleep_range(1000, 2000); } dev_err(&pt1->pdev->dev, "could not enable RAM\n"); return -EIO; @@ -382,7 +385,7 @@ static int pt1_enable_ram(struct pt1 *pt1) { int i, ret; int phase; - schedule_timeout_uninterruptible((HZ + 999) / 1000); + usleep_range(1000, 2000); phase = pt1->pdev->device == 0x211a ? 128 : 166; for (i = 0; i < phase; i++) { ret = pt1_do_enable_ram(pt1); @@ -469,6 +472,9 @@ static int pt1_thread(void *data) struct pt1_buffer_page *page; bool was_frozen; +#define PT1_FETCH_DELAY 10 +#define PT1_FETCH_DELAY_DELTA 2 + pt1 = data; set_freezable(); @@ -482,7 +488,13 @@ static int pt1_thread(void *data) page = pt1->tables[pt1->table_index].bufs[pt1->buf_index].page; if (!pt1_filter(pt1, page)) { - schedule_timeout_interruptible((HZ + 999) / 1000); + ktime_t delay; + + delay = PT1_FETCH_DELAY * NSEC_PER_MSEC; + set_current_state(TASK_INTERRUPTIBLE); + schedule_hrtimeout_range(&delay, + PT1_FETCH_DELAY_DELTA * NSEC_PER_MSEC, + HRTIMER_MODE_REL); continue; } @@ -718,7 +730,7 @@ pt1_update_power(struct pt1 *pt1) adap = pt1->adaps[i]; switch (adap->voltage) { case SEC_VOLTAGE_13: /* actually 11V */ - bits |= 1 << 1; + bits |= 1 << 2; break; case SEC_VOLTAGE_18: /* actually 15V */ bits |= 1 << 1 | 1 << 2; @@ -772,7 +784,7 @@ static int pt1_wakeup(struct dvb_frontend *fe) adap = container_of(fe->dvb, struct pt1_adapter, adap); adap->sleep = 0; pt1_update_power(adap->pt1); - schedule_timeout_uninterruptible((HZ + 999) / 1000); + usleep_range(1000, 2000); ret = config_demod(adap->demod_i2c_client, adap->pt1->fe_clk); if (ret == 0 && adap->orig_init) @@ -1079,7 +1091,7 @@ static int pt1_i2c_end(struct pt1 *pt1, int addr) do { if (signal_pending(current)) return -EINTR; - schedule_timeout_interruptible((HZ + 999) / 1000); + usleep_range(1000, 2000); } while (pt1_read_reg(pt1, 0) & 0x00000080); return 0; } @@ -1382,11 +1394,11 @@ static int pt1_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pt1->power = 1; pt1_update_power(pt1); - schedule_timeout_uninterruptible((HZ + 49) / 50); + msleep(20); pt1->reset = 0; pt1_update_power(pt1); - schedule_timeout_uninterruptible((HZ + 999) / 1000); + usleep_range(1000, 2000); ret = pt1_init_frontends(pt1); if (ret < 0)