Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3966322pxf; Mon, 29 Mar 2021 17:05:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymsHPFg3E3w6sUpcl/fQHszrPuJwxkXqwD8GGo0LUfF5JJObYrWQe+VPEQT+RpeH8AUTN/ X-Received: by 2002:a05:6402:1691:: with SMTP id a17mr31230994edv.336.1617062732203; Mon, 29 Mar 2021 17:05:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617062732; cv=none; d=google.com; s=arc-20160816; b=b4NtHjcOhv2OcXbKdknw078kKIMEht1z7oPZ87Kq47QsvdF5u+Hk3a6cyvw3E70MMx W6FSVROGU9JRjhho1yA2vKtX+9ZhgcnHikWkstZ7hvDGp3rlAF1l8BdORwbsJ7KT3VIV G56n6LIrf6bQzO9YhCMXHn6NcFrQMSNlfBhRt3xF5WD2gms9eRb0WiMrlDaGpXa5NDkZ puDejahPiAgn3LEFXOPDJoo34QXK89GOTSHb61J7QyZI/+DwKB2NrRUmL4neUSzbD43w 52nVYXAEzu+GqLDwMmdutg7H+BlJzNWjkY+ao6ioSNI8q0WHIaSTxbBLnlE8hSLdiH8j Aheg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=zIlib4PDsS21CN5BV0eB3FQvBnL57XW7ESKkY2jpkrM=; b=ihS2XGzxIIUycrPrceUM942LeQS2UQa+0HWEqVKsXUNf95D7Q0aAYP4XnM53lhLOPZ iAZJVFwrEXkjceG2bqR+qdnwwT7uHEsuJye2ZI/WU9esfV0o7LHAEANUzU4vWVYN3X0V kPLAqrc5zkSI8w8OF9jCXgUp9T86qAw90LB9CSZ4yeT5WbkWmWdZf6/g7N/3dk03pHiV jZWys8cAUOtrZs9RDBsb/dWCMP3R95T2aYEHcs7pwhZ1Qg2Wfkg3XS0JxHxroyYJyyZb 39iIFauYbFb6NS/4XpiXwEZpfp30JZwc8sgOGQp12a9AwLYc9cuVdsMpg9m0yX5FK/jI p2yg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w16si13973504edv.532.2021.03.29.17.05.10; Mon, 29 Mar 2021 17:05:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229483AbhC3AEI (ORCPT + 99 others); Mon, 29 Mar 2021 20:04:08 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:35151 "EHLO relay6-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230307AbhC3AEA (ORCPT ); Mon, 29 Mar 2021 20:04:00 -0400 X-Originating-IP: 90.65.108.55 Received: from localhost (lfbn-lyo-1-1676-55.w90-65.abo.wanadoo.fr [90.65.108.55]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id BCE91C0003; Tue, 30 Mar 2021 00:03:58 +0000 (UTC) From: Alexandre Belloni To: Lukasz Stelmach Cc: linux-rtc@vger.kernel.org, =?UTF-8?q?Bart=C5=82omiej=20=C5=BBolnierkiewicz?= , Marek Szyprowski , linux-kernel@vger.kernel.org, Alexandre Belloni Subject: [PATCH 3/3] rtc: rtc_update_irq_enable: rework UIE emulation Date: Tue, 30 Mar 2021 02:03:43 +0200 Message-Id: <20210330000343.801566-3-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210330000343.801566-1-alexandre.belloni@bootlin.com> References: <20210330000343.801566-1-alexandre.belloni@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/rtc/interface.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) 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); -- 2.30.2