It's missed to call clk_unprepare() about info->rtc_src_clk in
s3c_rtc_remove and to call clk_disable_unprepare about info->rtc_clk in
error routine of s3c_rtc_probe.
Signed-off-by: Joonyoung Shim <[email protected]>
---
drivers/rtc/rtc-s3c.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index a0f8323..d1866a4 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -410,6 +410,8 @@ static int s3c_rtc_remove(struct platform_device *pdev)
s3c_rtc_setaie(info->dev, 0);
+ if (info->data->needs_src_clk)
+ clk_unprepare(info->rtc_src_clk);
clk_unprepare(info->rtc_clk);
info->rtc_clk = NULL;
@@ -482,6 +484,7 @@ static int s3c_rtc_probe(struct platform_device *pdev)
if (IS_ERR(info->rtc_src_clk)) {
dev_err(&pdev->dev,
"failed to find rtc source clock\n");
+ clk_disable_unprepare(info->rtc_clk);
return PTR_ERR(info->rtc_src_clk);
}
clk_prepare_enable(info->rtc_src_clk);
--
1.9.1
It's unnecessary the code that assigns info->rtc_clk to NULL in
s3c_rtc_remove.
Signed-off-by: Joonyoung Shim <[email protected]>
---
drivers/rtc/rtc-s3c.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index d1866a4..44b2921 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -413,7 +413,6 @@ static int s3c_rtc_remove(struct platform_device *pdev)
if (info->data->needs_src_clk)
clk_unprepare(info->rtc_src_clk);
clk_unprepare(info->rtc_clk);
- info->rtc_clk = NULL;
return 0;
}
--
1.9.1
The driver uses clk_prepare_enable()/clk_disable_unprepare() only in
probe only, elsewhere, use the unified functions for enable/disable of
clk, e.g. s3c_rtc_enable_clk() / s3c_rtc_disable_clk(), so it's better
to use them for consistency of code.
Signed-off-by: Joonyoung Shim <[email protected]>
---
drivers/rtc/rtc-s3c.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index 44b2921..abe2a6d 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -476,19 +476,21 @@ static int s3c_rtc_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "failed to find rtc clock\n");
return PTR_ERR(info->rtc_clk);
}
- clk_prepare_enable(info->rtc_clk);
+ clk_prepare(info->rtc_clk);
if (info->data->needs_src_clk) {
info->rtc_src_clk = devm_clk_get(&pdev->dev, "rtc_src");
if (IS_ERR(info->rtc_src_clk)) {
dev_err(&pdev->dev,
"failed to find rtc source clock\n");
- clk_disable_unprepare(info->rtc_clk);
+ clk_unprepare(info->rtc_clk);
return PTR_ERR(info->rtc_src_clk);
}
- clk_prepare_enable(info->rtc_src_clk);
+ clk_prepare(info->rtc_src_clk);
}
+ s3c_rtc_enable_clk(info);
+
/* check to see if everything is setup correctly */
if (info->data->enable)
info->data->enable(info);
@@ -548,9 +550,11 @@ static int s3c_rtc_probe(struct platform_device *pdev)
if (info->data->disable)
info->data->disable(info);
+ s3c_rtc_disable_clk(info);
+
if (info->data->needs_src_clk)
- clk_disable_unprepare(info->rtc_src_clk);
- clk_disable_unprepare(info->rtc_clk);
+ clk_unprepare(info->rtc_src_clk);
+ clk_unprepare(info->rtc_clk);
return ret;
}
--
1.9.1
The clock enable/disable codes for alarm have removed from
'commit 24e1455493da ("drivers/rtc/rtc-s3c.c: delete duplicate clock
control")' and the clocks keep disabling even if alarm is set, so alarm
interrupt can't happen.
The s3c_rtc_setaie function can be called several times with that
enabled argument has same value, so it needs to check whether clocks is
enabled or not.
Signed-off-by: Joonyoung Shim <[email protected]>
---
drivers/rtc/rtc-s3c.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index abe2a6d..fce078c 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -39,6 +39,7 @@ struct s3c_rtc {
void __iomem *base;
struct clk *rtc_clk;
struct clk *rtc_src_clk;
+ bool clk_enabled;
struct s3c_rtc_data *data;
@@ -71,9 +72,12 @@ static void s3c_rtc_enable_clk(struct s3c_rtc *info)
unsigned long irq_flags;
spin_lock_irqsave(&info->alarm_clk_lock, irq_flags);
- clk_enable(info->rtc_clk);
- if (info->data->needs_src_clk)
- clk_enable(info->rtc_src_clk);
+ if (!info->clk_enabled) {
+ clk_enable(info->rtc_clk);
+ if (info->data->needs_src_clk)
+ clk_enable(info->rtc_src_clk);
+ info->clk_enabled = true;
+ }
spin_unlock_irqrestore(&info->alarm_clk_lock, irq_flags);
}
@@ -82,9 +86,12 @@ static void s3c_rtc_disable_clk(struct s3c_rtc *info)
unsigned long irq_flags;
spin_lock_irqsave(&info->alarm_clk_lock, irq_flags);
- if (info->data->needs_src_clk)
- clk_disable(info->rtc_src_clk);
- clk_disable(info->rtc_clk);
+ if (info->clk_enabled) {
+ if (info->data->needs_src_clk)
+ clk_disable(info->rtc_src_clk);
+ clk_disable(info->rtc_clk);
+ info->clk_enabled = false;
+ }
spin_unlock_irqrestore(&info->alarm_clk_lock, irq_flags);
}
@@ -128,6 +135,11 @@ static int s3c_rtc_setaie(struct device *dev, unsigned int enabled)
s3c_rtc_disable_clk(info);
+ if (enabled)
+ s3c_rtc_enable_clk(info);
+ else
+ s3c_rtc_disable_clk(info);
+
return 0;
}
--
1.9.1
On 11.08.2015 20:28, Joonyoung Shim wrote:
> It's missed to call clk_unprepare() about info->rtc_src_clk in
> s3c_rtc_remove and to call clk_disable_unprepare about info->rtc_clk in
> error routine of s3c_rtc_probe.
>
> Signed-off-by: Joonyoung Shim <[email protected]>
> ---
> drivers/rtc/rtc-s3c.c | 3 +++
> 1 file changed, 3 insertions(+)
Reviewed-by: Krzysztof Kozlowski <[email protected]>
Best regards,
Krzysztof
On 11.08.2015 20:28, Joonyoung Shim wrote:
> It's unnecessary the code that assigns info->rtc_clk to NULL in
> s3c_rtc_remove.
>
> Signed-off-by: Joonyoung Shim <[email protected]>
> ---
> drivers/rtc/rtc-s3c.c | 1 -
> 1 file changed, 1 deletion(-)
Reviewed-by: Krzysztof Kozlowski <[email protected]>
Best regards,
Krzysztof
On 11.08.2015 20:28, Joonyoung Shim wrote:
> The driver uses clk_prepare_enable()/clk_disable_unprepare() only in
> probe only, elsewhere, use the unified functions for enable/disable of
> clk, e.g. s3c_rtc_enable_clk() / s3c_rtc_disable_clk(), so it's better
> to use them for consistency of code.
>
> Signed-off-by: Joonyoung Shim <[email protected]>
> ---
> drivers/rtc/rtc-s3c.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
First of all - the code is larger (9 insertions, 5 deletion) so I have
doubts if this is better.
Second - this is not equivalent change. The s3c_rtc_enable_clk/disable
calls grab spin lock which is not necessary in probe.
Best regards,
Krzysztof
>
> diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
> index 44b2921..abe2a6d 100644
> --- a/drivers/rtc/rtc-s3c.c
> +++ b/drivers/rtc/rtc-s3c.c
> @@ -476,19 +476,21 @@ static int s3c_rtc_probe(struct platform_device *pdev)
> dev_err(&pdev->dev, "failed to find rtc clock\n");
> return PTR_ERR(info->rtc_clk);
> }
> - clk_prepare_enable(info->rtc_clk);
> + clk_prepare(info->rtc_clk);
>
> if (info->data->needs_src_clk) {
> info->rtc_src_clk = devm_clk_get(&pdev->dev, "rtc_src");
> if (IS_ERR(info->rtc_src_clk)) {
> dev_err(&pdev->dev,
> "failed to find rtc source clock\n");
> - clk_disable_unprepare(info->rtc_clk);
> + clk_unprepare(info->rtc_clk);
> return PTR_ERR(info->rtc_src_clk);
> }
> - clk_prepare_enable(info->rtc_src_clk);
> + clk_prepare(info->rtc_src_clk);
> }
>
> + s3c_rtc_enable_clk(info);
> +
> /* check to see if everything is setup correctly */
> if (info->data->enable)
> info->data->enable(info);
> @@ -548,9 +550,11 @@ static int s3c_rtc_probe(struct platform_device *pdev)
> if (info->data->disable)
> info->data->disable(info);
>
> + s3c_rtc_disable_clk(info);
> +
> if (info->data->needs_src_clk)
> - clk_disable_unprepare(info->rtc_src_clk);
> - clk_disable_unprepare(info->rtc_clk);
> + clk_unprepare(info->rtc_src_clk);
> + clk_unprepare(info->rtc_clk);
>
> return ret;
> }
>
On 11.08.2015 20:28, Joonyoung Shim wrote:
> The clock enable/disable codes for alarm have removed from
What do you mean in this paragraph? The clock code was removing something?
> 'commit 24e1455493da ("drivers/rtc/rtc-s3c.c: delete duplicate clock
Remove the 'apostrophe.
> control")' and the clocks keep disabling even if alarm is set, so alarm
> interrupt can't happen.
...and the clocks are disabled even...
>
> The s3c_rtc_setaie function can be called several times with that
> enabled argument has same value,
...several times with 'enabled' argument having same value
> so it needs to check whether clocks is
> enabled or not.
s/is/are/
>
> Signed-off-by: Joonyoung Shim <[email protected]>
Please add Cc-stable and fixes tag. To backport the patch probably
you'll have to remove the dependency on previous patches.
> ---
> drivers/rtc/rtc-s3c.c | 24 ++++++++++++++++++------
> 1 file changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
> index abe2a6d..fce078c 100644
> --- a/drivers/rtc/rtc-s3c.c
> +++ b/drivers/rtc/rtc-s3c.c
> @@ -39,6 +39,7 @@ struct s3c_rtc {
> void __iomem *base;
> struct clk *rtc_clk;
> struct clk *rtc_src_clk;
> + bool clk_enabled;
>
> struct s3c_rtc_data *data;
>
> @@ -71,9 +72,12 @@ static void s3c_rtc_enable_clk(struct s3c_rtc *info)
> unsigned long irq_flags;
>
> spin_lock_irqsave(&info->alarm_clk_lock, irq_flags);
> - clk_enable(info->rtc_clk);
> - if (info->data->needs_src_clk)
> - clk_enable(info->rtc_src_clk);
> + if (!info->clk_enabled) {
> + clk_enable(info->rtc_clk);
> + if (info->data->needs_src_clk)
> + clk_enable(info->rtc_src_clk);
> + info->clk_enabled = true;
> + }
> spin_unlock_irqrestore(&info->alarm_clk_lock, irq_flags);
> }
>
> @@ -82,9 +86,12 @@ static void s3c_rtc_disable_clk(struct s3c_rtc *info)
> unsigned long irq_flags;
>
> spin_lock_irqsave(&info->alarm_clk_lock, irq_flags);
> - if (info->data->needs_src_clk)
> - clk_disable(info->rtc_src_clk);
> - clk_disable(info->rtc_clk);
> + if (info->clk_enabled) {
> + if (info->data->needs_src_clk)
> + clk_disable(info->rtc_src_clk);
> + clk_disable(info->rtc_clk);
> + info->clk_enabled = false;
> + }
> spin_unlock_irqrestore(&info->alarm_clk_lock, irq_flags);
> }
>
> @@ -128,6 +135,11 @@ static int s3c_rtc_setaie(struct device *dev, unsigned int enabled)
>
> s3c_rtc_disable_clk(info);
>
> + if (enabled)
> + s3c_rtc_enable_clk(info);
> + else
> + s3c_rtc_disable_clk(info);
> +
> return 0;
> }
During probe the clk_enabled is false, so the clock won't be disabled at
the end of probe with s3c_rtc_disable_clk(). Maybe previous patch
interferes here so it would work after applying all 4 patches but not
when backporting. The patch in current form looks non-backportable.
Best regards,
KRzysztof
On 08/12/2015 09:28 AM, Krzysztof Kozlowski wrote:
> On 11.08.2015 20:28, Joonyoung Shim wrote:
>> The clock enable/disable codes for alarm have removed from
>
> What do you mean in this paragraph? The clock code was removing something?
>
>> 'commit 24e1455493da ("drivers/rtc/rtc-s3c.c: delete duplicate clock
>
> Remove the 'apostrophe.
>
>> control")' and the clocks keep disabling even if alarm is set, so alarm
>> interrupt can't happen.
> ...and the clocks are disabled even...
>
>
>>
>> The s3c_rtc_setaie function can be called several times with that
>> enabled argument has same value,
> ...several times with 'enabled' argument having same value
>
>> so it needs to check whether clocks is
>> enabled or not.
> s/is/are/
>
>>
>> Signed-off-by: Joonyoung Shim <[email protected]>
>
> Please add Cc-stable and fixes tag. To backport the patch probably
> you'll have to remove the dependency on previous patches.
Thanks for the point, i didn't think it.
On 08/12/2015 09:10 AM, Krzysztof Kozlowski wrote:
> On 11.08.2015 20:28, Joonyoung Shim wrote:
>> The driver uses clk_prepare_enable()/clk_disable_unprepare() only in
>> probe only, elsewhere, use the unified functions for enable/disable of
>> clk, e.g. s3c_rtc_enable_clk() / s3c_rtc_disable_clk(), so it's better
>> to use them for consistency of code.
>>
>> Signed-off-by: Joonyoung Shim <[email protected]>
>> ---
>> drivers/rtc/rtc-s3c.c | 14 +++++++++-----
>> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> First of all - the code is larger (9 insertions, 5 deletion) so I have
> doubts if this is better.
>
> Second - this is not equivalent change. The s3c_rtc_enable_clk/disable
> calls grab spin lock which is not necessary in probe.
>
I made this patch because of patch 4/4, but patch 4/4 should be removed
dependency from previous patches, so i will drop this patch.
Thanks.
On 11/08/2015 at 20:28:19 +0900, Joonyoung Shim wrote :
> It's missed to call clk_unprepare() about info->rtc_src_clk in
> s3c_rtc_remove and to call clk_disable_unprepare about info->rtc_clk in
> error routine of s3c_rtc_probe.
>
> Signed-off-by: Joonyoung Shim <[email protected]>
> ---
> drivers/rtc/rtc-s3c.c | 3 +++
> 1 file changed, 3 insertions(+)
>
Applied, thanks.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
On 11/08/2015 at 20:28:20 +0900, Joonyoung Shim wrote :
> It's unnecessary the code that assigns info->rtc_clk to NULL in
> s3c_rtc_remove.
>
> Signed-off-by: Joonyoung Shim <[email protected]>
> ---
> drivers/rtc/rtc-s3c.c | 1 -
> 1 file changed, 1 deletion(-)
>
Applied, thanks.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com