rtc: omap: fixes and clean ups
Subsystems (2)
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
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.
--- drivers/rtc/rtc-omap.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/rtc/rtc-omap.c +7 -7
@@ -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
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.9Cc Marcin Niestroj <[email protected]>Cc Tony Lindgren <[email protected]>Signed-off-by Johan Hovold <[email protected]>
Looks good to me:
Re: [PATCH 1/4] rtc: omap: fix potential crash on power off
In reply to Johan HovoldQuoted 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.9Cc Marcin Niestroj <[email protected]>Cc Tony Lindgren <[email protected]>Signed-off-by Johan Hovold <[email protected]
Signature · 1 line
Marcin Niestroj
PATCH 2/4 rtc: omap: fix resource leak in registration error path
In reply to Johan HovoldMake sure to deregister the pin controller in case rtc registration fails.
--- drivers/rtc/rtc-omap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/rtc/rtc-omap.c +3 -1
@@ -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
PATCH 3/4 rtc: omap: add missing register lock in error path
In reply to Johan HovoldFor 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
@@ -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
PATCH 4/4 rtc: omap: drop unnecessary register unlock around reads
In reply to Johan HovoldDrop 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
@@ -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
Alexandre Belloni
maintainerQuoted 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 readsdrivers/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