From patchwork Mon Jul 29 17:41:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 11064293 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C434B1398 for ; Mon, 29 Jul 2019 17:44:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3B76262FF for ; Mon, 29 Jul 2019 17:44:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A713C2862A; Mon, 29 Jul 2019 17:44:44 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3B896262FF for ; Mon, 29 Jul 2019 17:44:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=qlUpa7MWxnxapMjfWEdRflEs1RUQMQQj4KF0UiqEp88=; b=p4+QwwtEWao3vzPYkvDEb/riV/ TuVtbc63PCgQnPUD2J/1GdfwZk3OQ56vs3wGFD+kgUzX4BjND9KSJAEgWWuEQu8sMYSuAA1p2LiBT XLuOPmuukUDBTCXC+SfGd69MLIa0YlvNaCTFM5vRNbA1BiFpQQUgFE562wxUPCfppu0vqb8S4HFgU HnScwplr0uzUZgqeM66aVJlgjtZtxh/b4NwxY+BU3iDqMFUSMmxa+9R2UGyCfCsAEklaPRG3xan2U ez8xU60lcVt0qqjcfsiESXN3e+S55O/CP0XY2bAK7ukWezlwaejGrgrrHFGBv1ZytHLXNp2spqN9E /Rpa4a7w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hs9hT-0007hO-TU; Mon, 29 Jul 2019 17:44:43 +0000 Received: from mout.gmx.net ([212.227.15.15]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hs9fp-0006EJ-ON; Mon, 29 Jul 2019 17:43:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1564422140; bh=cz5syvrpEDjPh6mN9CRnHY7eSpKXvEo/1iVYs0MU7/k=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=UE3QZ/HI3AuxnxPTzLZelV5IijhJqrgwLxXXJkr+dlV4xblqDMaJY+guBXhyNJKbM 9QnaAgyh5xUDXTP7E+hYhm6UHwREebq74n78zy6mqVOwOJ0o3t+FV0y3vUu2QolNPH CeFLmAV2pHKyC1n7wf99v/CtoHVAYsI5boGZ+j4o= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([185.76.97.79]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MIuzJ-1hpfcb12fR-002bUc; Mon, 29 Jul 2019 19:42:20 +0200 From: Frank Wunderlich To: Alessandro Zummo , Alexandre Belloni , Allison Randal , "David S. Miller" , devicetree@vger.kernel.org, Eddie Huang , Greg Kroah-Hartman , Jonathan Cameron , Kate Stewart , Lee Jones , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-pm@vger.kernel.org, linux-rtc@vger.kernel.org, Mark Rutland , Matthias Brugger , Mauro Carvalho Chehab , Nicolas Ferre , Richard Fontana , Rob Herring , Sean Wang , Sebastian Reichel , Thomas Gleixner , "Tianping . Fang" Subject: [PATCH v3 04/10] rtc: mt6397: improvements of rtc driver Date: Mon, 29 Jul 2019 19:41:48 +0200 Message-Id: <20190729174154.4335-5-frank-w@public-files.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190729174154.4335-1-frank-w@public-files.de> References: <20190729174154.4335-1-frank-w@public-files.de> X-Provags-ID: V03:K1:rzp9FkJr7EadzfJs3aGYSULhKPhkKTUFIps4gv1ZB118If5DGcc oN7ccU4JkKglYIafUY5Iw4R21eEKa+ARpT5mTm+1UY5nfJxJtUidwjMw7Me9ShjbhuGg820 txw6meSqZlpmuTchydkn2WT3Mdc43ViwlwE3stQGtFUHvdWzf/L1IYGPhoxljJIK2Rib6kM VVYfP2iDIuT1BPSH5RPAA== X-UI-Out-Filterresults: notjunk:1;V03:K0:b+GGDEa6JdU=:kzWlCHr/edMNuIhJ4Un504 UxAyYga9K0wAFFieJVzKKo+oAj7WPsIvUkpF7/HHokmY3b5QBL9K/+qh0nO3Ic85U2VEj3eL6 bvYX55k3BqtB7Z0qOWvOQM9TvFm1XljcVIgesqWghZFKZ4lJog/Ow0JbWhSOkVp6PZTwrfA9e QUaJvWW3bXkVB7ymmTzubDb7hzNhUfOrpnUTU8syihLVbTdPKdRJpQJbDxtidsjHCljzTLfRt CWfoLN3FdQ1R4VDVBlP6CxxprjvQnLl9dtaEvn2OkXviPleYfYfEnDLSzyGU9Nj04Z6rBGSrw K8ibuv/7ao2rQ2x8k56JgF+hArKRKD9hHG1O61u7mVOLVZOwXtl3rI08Br90bCgXUXUcSWThL VwiN8KfVPTJAkqGNHH9aNd3L6Or9csNzHFKEg/LG7CwGEMPkF/3L936W2eZuA9FdyKu19osZb 09JIq9UmF3TcyO8vhl2YYWtPufP2JF1K4iWkowHqVyNcvwwT/akyHvDvEDn5c+gciYTHsF3kN IhucGCaAKmZEbqUy/B7rrooqX3iWFI3S97W0+tzyJlvwxg6rIBNxjuQ2e2ZxJfZsO+ALZrBBt Nrp3MoSLxIbyEClZr5kzyDYYfw8su95YaF3WnBcTsL5fsAh2Jn/oNzGxdBIhctHujNxrxCx7P pmlTRiRGCAA2O25031jAILBcqqbG4PMEigbX/A49ZnJjXrr+L7lCoLdlt24RBEl+N6XypqiGu XuqiVn00LB+Or4wLkgUlO3FlW4vqrJBdhl0dk3tk+YJ0/QF79afQcHgKhG9qCstxX4va+BDoj HZNbLFlQOxbFlTiqXyrCJVcEwKsA0aOo8iMT5JBb77jGNjWVA8k21Qg53KKchpYIunnlH6rDh 0LqJYMNEBbJ8IfcXvGPdKemItCliPdbyYVnd1FsqPAC+wizNfH3CJ5Je7iBup12xF67hUbsXZ I2+0H7Hw9BuvOmHPc5JwoWJvf20ol6iC7KuozF4VrCw+WzrcfnZQNOQmWRL+l0q/wr05GdHsI o6gceydIY9pVM9gnexm7XPu9gLxxlKs/Sqf6ub6FnXNjqqtL2IwVQFmFOsZgHauNmzl85W55o Cmw4BiAgb2g8nY= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190729_104302_083069_1E48E92A X-CRM114-Status: GOOD ( 15.21 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Josef Friedl , Frank Wunderlich MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Josef Friedl - use regmap_read_poll_timeout to drop while-loop - use devm-api to drop remove-callback changes since v2: - fix allocation after irq-request - compatible for mt6323 in separate commit => part 5 Suggested-by: Alexandre Belloni Signed-off-by: Josef Friedl Signed-off-by: Frank Wunderlich --- drivers/rtc/rtc-mt6397.c | 51 +++++++++++++++------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) -- 2.17.1 diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c index c08ee5edf865..9370b7fc9f81 100644 --- a/drivers/rtc/rtc-mt6397.c +++ b/drivers/rtc/rtc-mt6397.c @@ -4,16 +4,19 @@ * Author: Tianping.Fang */ -#include -#include +#include +#include +#include #include +#include +#include #include #include #include +#include static int mtk_rtc_write_trigger(struct mt6397_rtc *rtc) { - unsigned long timeout = jiffies + HZ; int ret; u32 data; @@ -21,19 +24,13 @@ static int mtk_rtc_write_trigger(struct mt6397_rtc *rtc) if (ret < 0) return ret; - while (1) { - ret = regmap_read(rtc->regmap, rtc->addr_base + RTC_BBPU, - &data); - if (ret < 0) - break; - if (!(data & RTC_BBPU_CBUSY)) - break; - if (time_after(jiffies, timeout)) { - ret = -ETIMEDOUT; - break; - } - cpu_relax(); - } + ret = regmap_read_poll_timeout(rtc->regmap, + rtc->addr_base + RTC_BBPU, data, + !(data & RTC_BBPU_CBUSY), + MTK_RTC_POLL_DELAY_US, + MTK_RTC_POLL_TIMEOUT); + if (ret < 0) + dev_err(rtc->dev, "failed to write WRTGE: %d\n", ret); return ret; } @@ -266,19 +263,19 @@ static int mtk_rtc_probe(struct platform_device *pdev) return rtc->irq; rtc->regmap = mt6397_chip->regmap; - rtc->dev = &pdev->dev; mutex_init(&rtc->lock); platform_set_drvdata(pdev, rtc); - rtc->rtc_dev = devm_rtc_allocate_device(rtc->dev); + rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev); if (IS_ERR(rtc->rtc_dev)) return PTR_ERR(rtc->rtc_dev); - ret = request_threaded_irq(rtc->irq, NULL, - mtk_rtc_irq_handler_thread, - IRQF_ONESHOT | IRQF_TRIGGER_HIGH, - "mt6397-rtc", rtc); + ret = devm_request_threaded_irq(&pdev->dev, rtc->irq, NULL, + mtk_rtc_irq_handler_thread, + IRQF_ONESHOT | IRQF_TRIGGER_HIGH, + "mt6397-rtc", rtc); + if (ret) { dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n", rtc->irq, ret); @@ -302,15 +299,6 @@ static int mtk_rtc_probe(struct platform_device *pdev) return ret; } -static int mtk_rtc_remove(struct platform_device *pdev) -{ - struct mt6397_rtc *rtc = platform_get_drvdata(pdev); - - free_irq(rtc->irq, rtc); - - return 0; -} - #ifdef CONFIG_PM_SLEEP static int mt6397_rtc_suspend(struct device *dev) { @@ -349,7 +337,6 @@ static struct platform_driver mtk_rtc_driver = { .pm = &mt6397_pm_ops, }, .probe = mtk_rtc_probe, - .remove = mtk_rtc_remove, }; module_platform_driver(mtk_rtc_driver);