diff options
author | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2021-01-11 00:17:36 +0100 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2021-01-16 23:19:26 +0100 |
commit | 7ae41220ef5831674f446baef19bfe1b31358260 (patch) | |
tree | 65a049a52e23e7d871a57b60b87b53a803900469 /drivers/rtc/class.c | |
parent | 3be95d277484117f248b2f7e8cb8d14cb38dbb04 (diff) | |
download | lwn-7ae41220ef5831674f446baef19bfe1b31358260.tar.gz lwn-7ae41220ef5831674f446baef19bfe1b31358260.zip |
rtc: introduce features bitfield
Introduce a bitfield to allow the drivers to announce the available
features for an RTC.
The main use case would be to better handle alarms, that could be present
or not or have a minute resolution or may need a correct week day to be set.
Use the newly introduced RTC_FEATURE_ALARM bit to then test whether alarms
are available instead of relying on the presence of ops->set_alarm.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210110231752.1418816-2-alexandre.belloni@bootlin.com
Diffstat (limited to 'drivers/rtc/class.c')
-rw-r--r-- | drivers/rtc/class.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 7e470fbd5e4d..03abd0aa229a 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c @@ -231,6 +231,8 @@ static struct rtc_device *rtc_allocate_device(void) rtc->pie_timer.function = rtc_pie_update_irq; rtc->pie_enabled = 0; + set_bit(RTC_FEATURE_ALARM, rtc->features); + return rtc; } @@ -386,6 +388,9 @@ int __devm_rtc_register_device(struct module *owner, struct rtc_device *rtc) return -EINVAL; } + if (!rtc->ops->set_alarm) + clear_bit(RTC_FEATURE_ALARM, rtc->features); + rtc->owner = owner; rtc_device_get_offset(rtc); |