Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4495222ybl; Tue, 20 Aug 2019 12:51:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyra0sYGOg68AvjJCjHhW5YclJ1JoLdbwx5pIgLQoNR7Vb/p3SskpUJO+l6NfL/hsjtoK86 X-Received: by 2002:a63:784c:: with SMTP id t73mr27057816pgc.268.1566330703729; Tue, 20 Aug 2019 12:51:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566330703; cv=none; d=google.com; s=arc-20160816; b=LiVvVQWlLTQbz0JFaWpUgxtAFyxoEYRCvUPa7EYYgpZEp4BtqId4tcR3aW1OWjpeet 1CkbuKEKj8CNjKgielbgNEFyruOSm864iCGKNQxIP4zWvS3ICEXXZIg5XY73JsiYHOVU lvw6KV8icuq9EhDZrU18fYG/ah98rd5A2lXKkEfTcj0TXQL4ZcQP2Ey+Ylg15Ur9yVRY RjO57/1InjeiPJv89KTARIFZkRY8wo7UvUSCcsuhdaEwL11il1Wt0C7mwccgIq4N9504 WD9gbDGUdMEy0T/iw+i6WyeNL5+byRx5NSNzLPZBgwenGn9wPFkxPlsQ9xKl/YnqqzUO q5PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=f2yXo/jRKx9m9mejvK/mNxcoM415zO2+ZeAmNXnhFSk=; b=nPjRwePmrFQwnzhws9LHJAg4QtqqoizB6KUytmStqNeExsuiPSIySV3ZG4lc/7pea5 TjOY/B/i0QXalVjpII356hZt/ruXfldGK9WJyHUWT/zasvqJjtiZ99wVKcl5oemDA2S0 fRAVQ72QmYVVOZJ2C/DKwMQCuOqae0IDnBAw+a3QWUyRH99a01iIq9RWJ1yD/1g+SfSX QTrz4mAEd5gRkOnzSWbUd/RpOsTBWryR1As7RkANplFK2zJ7ZUgVBbKTDIzBR1nnPbgl Y7sdvwQS3lGXy1a7lisTlTPE8TQSjftkQ+gVqU9scI5Q75csf1N+qb49RtZZcf1S4Qi7 KMEA== 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 f33si5790875plb.382.2019.08.20.12.51.28; Tue, 20 Aug 2019 12:51:43 -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 S1730786AbfHTTuC (ORCPT + 99 others); Tue, 20 Aug 2019 15:50:02 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:46073 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728283AbfHTTuC (ORCPT ); Tue, 20 Aug 2019 15:50:02 -0400 X-Originating-IP: 90.65.161.137 Received: from localhost (lfbn-1-1545-137.w90-65.abo.wanadoo.fr [90.65.161.137]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 51CF160004; Tue, 20 Aug 2019 19:49:59 +0000 (UTC) Date: Tue, 20 Aug 2019 21:49:59 +0200 From: Alexandre Belloni To: Frank Wunderlich Cc: linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, "linux-arm-kernel @ lists . infradead . org Alessandro Zummo" , 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: Re: [PATCH v6 07/13] rtc: mt6397: improvements of rtc driver Message-ID: <20190820194959.GY3545@piout.net> References: <20190818135611.7776-1-frank-w@public-files.de> <20190818135611.7776-8-frank-w@public-files.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190818135611.7776-8-frank-w@public-files.de> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18/08/2019 15:56:05+0200, Frank Wunderlich wrote: > 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 Acked-by: Alexandre Belloni > --- > 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 > -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com