Skip to contentSkip to conversation

rtc: omap: fixes and clean ups

PATCH In review Johan Hovold 4 participants 8 messages Jul 4, 2018 – Jul 12, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover rtc: omap: fixes and clean ups

Here are a couple of fixes for issues discovered through inspection along with some clean ups.

Johan

Johan Hovold (4):
rtc: omap: fix potential crash on power off
rtc: omap: fix resource leak in registration error path
rtc: omap: add missing register lock in error path
rtc: omap: drop unnecessary register unlock around reads

 drivers/rtc/rtc-omap.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
Signature · 1 line
2.18.0
#1 lore raw

PATCH 1/4 rtc: omap: fix potential crash on power off

Do not set the system power-off callback and omap power-off rtc pointer until we're done setting up our device to avoid leaving stale pointers around after a late probe error.

Fixes 97ea1906b3c2 ("rtc: omap: Support ext_wakeup configuration")
Cc stable <[email protected]> # 4.9
Cc Marcin Niestroj <[email protected]>
Cc Tony Lindgren <[email protected]>
---
 drivers/rtc/rtc-omap.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/rtc/rtc-omap.c +7 -7
index 39086398833e..c214b69a8787 100644
@@ -861,13 +861,6 @@ static int omap_rtc_probe(struct platform_device *pdev)
 			goto err;
 	}
 
-	if (rtc->is_pmic_controller) {
-		if (!pm_power_off) {
-			omap_rtc_power_off_rtc = rtc;
-			pm_power_off = omap_rtc_power_off;
-		}
-	}
-
 	/* Support ext_wakeup pinconf */
 	rtc_pinctrl_desc.name = dev_name(&pdev->dev);
 
@@ -884,6 +877,13 @@ static int omap_rtc_probe(struct platform_device *pdev)
 
 	rtc_nvmem_register(rtc->rtc, &omap_rtc_nvmem_config);
 
+	if (rtc->is_pmic_controller) {
+		if (!pm_power_off) {
+			omap_rtc_power_off_rtc = rtc;
+			pm_power_off = omap_rtc_power_off;
+		}
+	}
+
 	return 0;
 
 err:
Signature · 1 line
2.18.0
Acked-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] rtc: omap: fix potential crash on power off

Quoted 9 lines · Johan Hovold

Do not set the system power-off callback and omap power-off rtc pointer until we're done setting up our device to avoid leaving stale pointers around after a late probe error.

Fixes 97ea1906b3c2 ("rtc: omap: Support ext_wakeup configuration")
Cc stable <[email protected]> # 4.9
Cc Marcin Niestroj <[email protected]>
Cc Tony Lindgren <[email protected]>

Looks good to me:

Reviewed-by on v1 1/4
#3 lore raw

Re: [PATCH 1/4] rtc: omap: fix potential crash on power off

In reply to Johan Hovold
Quoted 9 lines · Johan Hovold

Do not set the system power-off callback and omap power-off rtc pointer until we're done setting up our device to avoid leaving stale pointers around after a late probe error.

Fixes 97ea1906b3c2 ("rtc: omap: Support ext_wakeup configuration")
Cc stable <[email protected]> # 4.9
Cc Marcin Niestroj <[email protected]>
Cc Tony Lindgren <[email protected]>
Signature · 1 line
Marcin Niestroj
#4 lore raw

PATCH 2/4 rtc: omap: fix resource leak in registration error path

In reply to Johan Hovold

Make sure to deregister the pin controller in case rtc registration fails.

Fixes 57072758623f ("rtc: omap: switch to rtc_register_device")
Cc stable <[email protected]> # 4.14
Cc Alexandre Belloni <[email protected]>
---
 drivers/rtc/rtc-omap.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/rtc/rtc-omap.c +3 -1
index c214b69a8787..6a7b804c3074 100644
@@ -873,7 +873,7 @@ static int omap_rtc_probe(struct platform_device *pdev)
 
 	ret = rtc_register_device(rtc->rtc);
 	if (ret)
-		goto err;
+		goto err_deregister_pinctrl;
 
 	rtc_nvmem_register(rtc->rtc, &omap_rtc_nvmem_config);
 
@@ -886,6 +886,8 @@ static int omap_rtc_probe(struct platform_device *pdev)
 
 	return 0;
 
+err_deregister_pinctrl:
+	pinctrl_unregister(rtc->pctldev);
 err:
 	clk_disable_unprepare(rtc->clk);
 	device_init_wakeup(&pdev->dev, false);
Signature · 1 line
2.18.0
#5 lore raw

PATCH 3/4 rtc: omap: add missing register lock in error path

In reply to Johan Hovold

For completeness re-lock the registers also in the power-off error path.

---
 drivers/rtc/rtc-omap.c | 1 +
 1 file changed, 1 insertion(+)
drivers/rtc/rtc-omap.c +1 -0
index 6a7b804c3074..7f9ee559dd99 100644
@@ -449,6 +449,7 @@ static void omap_rtc_power_off(void)
 
 	if (tm2bcd(&tm) < 0) {
 		dev_err(&rtc->rtc->dev, "power off failed\n");
+		rtc->type->lock(rtc);
 		return;
 	}
 
Signature · 1 line
2.18.0
#6 lore raw

PATCH 4/4 rtc: omap: drop unnecessary register unlock around reads

In reply to Johan Hovold

Drop unnecessary register write-unlock around two read accesses.

---
 drivers/rtc/rtc-omap.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/rtc/rtc-omap.c +0 -4
index 7f9ee559dd99..323ff55cc165 100644
@@ -583,9 +583,7 @@ static int rtc_pinconf_get(struct pinctrl_dev *pctldev,
 	u32 val;
 	u16 arg = 0;
 
-	rtc->type->unlock(rtc);
 	val = rtc_readl(rtc, OMAP_RTC_PMIC_REG);
-	rtc->type->lock(rtc);
 
 	switch (param) {
 	case PIN_CONFIG_INPUT_ENABLE:
@@ -615,9 +613,7 @@ static int rtc_pinconf_set(struct pinctrl_dev *pctldev,
 	u32 param_val;
 	int i;
 
-	rtc->type->unlock(rtc);
 	val = rtc_readl(rtc, OMAP_RTC_PMIC_REG);
-	rtc->type->lock(rtc);
 
 	/* active low by default */
 	val |= OMAP_RTC_PMIC_EXT_WKUP_POL(pin);
Signature · 1 line
2.18.0
#7 lore raw
In reply to Johan Hovold
Quoted 6 lines · Johan Hovold

Here are a couple of fixes for issues discovered through inspection along with some clean ups.

Johan

Quoted 9 lines

Johan Hovold (4):
rtc: omap: fix potential crash on power off
rtc: omap: fix resource leak in registration error path
rtc: omap: add missing register lock in error path
rtc: omap: drop unnecessary register unlock around reads

 drivers/rtc/rtc-omap.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

All applied, thanks

Quoted 3 lines
Signature · 1 line
2.18.0
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com