rtc: tps65910: allow using RTC without alarm interrupt
PATCH 1/1 rtc: tps65910: allow using RTC without alarm interrupt
--- drivers/rtc/rtc-tps65910.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
drivers/rtc/rtc-tps65910.c +15 -4
@@ -361,6 +361,13 @@ static const struct rtc_class_ops tps65910_rtc_ops = { .set_offset = tps65910_set_offset, }; +static const struct rtc_class_ops tps65910_rtc_ops_noirq = { + .read_time = tps65910_rtc_read_time, + .set_time = tps65910_rtc_set_time, + .read_offset = tps65910_read_offset, + .set_offset = tps65910_set_offset, +}; +static int tps65910_rtc_probe (struct platform_device *pdev) {struct tps65910 *tps65910 =NULL ;
@@ -415,13 +422,17 @@ static int tps65910_rtc_probe(struct platform_device *pdev) tps65910_rtc_interrupt,IRQF_TRIGGER_LOW , dev_name(&pdev->dev), &pdev->dev);if (ret <0 ) { -dev_err (&pdev->dev,"IRQ is not free.\n" ); -return ret; +dev_err (&pdev->dev,"request IRQ:%d failed, err = %d\n" , + irq, ret); + irq =-1 ; } tps_rtc->irq = irq; -device_set_wakeup_capable (&pdev->dev,1 ); +if (irq !=-1 ) { +device_set_wakeup_capable (&pdev->dev,1 ); + tps_rtc->rtc->ops = &tps65910_rtc_ops; + }else + tps_rtc->rtc->ops = &tps65910_rtc_ops_noirq; - tps_rtc->rtc->ops = &tps65910_rtc_ops; tps_rtc->rtc->range_min =RTC_TIMESTAMP_BEGIN_2000 ; tps_rtc->rtc->range_max =RTC_TIMESTAMP_END_2099 ;
Signature · 1 line
2.20.1
Alexandre Belloni
maintainerHi,
This needs a proper commit message.
Quoted 24 lines · Andrey Skvortsov
Signed-off-by Andrey Skvortsov <[email protected]>--- drivers/rtc/rtc-tps65910.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)drivers/rtc/rtc-tps65910.c +7
-0@@ -361,6 +361,13 @@ static const struct rtc_class_ops tps65910_rtc_ops = { .set_offset = tps65910_set_offset, }; +static const struct rtc_class_ops tps65910_rtc_ops_noirq = { + .read_time = tps65910_rtc_read_time, + .set_time = tps65910_rtc_set_time, + .read_offset = tps65910_read_offset, + .set_offset = tps65910_set_offset, +}; +static int tps65910_rtc_probe (struct platform_device *pdev) {struct tps65910 *tps65910 =NULL ;
drivers/rtc/rtc-tps65910.c static int tps65910_rtc_probe(struct platform_device *pdev) · line 426
Quoted 7 lines
drivers/rtc/rtc-tps65910.c +2
-2@@ -415,13 +422,17 @@ static int tps65910_rtc_probe(struct platform_device *pdev) tps65910_rtc_interrupt,IRQF_TRIGGER_LOW , dev_name(&pdev->dev), &pdev->dev);if (ret <0 ) { -dev_err (&pdev->dev,"IRQ is not free.\n" ); -return ret; +dev_err (&pdev->dev,"request IRQ:%d failed, err = %d\n" , + irq, ret);
Do we actually need an error message here?
Quoted 17 lines
drivers/rtc/rtc-tps65910.c +6
-2+ irq =-1 ; } tps_rtc->irq = irq; -device_set_wakeup_capable (&pdev->dev,1 ); +if (irq !=-1 ) { +device_set_wakeup_capable (&pdev->dev,1 ); + tps_rtc->rtc->ops = &tps65910_rtc_ops; + }else + tps_rtc->rtc->ops = &tps65910_rtc_ops_noirq; - tps_rtc->rtc->ops = &tps65910_rtc_ops; tps_rtc->rtc->range_min =RTC_TIMESTAMP_BEGIN_2000 ; tps_rtc->rtc->range_max =RTC_TIMESTAMP_END_2099 ;Signature · 1 line
2.20.1
Signature · 3 lines
Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Quoted 3 lines · Alexandre Belloni
Hi,
This needs a proper commit message.
Add in v2.
Quoted 26 lines · Andrey Skvortsov
Quoted 25 lines
Signed-off-by Andrey Skvortsov <[email protected]>--- drivers/rtc/rtc-tps65910.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)drivers/rtc/rtc-tps65910.c +7
-0@@ -361,6 +361,13 @@ static const struct rtc_class_ops tps65910_rtc_ops = { .set_offset = tps65910_set_offset, }; +static const struct rtc_class_ops tps65910_rtc_ops_noirq = { + .read_time = tps65910_rtc_read_time, + .set_time = tps65910_rtc_set_time, + .read_offset = tps65910_read_offset, + .set_offset = tps65910_set_offset, +}; +static int tps65910_rtc_probe (struct platform_device *pdev) {struct tps65910 *tps65910 =NULL ;@@ -415,13 +422,17 @@ static int tps65910_rtc_probe(struct platform_device *pdev) tps65910_rtc_interrupt, IRQF_TRIGGER_LOW,
Quoted 8 lines
drivers/rtc/rtc-tps65910.c static int tps65910_rtc_probe(struct platform_device *pdev) · line 426
Quoted 6 lines
drivers/rtc/rtc-tps65910.c +2
-2dev_name(&pdev->dev), &pdev->dev);if (ret <0 ) { -dev_err (&pdev->dev,"IRQ is not free.\n" ); -return ret; +dev_err (&pdev->dev,"request IRQ:%d failed, err = %d\n" , + irq, ret);Do we actually need an error message here?
You are right. This is definitely not an error anymore. What aboutdev_warn(&pdev->dev, "unable to request IRQ, alarms disabled\n"); like some other drivers do?
grep -RHn 'unable to request IRQ, alarms disabled'
rtc-rv8803.c:576: dev_warn(&client->dev, "unable to request IRQ, alarms disabled\n");
rtc-m41t80.c:914: dev_warn(&client->dev, "unable to request IRQ, alarms disabled\n");
rtc-rv3028.c:651: dev_warn(&client->dev, "unable to request IRQ, alarms disabled\n");
rtc-pcf85363.c:416: dev_warn(&client->dev, "unable to request IRQ, alarms disabled\n");
rtc-pcf85063.c:458: "unable to request IRQ, alarms disabled\n");
rtc-rv3029c2.c:828: dev_warn(dev, "unable to request IRQ, alarms disabled\n");
rtc-rx8025.c:540: dev_err(&client->dev, "unable to request IRQ, alarms disabled\n");
rtc-abx80x.c:839: dev_err(&client->dev, "unable to request IRQ, alarms disabled\n");
Quoted 23 lines
Quoted 18 lines
drivers/rtc/rtc-tps65910.c +6
-2+ irq =-1 ; } tps_rtc->irq = irq; -device_set_wakeup_capable (&pdev->dev,1 ); +if (irq !=-1 ) { +device_set_wakeup_capable (&pdev->dev,1 ); + tps_rtc->rtc->ops = &tps65910_rtc_ops; + }else + tps_rtc->rtc->ops = &tps65910_rtc_ops_noirq; - tps_rtc->rtc->ops = &tps65910_rtc_ops; tps_rtc->rtc->range_min =RTC_TIMESTAMP_BEGIN_2000 ; tps_rtc->rtc->range_max =RTC_TIMESTAMP_END_2099 ;Signature · 1 line
2.20.1Signature · 3 lines
Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Signature · 2 lines
Best regards, Andrey Skvortsov
Alexandre Belloni
maintainerQuoted 14 lines · Andrey Skvortsov
Quoted 5 lines
Quoted 5 lines
static int
tps65910_rtc_probe(struct platform_device *pdev){drivers/rtc/rtc-tps65910.c +0
-0struct tps65910 *tps65910 =NULL ;@@ -415,13 +422,17 @@ static int tps65910_rtc_probe(struct platform_device *pdev) tps65910_rtc_interrupt, IRQF_TRIGGER_LOW,Quoted 8 lines
drivers/rtc/rtc-tps65910.c static int tps65910_rtc_probe(struct platform_device *pdev) · line 426
Quoted 6 lines
drivers/rtc/rtc-tps65910.c +2
-2dev_name(&pdev->dev), &pdev->dev);if (ret <0 ) { -dev_err (&pdev->dev,"IRQ is not free.\n" ); -return ret; +dev_err (&pdev->dev,"request IRQ:%d failed, err = %d\n" , + irq, ret);Do we actually need an error message here?
Quoted 5 lines
You are right. This is definitely not an error anymore. What about
dev_warn(&pdev->dev, "unable to request IRQ, alarms disabled\n"); like some other drivers do?
Yes, or that can be left out completely as userspace will be able to know whether alarms are supported without this message.
Signature · 3 lines
Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v2 1/1 rtc: tps65910: allow using RTC without alarm interrupt
If tps65910 INT1 pin (IRQ output) is not wired to any IRQ controller, then it can't be used as system wakeup/alarm source,
but it is still possible to read/write time from/to RTC.
---
v1 -> v2:
- add detailed commit description
- remove error message about failed IRQ request
drivers/rtc/rtc-tps65910.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/rtc/rtc-tps65910.c +15 -6
@@ -361,6 +361,13 @@ static const struct rtc_class_ops tps65910_rtc_ops = { .set_offset = tps65910_set_offset, }; +static const struct rtc_class_ops tps65910_rtc_ops_noirq = { + .read_time = tps65910_rtc_read_time, + .set_time = tps65910_rtc_set_time, + .read_offset = tps65910_read_offset, + .set_offset = tps65910_set_offset, +}; +static int tps65910_rtc_probe (struct platform_device *pdev) {struct tps65910 *tps65910 =NULL ;
@@ -414,14 +421,16 @@ static int tps65910_rtc_probe(struct platform_device *pdev) ret =devm_request_threaded_irq (&pdev->dev, irq,NULL , tps65910_rtc_interrupt,IRQF_TRIGGER_LOW ,dev_name (&pdev->dev), &pdev->dev); -if (ret <0 ) { -dev_err (&pdev->dev,"IRQ is not free.\n" ); -return ret; - } +if (ret <0 ) + irq =-1 ; + tps_rtc->irq = irq; -device_set_wakeup_capable (&pdev->dev,1 ); +if (irq !=-1 ) { +device_set_wakeup_capable (&pdev->dev,1 ); + tps_rtc->rtc->ops = &tps65910_rtc_ops; + }else + tps_rtc->rtc->ops = &tps65910_rtc_ops_noirq; - tps_rtc->rtc->ops = &tps65910_rtc_ops; tps_rtc->rtc->range_min =RTC_TIMESTAMP_BEGIN_2000 ; tps_rtc->rtc->range_max =RTC_TIMESTAMP_END_2099 ;
Signature · 1 line
2.20.1
Quoted 5 lines · Andrey Skvortsov
If tps65910 INT1 pin (IRQ output) is not wired to any IRQ controller, then it can't be used as system wakeup/alarm source,
but it is still possible to read/write time from/to RTC.Signed-off-by Andrey Skvortsov <[email protected]>
Quoted 9 lines
---
v1 -> v2:
- add detailed commit description
- remove error message about failed IRQ requestdrivers/rtc/rtc-tps65910.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
Applied, thanks.
Signature · 3 lines
Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com