drm/msm: Use generic bulk clock function

Submitted by Jordan Crouse on July 25, 2019, 4:53 p.m.

Details

Message ID 1564073635-27998-1-git-send-email-jcrouse@codeaurora.org
State New
Headers show
Series "drm/msm: Use generic bulk clock function" ( rev: 1 ) in Freedreno

Not browsing as part of any series.

Commit Message

Jordan Crouse July 25, 2019, 4:53 p.m.
Remove the homebrewed bulk clock get function and replace it with
devm_clk_bulk_get_all().

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---

 drivers/gpu/drm/msm/adreno/a6xx_gmu.c |  2 +-
 drivers/gpu/drm/msm/msm_drv.c         | 40 -----------------------------------
 drivers/gpu/drm/msm/msm_drv.h         |  1 -
 drivers/gpu/drm/msm/msm_gpu.c         |  2 +-
 4 files changed, 2 insertions(+), 43 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index 2ca470e..85f14fe 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -1172,7 +1172,7 @@  static int a6xx_gmu_pwrlevels_probe(struct a6xx_gmu *gmu)
 
 static int a6xx_gmu_clocks_probe(struct a6xx_gmu *gmu)
 {
-	int ret = msm_clk_bulk_get(gmu->dev, &gmu->clocks);
+	int ret = devm_clk_bulk_get_all(gmu->dev, &gmu->clocks);
 
 	if (ret < 1)
 		return ret;
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 0e0fca1..96fe24c 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -75,46 +75,6 @@  module_param(modeset, bool, 0600);
  * Util/helpers:
  */
 
-int msm_clk_bulk_get(struct device *dev, struct clk_bulk_data **bulk)
-{
-	struct property *prop;
-	const char *name;
-	struct clk_bulk_data *local;
-	int i = 0, ret, count;
-
-	count = of_property_count_strings(dev->of_node, "clock-names");
-	if (count < 1)
-		return 0;
-
-	local = devm_kcalloc(dev, sizeof(struct clk_bulk_data *),
-		count, GFP_KERNEL);
-	if (!local)
-		return -ENOMEM;
-
-	of_property_for_each_string(dev->of_node, "clock-names", prop, name) {
-		local[i].id = devm_kstrdup(dev, name, GFP_KERNEL);
-		if (!local[i].id) {
-			devm_kfree(dev, local);
-			return -ENOMEM;
-		}
-
-		i++;
-	}
-
-	ret = devm_clk_bulk_get(dev, count, local);
-
-	if (ret) {
-		for (i = 0; i < count; i++)
-			devm_kfree(dev, (void *) local[i].id);
-		devm_kfree(dev, local);
-
-		return ret;
-	}
-
-	*bulk = local;
-	return count;
-}
-
 struct clk *msm_clk_bulk_get_clock(struct clk_bulk_data *bulk, int count,
 		const char *name)
 {
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index ee7b512..843c68f 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -399,7 +399,6 @@  static inline void msm_perf_debugfs_cleanup(struct msm_drm_private *priv) {}
 #endif
 
 struct clk *msm_clk_get(struct platform_device *pdev, const char *name);
-int msm_clk_bulk_get(struct device *dev, struct clk_bulk_data **bulk);
 
 struct clk *msm_clk_bulk_get_clock(struct clk_bulk_data *bulk, int count,
 	const char *name);
diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index 4edb874..445a9f8 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -783,7 +783,7 @@  static irqreturn_t irq_handler(int irq, void *data)
 
 static int get_clocks(struct platform_device *pdev, struct msm_gpu *gpu)
 {
-	int ret = msm_clk_bulk_get(&pdev->dev, &gpu->grp_clks);
+	int ret = devm_clk_bulk_get_all(&pdev->dev, &gpu->grp_clks);
 
 	if (ret < 1) {
 		gpu->nr_clocks = 0;

Comments

Quoting Jordan Crouse (2019-07-25 09:53:55)
> Remove the homebrewed bulk clock get function and replace it with
> devm_clk_bulk_get_all().
> 
> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>
On Thu, Jul 25, 2019 at 9:54 AM Jordan Crouse <jcrouse@codeaurora.org> wrote:
>
> Remove the homebrewed bulk clock get function and replace it with
> devm_clk_bulk_get_all().
>
> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

nice cleanup

Reviewed-by: Rob Clark <robdclark@gmail.com>

> ---
>
>  drivers/gpu/drm/msm/adreno/a6xx_gmu.c |  2 +-
>  drivers/gpu/drm/msm/msm_drv.c         | 40 -----------------------------------
>  drivers/gpu/drm/msm/msm_drv.h         |  1 -
>  drivers/gpu/drm/msm/msm_gpu.c         |  2 +-
>  4 files changed, 2 insertions(+), 43 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> index 2ca470e..85f14fe 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> @@ -1172,7 +1172,7 @@ static int a6xx_gmu_pwrlevels_probe(struct a6xx_gmu *gmu)
>
>  static int a6xx_gmu_clocks_probe(struct a6xx_gmu *gmu)
>  {
> -       int ret = msm_clk_bulk_get(gmu->dev, &gmu->clocks);
> +       int ret = devm_clk_bulk_get_all(gmu->dev, &gmu->clocks);
>
>         if (ret < 1)
>                 return ret;
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index 0e0fca1..96fe24c 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -75,46 +75,6 @@ module_param(modeset, bool, 0600);
>   * Util/helpers:
>   */
>
> -int msm_clk_bulk_get(struct device *dev, struct clk_bulk_data **bulk)
> -{
> -       struct property *prop;
> -       const char *name;
> -       struct clk_bulk_data *local;
> -       int i = 0, ret, count;
> -
> -       count = of_property_count_strings(dev->of_node, "clock-names");
> -       if (count < 1)
> -               return 0;
> -
> -       local = devm_kcalloc(dev, sizeof(struct clk_bulk_data *),
> -               count, GFP_KERNEL);
> -       if (!local)
> -               return -ENOMEM;
> -
> -       of_property_for_each_string(dev->of_node, "clock-names", prop, name) {
> -               local[i].id = devm_kstrdup(dev, name, GFP_KERNEL);
> -               if (!local[i].id) {
> -                       devm_kfree(dev, local);
> -                       return -ENOMEM;
> -               }
> -
> -               i++;
> -       }
> -
> -       ret = devm_clk_bulk_get(dev, count, local);
> -
> -       if (ret) {
> -               for (i = 0; i < count; i++)
> -                       devm_kfree(dev, (void *) local[i].id);
> -               devm_kfree(dev, local);
> -
> -               return ret;
> -       }
> -
> -       *bulk = local;
> -       return count;
> -}
> -
>  struct clk *msm_clk_bulk_get_clock(struct clk_bulk_data *bulk, int count,
>                 const char *name)
>  {
> diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
> index ee7b512..843c68f 100644
> --- a/drivers/gpu/drm/msm/msm_drv.h
> +++ b/drivers/gpu/drm/msm/msm_drv.h
> @@ -399,7 +399,6 @@ static inline void msm_perf_debugfs_cleanup(struct msm_drm_private *priv) {}
>  #endif
>
>  struct clk *msm_clk_get(struct platform_device *pdev, const char *name);
> -int msm_clk_bulk_get(struct device *dev, struct clk_bulk_data **bulk);
>
>  struct clk *msm_clk_bulk_get_clock(struct clk_bulk_data *bulk, int count,
>         const char *name);
> diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
> index 4edb874..445a9f8 100644
> --- a/drivers/gpu/drm/msm/msm_gpu.c
> +++ b/drivers/gpu/drm/msm/msm_gpu.c
> @@ -783,7 +783,7 @@ static irqreturn_t irq_handler(int irq, void *data)
>
>  static int get_clocks(struct platform_device *pdev, struct msm_gpu *gpu)
>  {
> -       int ret = msm_clk_bulk_get(&pdev->dev, &gpu->grp_clks);
> +       int ret = devm_clk_bulk_get_all(&pdev->dev, &gpu->grp_clks);
>
>         if (ret < 1) {
>                 gpu->nr_clocks = 0;
> --
> 2.7.4
>