diff mbox

[3/4] rtc: s3c: use unified functions for enable/disable of clk

Message ID 1439292502-22912-3-git-send-email-jy0922.shim@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Joonyoung Shim Aug. 11, 2015, 11:28 a.m. UTC
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 <jy0922.shim@samsung.com>
---
 drivers/rtc/rtc-s3c.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

Comments

Krzysztof Kozlowski Aug. 12, 2015, 12:10 a.m. UTC | #1
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 <jy0922.shim@samsung.com>
> ---
>  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;
>  }
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Joonyoung Shim Aug. 12, 2015, 10:26 a.m. UTC | #2
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 <jy0922.shim@samsung.com>
>> ---
>>  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.

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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;
 }