Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1618353ybl; Sun, 18 Aug 2019 07:05:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqzrdPSO0JGIIuPOsA5lJksKw0pkNnxr0QYb6jBfc+xJ3tYXxCwLRk5nDFOXtZc140uSH2af X-Received: by 2002:a63:6686:: with SMTP id a128mr15645436pgc.361.1566137149174; Sun, 18 Aug 2019 07:05:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566137149; cv=none; d=google.com; s=arc-20160816; b=SK5a0iq58+8RK1tAY55uUedjXQ/uxdAKuFPQm6S4+q14vNP65lIpyfTeXdQAXp/RHp UxzZhx1vRYpRbdz5PgcBg4Vt+YWvQ3ilJgpJSg6wcukRqHqFLyY4hzmCLZDbsj3aRgJS MeUqTdR8E57wf3+ytqtJU1ETn8Eks88F4NUEf1zvhMrt1xdPvaXK3yF7kVZ6lDalKHPB BxBGYf5DQdjJ/zqwdF5P+8dBeSvsn36PSLV54as5QdDqdWYisZsrNBWHqRhJjpS2HjSd qRO9yTXAWjQV3BiDX9MeGqHQvQmTlDQrOh8p+0O2528eAi3oUTg2h5RP2MrzwQpO5K05 +GVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=73lRNmkikoZr0FlRejmUyGlLzk/Goh8lD4ReMRa55R0=; b=EnnY0TKkHOGmBEsfwWrBfy1kYIbyqW/fPtlaxyiKNrrLkjlo1jmOwY0iOziuZut5sp oLA62ImNkXECWwOPqmdYKZCbHL16A/4c5OvUSZpmxUCO2NgXpzVwInSWzLwpaRKs9Qyv 2ab90KcgC90CJU5xa0WsIH5Z9U8lw3pbvWXvJL9ej6QZOnkqM095PPcw328ZkQN/mFF6 BO3Vznq8tPBm+umJ6W4Jum4ee7JPwYJyWKhWsQpMXuteB2vzqhWzSe7cXvFq9eJf2rUK Qi8abqFppE0aUzCw9zpCtWO069GBbs4eMNUtwAKNrhkCbQYv1DsKwoBQcXrdrIz75dzB r1Pw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 70si8015353ple.282.2019.08.18.07.05.34; Sun, 18 Aug 2019 07:05:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726935AbfHROE3 (ORCPT + 99 others); Sun, 18 Aug 2019 10:04:29 -0400 Received: from mxwww.masterlogin.de ([95.129.51.220]:43024 "EHLO mxwww.masterlogin.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726807AbfHROE0 (ORCPT ); Sun, 18 Aug 2019 10:04:26 -0400 Received: from mxout1.routing.net (unknown [192.168.10.81]) by new.mxwww.masterlogin.de (Postfix) with ESMTPS id 27B7B96DFA; Sun, 18 Aug 2019 13:56:28 +0000 (UTC) Received: from mxbox3.masterlogin.de (unknown [192.168.10.253]) by mxout1.routing.net (Postfix) with ESMTP id 7B91D43CE1; Sun, 18 Aug 2019 13:56:28 +0000 (UTC) Received: from localhost.localdomain (fttx-pool-185.53.43.183.bambit.de [185.53.43.183]) by mxbox3.masterlogin.de (Postfix) with ESMTPSA id A53193605A8; Sun, 18 Aug 2019 15:56:27 +0200 (CEST) From: Frank Wunderlich To: linux-mediatek@lists.infradead.org Cc: Frank Wunderlich , devicetree@vger.kernel.org, "linux-arm-kernel @ lists . infradead . org Alessandro Zummo" , Alexandre Belloni , Eddie Huang , Josef Friedl , Lee Jones , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-rtc@vger.kernel.org, Mark Rutland , Matthias Brugger , Rob Herring , Sean Wang , Sebastian Reichel , "Tianping Fang" Subject: [PATCH v6 07/13] rtc: mt6397: improvements of rtc driver Date: Sun, 18 Aug 2019 15:56:05 +0200 Message-Id: <20190818135611.7776-8-frank-w@public-files.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818135611.7776-1-frank-w@public-files.de> References: <20190818135611.7776-1-frank-w@public-files.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josef Friedl - use regmap_read_poll_timeout to drop while-loop - use devm-api to drop remove-callback Suggested-by: Alexandre Belloni Signed-off-by: Josef Friedl Signed-off-by: Frank Wunderlich --- changes since v5: none changes since v4: none changes since v3: none changes since v2: - fix allocation after irq-request - compatible for mt6323 in separate commit => part 5 --- drivers/rtc/rtc-mt6397.c | 51 +++++++++++++++------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) 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); -- 2.17.1