Re: [PATCH 6/6] rtc: rv3029: add alarm IRQ
From: Alexandre Belloni
Date: Fri Apr 22 2016 - 19:49:21 EST
On 21/04/2016 at 20:24:19 +0200, Mylène Josserand wrote :
> @@ -731,11 +786,9 @@ static void rv3029_hwmon_register(struct device *dev, const char *name)
>
> #endif /* CONFIG_RTC_DRV_RV3029_HWMON */
>
> -static const struct rtc_class_ops rv3029_rtc_ops = {
> +static struct rtc_class_ops rv3029_rtc_ops = {
> .read_time = rv3029_read_time,
> .set_time = rv3029_set_time,
> - .read_alarm = rv3029_read_alarm,
> - .set_alarm = rv3029_set_alarm,
> };
>
> static struct i2c_device_id rv3029_id[] = {
> @@ -772,8 +825,27 @@ static int rv3029_probe(struct device *dev, struct regmap *regmap, int irq,
>
> rv3029->rtc = devm_rtc_device_register(dev, name, &rv3029_rtc_ops,
> THIS_MODULE);
> + if (IS_ERR(rv3029->rtc)) {
> + dev_err(dev, "unable to register the class device\n");
> + return PTR_ERR(rv3029->rtc);
> + }
>
> - return PTR_ERR_OR_ZERO(rv3029->rtc);
> + if (rv3029->irq > 0) {
> + rc = devm_request_threaded_irq(dev, rv3029->irq,
> + NULL, rv3029_handle_irq,
> + IRQF_TRIGGER_LOW | IRQF_ONESHOT,
> + "rv3029", dev);
> + if (rc) {
> + dev_warn(dev, "unable to request IRQ, alarms disabled\n");
> + rv3029->irq = 0;
> + } else {
> + rv3029_rtc_ops.read_alarm = rv3029_read_alarm;
> + rv3029_rtc_ops.set_alarm = rv3029_set_alarm;
> + rv3029_rtc_ops.alarm_irq_enable = rv3029_alarm_irq_enable;
> + }
> + }
> +
While this work, devm_rtc_device_register() needs to know whether the
alarms are enabled and will try to call .read_alarm(). That is not
completely an issue right now and as we discussed, I'm planning to send
a rework of the rtc core to overcome that issue.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com