diff mbox series

iommu/exynos: Use the devm_clk_get_optional() helper

Message ID 99c0d5ce643737ee0952df41fd60433a0bbeb447.1679834256.git.christophe.jaillet@wanadoo.fr
State New
Headers show
Series iommu/exynos: Use the devm_clk_get_optional() helper | expand

Commit Message

Christophe JAILLET March 26, 2023, 12:37 p.m. UTC
Use devm_clk_get_optional() instead of hand writing it.
This saves some loC and improves the semantic.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/iommu/exynos-iommu.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

Comments

Marek Szyprowski April 3, 2023, 7:03 a.m. UTC | #1
On 26.03.2023 14:37, Christophe JAILLET wrote:
> Use devm_clk_get_optional() instead of hand writing it.
> This saves some loC and improves the semantic.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
>   drivers/iommu/exynos-iommu.c | 24 ++++++++----------------
>   1 file changed, 8 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
> index 483aaaeb6dae..867f409e0325 100644
> --- a/drivers/iommu/exynos-iommu.c
> +++ b/drivers/iommu/exynos-iommu.c
> @@ -747,22 +747,16 @@ static int exynos_sysmmu_probe(struct platform_device *pdev)
>   		return ret;
>   	}
>   
> -	data->clk = devm_clk_get(dev, "sysmmu");
> -	if (PTR_ERR(data->clk) == -ENOENT)
> -		data->clk = NULL;
> -	else if (IS_ERR(data->clk))
> +	data->clk = devm_clk_get_optional(dev, "sysmmu");
> +	if (IS_ERR(data->clk))
>   		return PTR_ERR(data->clk);
>   
> -	data->aclk = devm_clk_get(dev, "aclk");
> -	if (PTR_ERR(data->aclk) == -ENOENT)
> -		data->aclk = NULL;
> -	else if (IS_ERR(data->aclk))
> +	data->aclk = devm_clk_get_optional(dev, "aclk");
> +	if (IS_ERR(data->aclk))
>   		return PTR_ERR(data->aclk);
>   
> -	data->pclk = devm_clk_get(dev, "pclk");
> -	if (PTR_ERR(data->pclk) == -ENOENT)
> -		data->pclk = NULL;
> -	else if (IS_ERR(data->pclk))
> +	data->pclk = devm_clk_get_optional(dev, "pclk");
> +	if (IS_ERR(data->pclk))
>   		return PTR_ERR(data->pclk);
>   
>   	if (!data->clk && (!data->aclk || !data->pclk)) {
> @@ -770,10 +764,8 @@ static int exynos_sysmmu_probe(struct platform_device *pdev)
>   		return -ENOSYS;
>   	}
>   
> -	data->clk_master = devm_clk_get(dev, "master");
> -	if (PTR_ERR(data->clk_master) == -ENOENT)
> -		data->clk_master = NULL;
> -	else if (IS_ERR(data->clk_master))
> +	data->clk_master = devm_clk_get_optional(dev, "master");
> +	if (IS_ERR(data->clk_master))
>   		return PTR_ERR(data->clk_master);
>   
>   	data->sysmmu = dev;

Best regards
Joerg Roedel April 13, 2023, 9:50 a.m. UTC | #2
On Sun, Mar 26, 2023 at 02:37:50PM +0200, Christophe JAILLET wrote:
> Use devm_clk_get_optional() instead of hand writing it.
> This saves some loC and improves the semantic.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/iommu/exynos-iommu.c | 24 ++++++++----------------
>  1 file changed, 8 insertions(+), 16 deletions(-)

Applied, thanks.
diff mbox series

Patch

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index 483aaaeb6dae..867f409e0325 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -747,22 +747,16 @@  static int exynos_sysmmu_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	data->clk = devm_clk_get(dev, "sysmmu");
-	if (PTR_ERR(data->clk) == -ENOENT)
-		data->clk = NULL;
-	else if (IS_ERR(data->clk))
+	data->clk = devm_clk_get_optional(dev, "sysmmu");
+	if (IS_ERR(data->clk))
 		return PTR_ERR(data->clk);
 
-	data->aclk = devm_clk_get(dev, "aclk");
-	if (PTR_ERR(data->aclk) == -ENOENT)
-		data->aclk = NULL;
-	else if (IS_ERR(data->aclk))
+	data->aclk = devm_clk_get_optional(dev, "aclk");
+	if (IS_ERR(data->aclk))
 		return PTR_ERR(data->aclk);
 
-	data->pclk = devm_clk_get(dev, "pclk");
-	if (PTR_ERR(data->pclk) == -ENOENT)
-		data->pclk = NULL;
-	else if (IS_ERR(data->pclk))
+	data->pclk = devm_clk_get_optional(dev, "pclk");
+	if (IS_ERR(data->pclk))
 		return PTR_ERR(data->pclk);
 
 	if (!data->clk && (!data->aclk || !data->pclk)) {
@@ -770,10 +764,8 @@  static int exynos_sysmmu_probe(struct platform_device *pdev)
 		return -ENOSYS;
 	}
 
-	data->clk_master = devm_clk_get(dev, "master");
-	if (PTR_ERR(data->clk_master) == -ENOENT)
-		data->clk_master = NULL;
-	else if (IS_ERR(data->clk_master))
+	data->clk_master = devm_clk_get_optional(dev, "master");
+	if (IS_ERR(data->clk_master))
 		return PTR_ERR(data->clk_master);
 
 	data->sysmmu = dev;