linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Łukasz Stelmach" <l.stelmach@samsung.com>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-rtc@vger.kernel.org,
	"Bartłomiej Żolnierkiewicz" <b.zolnierkie@samsung.com>,
	"Marek Szyprowski" <m.szyprowski@samsung.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] rtc: rtc_update_irq_enable: rework UIE emulation
Date: Fri, 02 Apr 2021 12:28:12 +0200	[thread overview]
Message-ID: <dleftjmtuhdlqb.fsf%l.stelmach@samsung.com> (raw)
In-Reply-To: <20210330000343.801566-3-alexandre.belloni@bootlin.com> (Alexandre Belloni's message of "Tue, 30 Mar 2021 02:03:43 +0200")

[-- Attachment #1: Type: text/plain, Size: 2540 bytes --]

It was <2021-03-30 wto 02:03>, when Alexandre Belloni wrote:
> Now that the core is aware of whether alarms are available, it is possible
> to decide whether UIE emulation is required before actually trying to set
> the alarm.
>
> This greatly simplifies rtc_update_irq_enable because there is now only one
> error value to track and is not relying on the return value of
> __rtc_set_alarm anymore.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> ---
>  drivers/rtc/interface.c | 28 +++++++---------------------
>  1 file changed, 7 insertions(+), 21 deletions(-)
>

Tested-by: Łukasz Stelmach <l.stelmach@samsung.com>

> diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
> index dcb34c73319e..b162964d2b39 100644
> --- a/drivers/rtc/interface.c
> +++ b/drivers/rtc/interface.c
> @@ -561,8 +561,12 @@ int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
>  	if (rtc->uie_rtctimer.enabled == enabled)
>  		goto out;
>  
> -	if (rtc->uie_unsupported) {
> +	if (rtc->uie_unsupported || !test_bit(RTC_FEATURE_ALARM, rtc->features)) {
> +#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
> +		err = rtc_dev_update_irq_enable_emul(rtc, enabled);
> +#else
>  		err = -EINVAL;
> +#endif
>  		goto out;
>  	}
>  
> @@ -570,8 +574,8 @@ int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
>  		struct rtc_time tm;
>  		ktime_t now, onesec;
>  
> -		rc = __rtc_read_time(rtc, &tm);
> -		if (rc)
> +		err = __rtc_read_time(rtc, &tm);
> +		if (err)
>  			goto out;
>  		onesec = ktime_set(1, 0);
>  		now = rtc_tm_to_ktime(tm);
> @@ -585,24 +589,6 @@ int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
>  out:
>  	mutex_unlock(&rtc->ops_lock);
>  
> -	/*
> -	 * __rtc_read_time() failed, this probably means that the RTC time has
> -	 * never been set or less probably there is a transient error on the
> -	 * bus. In any case, avoid enabling emulation has this will fail when
> -	 * reading the time too.
> -	 */
> -	if (rc)
> -		return rc;
> -
> -#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
> -	/*
> -	 * Enable emulation if the driver returned -EINVAL to signal that it has
> -	 * been configured without interrupts or they are not available at the
> -	 * moment.
> -	 */
> -	if (err == -EINVAL)
> -		err = rtc_dev_update_irq_enable_emul(rtc, enabled);
> -#endif
>  	return err;
>  }
>  EXPORT_SYMBOL_GPL(rtc_update_irq_enable);

-- 
Łukasz Stelmach
Samsung R&D Institute Poland
Samsung Electronics

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

  parent reply	other threads:[~2021-04-02 10:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20210305174419eucas1p1639ed3bbcbc37ab3e3619e9c5d1e1629@eucas1p1.samsung.com>
2021-03-05 17:44 ` [PATCH] rtc: ds1307: set uie_unsupported if no interrupt is available Łukasz Stelmach
2021-03-15 22:01   ` Alexandre Belloni
     [not found]   ` <CGME20210316121218eucas1p1f74d6e6cec7fc897051902a7da478fd0@eucas1p1.samsung.com>
2021-03-16 12:12     ` Lukasz Stelmach
2021-03-16 12:32       ` Alexandre Belloni
     [not found]         ` <CGME20210316180430eucas1p1a3cb26f40772b0af75782ff84908d731@eucas1p1.samsung.com>
2021-03-16 18:04           ` Lukasz Stelmach
     [not found]             ` <CGME20210317081944eucas1p123bd27f3203c937d2969a66fb06d6d9e@eucas1p1.samsung.com>
2021-03-17  8:19               ` [PATCH 1/2] WIP: Introduce has_alarm method for rtc devices Łukasz Stelmach
     [not found]                 ` <CGME20210317081947eucas1p15a31b346977fba94bf154716c3d89cb0@eucas1p1.samsung.com>
2021-03-17  8:19                   ` [PATCH 2/2] WIP: Provide has_alarm method Łukasz Stelmach
2021-03-30  0:02             ` [PATCH] rtc: ds1307: set uie_unsupported if no interrupt is available Alexandre Belloni
2021-03-30  0:03               ` [PATCH 1/3] rtc: ds1307: replace HAS_ALARM by RTC_FEATURE_ALARM Alexandre Belloni
2021-03-30  0:03                 ` [PATCH 2/3] rtc: ds1307: remove flags Alexandre Belloni
     [not found]                   ` <CGME20210402102743eucas1p23690e0df642a10fa0326a84fac6c0ed3@eucas1p2.samsung.com>
2021-04-02 10:27                     ` Łukasz Stelmach
2021-03-30  0:03                 ` [PATCH 3/3] rtc: rtc_update_irq_enable: rework UIE emulation Alexandre Belloni
     [not found]                   ` <CGME20210402102813eucas1p1bae7ec57559fa8df622118275bf6fae0@eucas1p1.samsung.com>
2021-04-02 10:28                     ` Łukasz Stelmach [this message]
     [not found]                 ` <CGME20210402102655eucas1p24ee7e879816089921bf9752c3c483122@eucas1p2.samsung.com>
2021-04-02 10:26                   ` [PATCH 1/3] rtc: ds1307: replace HAS_ALARM by RTC_FEATURE_ALARM Łukasz Stelmach
     [not found]               ` <CGME20210330065217eucas1p2c50a100bf0101e72dd753f37257f6a57@eucas1p2.samsung.com>
2021-03-30  6:52                 ` [PATCH] rtc: ds1307: set uie_unsupported if no interrupt is available Lukasz Stelmach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dleftjmtuhdlqb.fsf%l.stelmach@samsung.com \
    --to=l.stelmach@samsung.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).