* [PATCH 1/5] rtc: at91sam9: properly handle error case
@ 2015-07-30 0:24 Alexandre Belloni
2015-07-30 0:24 ` [PATCH 2/5] rtc: at91sam9: remove useless check Alexandre Belloni
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Alexandre Belloni @ 2015-07-30 0:24 UTC (permalink / raw)
To: linux-arm-kernel
In case of a probe error, it is possible to abort after issuing
clk_prepare_enable(). Ensure the clock is disabled and unprepared in that
case.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/rtc/rtc-at91sam9.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
index 5ccaee32df72..152cd816cc43 100644
--- a/drivers/rtc/rtc-at91sam9.c
+++ b/drivers/rtc/rtc-at91sam9.c
@@ -451,8 +451,10 @@ static int at91_rtc_probe(struct platform_device *pdev)
rtc->rtcdev = devm_rtc_device_register(&pdev->dev, pdev->name,
&at91_rtc_ops, THIS_MODULE);
- if (IS_ERR(rtc->rtcdev))
- return PTR_ERR(rtc->rtcdev);
+ if (IS_ERR(rtc->rtcdev)) {
+ ret = PTR_ERR(rtc->rtcdev);
+ goto err_clk;
+ }
/* register irq handler after we know what name we'll use */
ret = devm_request_irq(&pdev->dev, rtc->irq, at91_rtc_interrupt,
@@ -460,7 +462,7 @@ static int at91_rtc_probe(struct platform_device *pdev)
dev_name(&rtc->rtcdev->dev), rtc);
if (ret) {
dev_dbg(&pdev->dev, "can't share IRQ %d?\n", rtc->irq);
- return ret;
+ goto err_clk;
}
/* NOTE: sam9260 rev A silicon has a ROM bug which resets the
@@ -474,6 +476,11 @@ static int at91_rtc_probe(struct platform_device *pdev)
dev_name(&rtc->rtcdev->dev));
return 0;
+
+err_clk:
+ clk_disable_unprepare(rtc->sclk);
+
+ return ret;
}
/*
--
2.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/5] rtc: at91sam9: remove useless check
2015-07-30 0:24 [PATCH 1/5] rtc: at91sam9: properly handle error case Alexandre Belloni
@ 2015-07-30 0:24 ` Alexandre Belloni
2015-07-30 0:24 ` [PATCH 3/5] rtc: at91sam9: sort headers alphabetically Alexandre Belloni
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Alexandre Belloni @ 2015-07-30 0:24 UTC (permalink / raw)
To: linux-arm-kernel
rtc->sclk necessarily points to a valid clocks at this point. Else the
probe would have aborted.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/rtc/rtc-at91sam9.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
index 152cd816cc43..0a8485ac3864 100644
--- a/drivers/rtc/rtc-at91sam9.c
+++ b/drivers/rtc/rtc-at91sam9.c
@@ -494,8 +494,7 @@ static int at91_rtc_remove(struct platform_device *pdev)
/* disable all interrupts */
rtt_writel(rtc, MR, mr & ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN));
- if (!IS_ERR(rtc->sclk))
- clk_disable_unprepare(rtc->sclk);
+ clk_disable_unprepare(rtc->sclk);
return 0;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/5] rtc: at91sam9: sort headers alphabetically
2015-07-30 0:24 [PATCH 1/5] rtc: at91sam9: properly handle error case Alexandre Belloni
2015-07-30 0:24 ` [PATCH 2/5] rtc: at91sam9: remove useless check Alexandre Belloni
@ 2015-07-30 0:24 ` Alexandre Belloni
2015-07-30 0:24 ` [PATCH 4/5] rtc: at91sam9: get sclk rate after enabling it Alexandre Belloni
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Alexandre Belloni @ 2015-07-30 0:24 UTC (permalink / raw)
To: linux-arm-kernel
Sort included headers alphabetically.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/rtc/rtc-at91sam9.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
index 0a8485ac3864..23f721d049b2 100644
--- a/drivers/rtc/rtc-at91sam9.c
+++ b/drivers/rtc/rtc-at91sam9.c
@@ -11,20 +11,20 @@
* 2 of the License, or (at your option) any later version.
*/
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/platform_device.h>
-#include <linux/time.h>
-#include <linux/rtc.h>
+#include <linux/clk.h>
#include <linux/interrupt.h>
#include <linux/ioctl.h>
-#include <linux/slab.h>
-#include <linux/platform_data/atmel.h>
#include <linux/io.h>
+#include <linux/kernel.h>
#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/platform_data/atmel.h>
+#include <linux/platform_device.h>
#include <linux/regmap.h>
+#include <linux/rtc.h>
+#include <linux/slab.h>
#include <linux/suspend.h>
-#include <linux/clk.h>
+#include <linux/time.h>
/*
* This driver uses two configurable hardware resources that live in the
--
2.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/5] rtc: at91sam9: get sclk rate after enabling it
2015-07-30 0:24 [PATCH 1/5] rtc: at91sam9: properly handle error case Alexandre Belloni
2015-07-30 0:24 ` [PATCH 2/5] rtc: at91sam9: remove useless check Alexandre Belloni
2015-07-30 0:24 ` [PATCH 3/5] rtc: at91sam9: sort headers alphabetically Alexandre Belloni
@ 2015-07-30 0:24 ` Alexandre Belloni
2015-07-30 0:24 ` [PATCH 5/5] rtc: at91rm9200: sort headers alphabetically Alexandre Belloni
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Alexandre Belloni @ 2015-07-30 0:24 UTC (permalink / raw)
To: linux-arm-kernel
See help for clk_get_rate(): "obtain the current clock rate (in Hz) for a
clock source. This is only valid once the clock source has been enabled."
It currently returns the correct value but that may not stay that way.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/rtc/rtc-at91sam9.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
index 23f721d049b2..f9e85ace5e71 100644
--- a/drivers/rtc/rtc-at91sam9.c
+++ b/drivers/rtc/rtc-at91sam9.c
@@ -425,18 +425,19 @@ static int at91_rtc_probe(struct platform_device *pdev)
if (IS_ERR(rtc->sclk))
return PTR_ERR(rtc->sclk);
- sclk_rate = clk_get_rate(rtc->sclk);
- if (!sclk_rate || sclk_rate > AT91_RTT_RTPRES) {
- dev_err(&pdev->dev, "Invalid slow clock rate\n");
- return -EINVAL;
- }
-
ret = clk_prepare_enable(rtc->sclk);
if (ret) {
dev_err(&pdev->dev, "Could not enable slow clock\n");
return ret;
}
+ sclk_rate = clk_get_rate(rtc->sclk);
+ if (!sclk_rate || sclk_rate > AT91_RTT_RTPRES) {
+ dev_err(&pdev->dev, "Invalid slow clock rate\n");
+ ret = -EINVAL;
+ goto err_clk;
+ }
+
mr = rtt_readl(rtc, MR);
/* unless RTT is counting at 1 Hz, re-initialize it */
--
2.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/5] rtc: at91rm9200: sort headers alphabetically
2015-07-30 0:24 [PATCH 1/5] rtc: at91sam9: properly handle error case Alexandre Belloni
` (2 preceding siblings ...)
2015-07-30 0:24 ` [PATCH 4/5] rtc: at91sam9: get sclk rate after enabling it Alexandre Belloni
@ 2015-07-30 0:24 ` Alexandre Belloni
2015-07-30 9:28 ` [PATCH 1/5] rtc: at91sam9: properly handle error case Boris Brezillon
2015-07-30 9:57 ` Nicolas Ferre
5 siblings, 0 replies; 7+ messages in thread
From: Alexandre Belloni @ 2015-07-30 0:24 UTC (permalink / raw)
To: linux-arm-kernel
Sort included headers alphabetically.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/rtc/rtc-at91rm9200.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
index 8093d9e50619..cb62e214b52a 100644
--- a/drivers/rtc/rtc-at91rm9200.c
+++ b/drivers/rtc/rtc-at91rm9200.c
@@ -18,21 +18,21 @@
*
*/
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/platform_device.h>
-#include <linux/time.h>
-#include <linux/rtc.h>
#include <linux/bcd.h>
#include <linux/clk.h>
+#include <linux/completion.h>
#include <linux/interrupt.h>
-#include <linux/spinlock.h>
#include <linux/ioctl.h>
-#include <linux/completion.h>
#include <linux/io.h>
-#include <linux/of.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
#include <linux/of_device.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/rtc.h>
+#include <linux/spinlock.h>
#include <linux/suspend.h>
+#include <linux/time.h>
#include <linux/uaccess.h>
#include "rtc-at91rm9200.h"
--
2.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 1/5] rtc: at91sam9: properly handle error case
2015-07-30 0:24 [PATCH 1/5] rtc: at91sam9: properly handle error case Alexandre Belloni
` (3 preceding siblings ...)
2015-07-30 0:24 ` [PATCH 5/5] rtc: at91rm9200: sort headers alphabetically Alexandre Belloni
@ 2015-07-30 9:28 ` Boris Brezillon
2015-07-30 9:57 ` Nicolas Ferre
5 siblings, 0 replies; 7+ messages in thread
From: Boris Brezillon @ 2015-07-30 9:28 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, 30 Jul 2015 02:24:28 +0200
Alexandre Belloni <alexandre.belloni@free-electrons.com> wrote:
> In case of a probe error, it is possible to abort after issuing
> clk_prepare_enable(). Ensure the clock is disabled and unprepared in that
> case.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To the whole series:
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> drivers/rtc/rtc-at91sam9.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
> index 5ccaee32df72..152cd816cc43 100644
> --- a/drivers/rtc/rtc-at91sam9.c
> +++ b/drivers/rtc/rtc-at91sam9.c
> @@ -451,8 +451,10 @@ static int at91_rtc_probe(struct platform_device *pdev)
>
> rtc->rtcdev = devm_rtc_device_register(&pdev->dev, pdev->name,
> &at91_rtc_ops, THIS_MODULE);
> - if (IS_ERR(rtc->rtcdev))
> - return PTR_ERR(rtc->rtcdev);
> + if (IS_ERR(rtc->rtcdev)) {
> + ret = PTR_ERR(rtc->rtcdev);
> + goto err_clk;
> + }
>
> /* register irq handler after we know what name we'll use */
> ret = devm_request_irq(&pdev->dev, rtc->irq, at91_rtc_interrupt,
> @@ -460,7 +462,7 @@ static int at91_rtc_probe(struct platform_device *pdev)
> dev_name(&rtc->rtcdev->dev), rtc);
> if (ret) {
> dev_dbg(&pdev->dev, "can't share IRQ %d?\n", rtc->irq);
> - return ret;
> + goto err_clk;
> }
>
> /* NOTE: sam9260 rev A silicon has a ROM bug which resets the
> @@ -474,6 +476,11 @@ static int at91_rtc_probe(struct platform_device *pdev)
> dev_name(&rtc->rtcdev->dev));
>
> return 0;
> +
> +err_clk:
> + clk_disable_unprepare(rtc->sclk);
> +
> + return ret;
> }
>
> /*
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/5] rtc: at91sam9: properly handle error case
2015-07-30 0:24 [PATCH 1/5] rtc: at91sam9: properly handle error case Alexandre Belloni
` (4 preceding siblings ...)
2015-07-30 9:28 ` [PATCH 1/5] rtc: at91sam9: properly handle error case Boris Brezillon
@ 2015-07-30 9:57 ` Nicolas Ferre
5 siblings, 0 replies; 7+ messages in thread
From: Nicolas Ferre @ 2015-07-30 9:57 UTC (permalink / raw)
To: linux-arm-kernel
Le 30/07/2015 02:24, Alexandre Belloni a ?crit :
> In case of a probe error, it is possible to abort after issuing
> clk_prepare_enable(). Ensure the clock is disabled and unprepared in that
> case.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To the whole series:
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Thanks.
> ---
> drivers/rtc/rtc-at91sam9.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
> index 5ccaee32df72..152cd816cc43 100644
> --- a/drivers/rtc/rtc-at91sam9.c
> +++ b/drivers/rtc/rtc-at91sam9.c
> @@ -451,8 +451,10 @@ static int at91_rtc_probe(struct platform_device *pdev)
>
> rtc->rtcdev = devm_rtc_device_register(&pdev->dev, pdev->name,
> &at91_rtc_ops, THIS_MODULE);
> - if (IS_ERR(rtc->rtcdev))
> - return PTR_ERR(rtc->rtcdev);
> + if (IS_ERR(rtc->rtcdev)) {
> + ret = PTR_ERR(rtc->rtcdev);
> + goto err_clk;
> + }
>
> /* register irq handler after we know what name we'll use */
> ret = devm_request_irq(&pdev->dev, rtc->irq, at91_rtc_interrupt,
> @@ -460,7 +462,7 @@ static int at91_rtc_probe(struct platform_device *pdev)
> dev_name(&rtc->rtcdev->dev), rtc);
> if (ret) {
> dev_dbg(&pdev->dev, "can't share IRQ %d?\n", rtc->irq);
> - return ret;
> + goto err_clk;
> }
>
> /* NOTE: sam9260 rev A silicon has a ROM bug which resets the
> @@ -474,6 +476,11 @@ static int at91_rtc_probe(struct platform_device *pdev)
> dev_name(&rtc->rtcdev->dev));
>
> return 0;
> +
> +err_clk:
> + clk_disable_unprepare(rtc->sclk);
> +
> + return ret;
> }
>
> /*
>
--
Nicolas Ferre
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-07-30 9:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-30 0:24 [PATCH 1/5] rtc: at91sam9: properly handle error case Alexandre Belloni
2015-07-30 0:24 ` [PATCH 2/5] rtc: at91sam9: remove useless check Alexandre Belloni
2015-07-30 0:24 ` [PATCH 3/5] rtc: at91sam9: sort headers alphabetically Alexandre Belloni
2015-07-30 0:24 ` [PATCH 4/5] rtc: at91sam9: get sclk rate after enabling it Alexandre Belloni
2015-07-30 0:24 ` [PATCH 5/5] rtc: at91rm9200: sort headers alphabetically Alexandre Belloni
2015-07-30 9:28 ` [PATCH 1/5] rtc: at91sam9: properly handle error case Boris Brezillon
2015-07-30 9:57 ` Nicolas Ferre
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).