From: alexandre.belloni@bootlin.com
To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 08/12] rtc: ds1511: let the core know when alarm are not supported
Date: Wed, 28 Feb 2024 00:04:23 +0100 [thread overview]
Message-ID: <20240227230431.1837717-8-alexandre.belloni@bootlin.com> (raw)
In-Reply-To: <20240227230431.1837717-1-alexandre.belloni@bootlin.com>
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Instead of failing function calls, let the core know alarms are not
supported so it can fail early and avoid unnecessary calls.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-ds1511.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c
index b0dfdda2c8fc..c81f464e6a50 100644
--- a/drivers/rtc/rtc-ds1511.c
+++ b/drivers/rtc/rtc-ds1511.c
@@ -188,9 +188,6 @@ static int ds1511_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
struct rtc_plat_data *pdata = dev_get_drvdata(dev);
unsigned long flags;
- if (pdata->irq <= 0)
- return -EINVAL;
-
pdata->alrm_mday = alrm->time.tm_mday;
pdata->alrm_hour = alrm->time.tm_hour;
pdata->alrm_min = alrm->time.tm_min;
@@ -219,9 +216,6 @@ static int ds1511_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct rtc_plat_data *pdata = dev_get_drvdata(dev);
- if (pdata->irq <= 0)
- return -EINVAL;
-
alrm->time.tm_mday = pdata->alrm_mday < 0 ? 0 : pdata->alrm_mday;
alrm->time.tm_hour = pdata->alrm_hour < 0 ? 0 : pdata->alrm_hour;
alrm->time.tm_min = pdata->alrm_min < 0 ? 0 : pdata->alrm_min;
@@ -253,9 +247,6 @@ static int ds1511_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
struct rtc_plat_data *pdata = dev_get_drvdata(dev);
unsigned long flags;
- if (pdata->irq <= 0)
- return -EINVAL;
-
spin_lock_irqsave(&pdata->lock, flags);
ds1511_rtc_alarm_enable(enabled);
spin_unlock_irqrestore(&pdata->lock, flags);
@@ -349,12 +340,6 @@ static int ds1511_rtc_probe(struct platform_device *pdev)
pdata->rtc->ops = &ds1511_rtc_ops;
- ret = devm_rtc_register_device(pdata->rtc);
- if (ret)
- return ret;
-
- devm_rtc_nvmem_register(pdata->rtc, &ds1511_nvmem_cfg);
-
/*
* if the platform has an interrupt in mind for this device,
* then by all means, set it
@@ -369,6 +354,15 @@ static int ds1511_rtc_probe(struct platform_device *pdev)
}
}
+ if (pdata->irq == 0)
+ clear_bit(RTC_FEATURE_ALARM, pdata->rtc->features);
+
+ ret = devm_rtc_register_device(pdata->rtc);
+ if (ret)
+ return ret;
+
+ devm_rtc_nvmem_register(pdata->rtc, &ds1511_nvmem_cfg);
+
return 0;
}
--
2.43.0
next prev parent reply other threads:[~2024-02-27 23:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-27 23:04 [PATCH 01/12] rtc: ds1511: drop useless checks alexandre.belloni
2024-02-27 23:04 ` [PATCH 02/12] rtc: ds1511: drop useless computation alexandre.belloni
2024-02-27 23:04 ` [PATCH 03/12] rtc: ds1511: drop dead code alexandre.belloni
2024-02-27 23:04 ` [PATCH 04/12] rtc: ds1511: drop useless enum alexandre.belloni
2024-02-27 23:04 ` [PATCH 05/12] rtc: ds1511: fix function definition alexandre.belloni
2024-02-27 23:04 ` [PATCH 06/12] rtc: ds1511: remove incomplete UIE support alexandre.belloni
2024-02-27 23:04 ` [PATCH 07/12] rtc: ds1511: remove ds1511_rtc_update_alarm alexandre.belloni
2024-02-27 23:04 ` alexandre.belloni [this message]
2024-02-27 23:04 ` [PATCH 09/12] rtc: ds1511: remove partial alarm support alexandre.belloni
2024-02-27 23:04 ` [PATCH 10/12] rtc: ds1511: implement ds1511_rtc_read_alarm properly alexandre.belloni
2024-02-27 23:04 ` [PATCH 11/12] rtc: ds1511: rename pdata alexandre.belloni
2024-02-27 23:04 ` [PATCH 12/12] rtc: ds1511: drop inline/noinline hints alexandre.belloni
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=20240227230431.1837717-8-alexandre.belloni@bootlin.com \
--to=alexandre.belloni@bootlin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
/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
all inboxes | Powered by JetHome®