dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH Resend] drm/exynos: Use devm_clk_get in exynos_mixer.c
@ 2012-11-23  8:43 Sachin Kamat
  2012-11-23  8:43 ` [PATCH Resend] drm/exynos: Use devm_* APIs in exynos_hdmi.c Sachin Kamat
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Sachin Kamat @ 2012-11-23  8:43 UTC (permalink / raw)
  To: dri-devel; +Cc: sachin.kamat, patches

devm_clk_get is device managed and makes error handling and exit code
simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/gpu/drm/exynos/exynos_mixer.c |   59 +++++++++------------------------
 1 files changed, 16 insertions(+), 43 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index 0d3ed28..5712b0e 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -962,57 +962,45 @@ static int __devinit mixer_resources_init(struct exynos_drm_hdmi_context *ctx,
 
 	spin_lock_init(&mixer_res->reg_slock);
 
-	mixer_res->mixer = clk_get(dev, "mixer");
+	mixer_res->mixer = devm_clk_get(dev, "mixer");
 	if (IS_ERR_OR_NULL(mixer_res->mixer)) {
 		dev_err(dev, "failed to get clock 'mixer'\n");
-		ret = -ENODEV;
-		goto fail;
+		return -ENODEV;
 	}
 
-	mixer_res->sclk_hdmi = clk_get(dev, "sclk_hdmi");
+	mixer_res->sclk_hdmi = devm_clk_get(dev, "sclk_hdmi");
 	if (IS_ERR_OR_NULL(mixer_res->sclk_hdmi)) {
 		dev_err(dev, "failed to get clock 'sclk_hdmi'\n");
-		ret = -ENODEV;
-		goto fail;
+		return -ENODEV;
 	}
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (res == NULL) {
 		dev_err(dev, "get memory resource failed.\n");
-		ret = -ENXIO;
-		goto fail;
+		return -ENXIO;
 	}
 
 	mixer_res->mixer_regs = devm_ioremap(&pdev->dev, res->start,
 							resource_size(res));
 	if (mixer_res->mixer_regs == NULL) {
 		dev_err(dev, "register mapping failed.\n");
-		ret = -ENXIO;
-		goto fail;
+		return -ENXIO;
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (res == NULL) {
 		dev_err(dev, "get interrupt resource failed.\n");
-		ret = -ENXIO;
-		goto fail;
+		return -ENXIO;
 	}
 
 	ret = devm_request_irq(&pdev->dev, res->start, mixer_irq_handler,
 							0, "drm_mixer", ctx);
 	if (ret) {
 		dev_err(dev, "request interrupt failed.\n");
-		goto fail;
+		return ret;
 	}
 	mixer_res->irq = res->start;
 
 	return 0;
-
-fail:
-	if (!IS_ERR_OR_NULL(mixer_res->sclk_hdmi))
-		clk_put(mixer_res->sclk_hdmi);
-	if (!IS_ERR_OR_NULL(mixer_res->mixer))
-		clk_put(mixer_res->mixer);
-	return ret;
 }
 
 static int __devinit vp_resources_init(struct exynos_drm_hdmi_context *ctx,
@@ -1022,25 +1010,21 @@ static int __devinit vp_resources_init(struct exynos_drm_hdmi_context *ctx,
 	struct device *dev = &pdev->dev;
 	struct mixer_resources *mixer_res = &mixer_ctx->mixer_res;
 	struct resource *res;
-	int ret;
 
-	mixer_res->vp = clk_get(dev, "vp");
+	mixer_res->vp = devm_clk_get(dev, "vp");
 	if (IS_ERR_OR_NULL(mixer_res->vp)) {
 		dev_err(dev, "failed to get clock 'vp'\n");
-		ret = -ENODEV;
-		goto fail;
+		return -ENODEV;
 	}
-	mixer_res->sclk_mixer = clk_get(dev, "sclk_mixer");
+	mixer_res->sclk_mixer = devm_clk_get(dev, "sclk_mixer");
 	if (IS_ERR_OR_NULL(mixer_res->sclk_mixer)) {
 		dev_err(dev, "failed to get clock 'sclk_mixer'\n");
-		ret = -ENODEV;
-		goto fail;
+		return -ENODEV;
 	}
-	mixer_res->sclk_dac = clk_get(dev, "sclk_dac");
+	mixer_res->sclk_dac = devm_clk_get(dev, "sclk_dac");
 	if (IS_ERR_OR_NULL(mixer_res->sclk_dac)) {
 		dev_err(dev, "failed to get clock 'sclk_dac'\n");
-		ret = -ENODEV;
-		goto fail;
+		return -ENODEV;
 	}
 
 	if (mixer_res->sclk_hdmi)
@@ -1049,28 +1033,17 @@ static int __devinit vp_resources_init(struct exynos_drm_hdmi_context *ctx,
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
 	if (res == NULL) {
 		dev_err(dev, "get memory resource failed.\n");
-		ret = -ENXIO;
-		goto fail;
+		return -ENXIO;
 	}
 
 	mixer_res->vp_regs = devm_ioremap(&pdev->dev, res->start,
 							resource_size(res));
 	if (mixer_res->vp_regs == NULL) {
 		dev_err(dev, "register mapping failed.\n");
-		ret = -ENXIO;
-		goto fail;
+		return -ENXIO;
 	}
 
 	return 0;
-
-fail:
-	if (!IS_ERR_OR_NULL(mixer_res->sclk_dac))
-		clk_put(mixer_res->sclk_dac);
-	if (!IS_ERR_OR_NULL(mixer_res->sclk_mixer))
-		clk_put(mixer_res->sclk_mixer);
-	if (!IS_ERR_OR_NULL(mixer_res->vp))
-		clk_put(mixer_res->vp);
-	return ret;
 }
 
 static struct mixer_drv_data exynos5_mxr_drv_data = {
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH Resend] drm/exynos: Use devm_* APIs in exynos_hdmi.c
  2012-11-23  8:43 [PATCH Resend] drm/exynos: Use devm_clk_get in exynos_mixer.c Sachin Kamat
@ 2012-11-23  8:43 ` Sachin Kamat
  2012-11-23  9:40   ` Inki Dae
  2012-11-23  8:43 ` [PATCH Resend] drm/exynos: Use devm_clk_get in exynos_drm_fimd.c Sachin Kamat
  2012-11-23  9:40 ` [PATCH Resend] drm/exynos: Use devm_clk_get in exynos_mixer.c Inki Dae
  2 siblings, 1 reply; 7+ messages in thread
From: Sachin Kamat @ 2012-11-23  8:43 UTC (permalink / raw)
  To: dri-devel; +Cc: sachin.kamat, patches

devm_* functions are device managed and make error handling and exit code
simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/gpu/drm/exynos/exynos_hdmi.c |   60 +++++++--------------------------
 1 files changed, 13 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 59839cc..af5c8ac 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -2197,27 +2197,27 @@ static int __devinit hdmi_resources_init(struct hdmi_context *hdata)
 	memset(res, 0, sizeof(*res));
 
 	/* get clocks, power */
-	res->hdmi = clk_get(dev, "hdmi");
+	res->hdmi = devm_clk_get(dev, "hdmi");
 	if (IS_ERR_OR_NULL(res->hdmi)) {
 		DRM_ERROR("failed to get clock 'hdmi'\n");
 		goto fail;
 	}
-	res->sclk_hdmi = clk_get(dev, "sclk_hdmi");
+	res->sclk_hdmi = devm_clk_get(dev, "sclk_hdmi");
 	if (IS_ERR_OR_NULL(res->sclk_hdmi)) {
 		DRM_ERROR("failed to get clock 'sclk_hdmi'\n");
 		goto fail;
 	}
-	res->sclk_pixel = clk_get(dev, "sclk_pixel");
+	res->sclk_pixel = devm_clk_get(dev, "sclk_pixel");
 	if (IS_ERR_OR_NULL(res->sclk_pixel)) {
 		DRM_ERROR("failed to get clock 'sclk_pixel'\n");
 		goto fail;
 	}
-	res->sclk_hdmiphy = clk_get(dev, "sclk_hdmiphy");
+	res->sclk_hdmiphy = devm_clk_get(dev, "sclk_hdmiphy");
 	if (IS_ERR_OR_NULL(res->sclk_hdmiphy)) {
 		DRM_ERROR("failed to get clock 'sclk_hdmiphy'\n");
 		goto fail;
 	}
-	res->hdmiphy = clk_get(dev, "hdmiphy");
+	res->hdmiphy = devm_clk_get(dev, "hdmiphy");
 	if (IS_ERR_OR_NULL(res->hdmiphy)) {
 		DRM_ERROR("failed to get clock 'hdmiphy'\n");
 		goto fail;
@@ -2225,7 +2225,7 @@ static int __devinit hdmi_resources_init(struct hdmi_context *hdata)
 
 	clk_set_parent(res->sclk_hdmi, res->sclk_pixel);
 
-	res->regul_bulk = kzalloc(ARRAY_SIZE(supply) *
+	res->regul_bulk = devm_kzalloc(dev, ARRAY_SIZE(supply) *
 		sizeof(res->regul_bulk[0]), GFP_KERNEL);
 	if (!res->regul_bulk) {
 		DRM_ERROR("failed to get memory for regulators\n");
@@ -2235,7 +2235,7 @@ static int __devinit hdmi_resources_init(struct hdmi_context *hdata)
 		res->regul_bulk[i].supply = supply[i];
 		res->regul_bulk[i].consumer = NULL;
 	}
-	ret = regulator_bulk_get(dev, ARRAY_SIZE(supply), res->regul_bulk);
+	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(supply), res->regul_bulk);
 	if (ret) {
 		DRM_ERROR("failed to get regulators\n");
 		goto fail;
@@ -2248,28 +2248,6 @@ fail:
 	return -ENODEV;
 }
 
-static int hdmi_resources_cleanup(struct hdmi_context *hdata)
-{
-	struct hdmi_resources *res = &hdata->res;
-
-	regulator_bulk_free(res->regul_count, res->regul_bulk);
-	/* kfree is NULL-safe */
-	kfree(res->regul_bulk);
-	if (!IS_ERR_OR_NULL(res->hdmiphy))
-		clk_put(res->hdmiphy);
-	if (!IS_ERR_OR_NULL(res->sclk_hdmiphy))
-		clk_put(res->sclk_hdmiphy);
-	if (!IS_ERR_OR_NULL(res->sclk_pixel))
-		clk_put(res->sclk_pixel);
-	if (!IS_ERR_OR_NULL(res->sclk_hdmi))
-		clk_put(res->sclk_hdmi);
-	if (!IS_ERR_OR_NULL(res->hdmi))
-		clk_put(res->hdmi);
-	memset(res, 0, sizeof(*res));
-
-	return 0;
-}
-
 static struct i2c_client *hdmi_ddc, *hdmi_hdmiphy;
 
 void hdmi_attach_ddc_client(struct i2c_client *ddc)
@@ -2409,36 +2387,32 @@ static int __devinit hdmi_probe(struct platform_device *pdev)
 	ret = hdmi_resources_init(hdata);
 
 	if (ret) {
-		ret = -EINVAL;
 		DRM_ERROR("hdmi_resources_init failed\n");
-		goto err_data;
+		return -EINVAL;
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
 		DRM_ERROR("failed to find registers\n");
-		ret = -ENOENT;
-		goto err_resource;
+		return -ENOENT;
 	}
 
 	hdata->regs = devm_request_and_ioremap(&pdev->dev, res);
 	if (!hdata->regs) {
 		DRM_ERROR("failed to map registers\n");
-		ret = -ENXIO;
-		goto err_resource;
+		return -ENXIO;
 	}
 
-	ret = gpio_request(hdata->hpd_gpio, "HPD");
+	ret = devm_gpio_request(&pdev->dev, hdata->hpd_gpio, "HPD");
 	if (ret) {
 		DRM_ERROR("failed to request HPD gpio\n");
-		goto err_resource;
+		return ret;
 	}
 
 	/* DDC i2c driver */
 	if (i2c_add_driver(&ddc_driver)) {
 		DRM_ERROR("failed to register ddc i2c driver\n");
-		ret = -ENOENT;
-		goto err_gpio;
+		return -ENOENT;
 	}
 
 	hdata->ddc_port = hdmi_ddc;
@@ -2501,11 +2475,6 @@ err_hdmiphy:
 	i2c_del_driver(&hdmiphy_driver);
 err_ddc:
 	i2c_del_driver(&ddc_driver);
-err_gpio:
-	gpio_free(hdata->hpd_gpio);
-err_resource:
-	hdmi_resources_cleanup(hdata);
-err_data:
 	return ret;
 }
 
@@ -2522,9 +2491,6 @@ static int __devexit hdmi_remove(struct platform_device *pdev)
 	free_irq(hdata->internal_irq, hdata);
 	free_irq(hdata->external_irq, hdata);
 
-	gpio_free(hdata->hpd_gpio);
-
-	hdmi_resources_cleanup(hdata);
 
 	/* hdmiphy i2c driver */
 	i2c_del_driver(&hdmiphy_driver);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH Resend] drm/exynos: Use devm_clk_get in exynos_drm_fimd.c
  2012-11-23  8:43 [PATCH Resend] drm/exynos: Use devm_clk_get in exynos_mixer.c Sachin Kamat
  2012-11-23  8:43 ` [PATCH Resend] drm/exynos: Use devm_* APIs in exynos_hdmi.c Sachin Kamat
@ 2012-11-23  8:43 ` Sachin Kamat
  2012-11-23  9:51   ` Inki Dae
  2012-11-23  9:40 ` [PATCH Resend] drm/exynos: Use devm_clk_get in exynos_mixer.c Inki Dae
  2 siblings, 1 reply; 7+ messages in thread
From: Sachin Kamat @ 2012-11-23  8:43 UTC (permalink / raw)
  To: dri-devel; +Cc: sachin.kamat, patches

devm_clk_get is device managed and makes error handling and exit code
simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/gpu/drm/exynos/exynos_drm_fimd.c |   31 ++++++-----------------------
 1 files changed, 7 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index ad04edd..00bd266 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -846,18 +846,16 @@ static int __devinit fimd_probe(struct platform_device *pdev)
 	if (!ctx)
 		return -ENOMEM;
 
-	ctx->bus_clk = clk_get(dev, "fimd");
+	ctx->bus_clk = devm_clk_get(dev, "fimd");
 	if (IS_ERR(ctx->bus_clk)) {
 		dev_err(dev, "failed to get bus clock\n");
-		ret = PTR_ERR(ctx->bus_clk);
-		goto err_clk_get;
+		return PTR_ERR(ctx->bus_clk);
 	}
 
-	ctx->lcd_clk = clk_get(dev, "sclk_fimd");
+	ctx->lcd_clk = devm_clk_get(dev, "sclk_fimd");
 	if (IS_ERR(ctx->lcd_clk)) {
 		dev_err(dev, "failed to get lcd clock\n");
-		ret = PTR_ERR(ctx->lcd_clk);
-		goto err_bus_clk;
+		return PTR_ERR(ctx->lcd_clk);
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -865,14 +863,13 @@ static int __devinit fimd_probe(struct platform_device *pdev)
 	ctx->regs = devm_request_and_ioremap(&pdev->dev, res);
 	if (!ctx->regs) {
 		dev_err(dev, "failed to map registers\n");
-		ret = -ENXIO;
-		goto err_clk;
+		return -ENXIO;
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (!res) {
 		dev_err(dev, "irq request failed.\n");
-		goto err_clk;
+		return -ENXIO;
 	}
 
 	ctx->irq = res->start;
@@ -881,7 +878,7 @@ static int __devinit fimd_probe(struct platform_device *pdev)
 							0, "drm_fimd", ctx);
 	if (ret) {
 		dev_err(dev, "irq request failed.\n");
-		goto err_clk;
+		return ret;
 	}
 
 	ctx->vidcon0 = pdata->vidcon0;
@@ -915,17 +912,6 @@ static int __devinit fimd_probe(struct platform_device *pdev)
 	exynos_drm_subdrv_register(subdrv);
 
 	return 0;
-
-err_clk:
-	clk_disable(ctx->lcd_clk);
-	clk_put(ctx->lcd_clk);
-
-err_bus_clk:
-	clk_disable(ctx->bus_clk);
-	clk_put(ctx->bus_clk);
-
-err_clk_get:
-	return ret;
 }
 
 static int __devexit fimd_remove(struct platform_device *pdev)
@@ -949,9 +935,6 @@ static int __devexit fimd_remove(struct platform_device *pdev)
 out:
 	pm_runtime_disable(dev);
 
-	clk_put(ctx->lcd_clk);
-	clk_put(ctx->bus_clk);
-
 	return 0;
 }
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* RE: [PATCH Resend] drm/exynos: Use devm_clk_get in exynos_mixer.c
  2012-11-23  8:43 [PATCH Resend] drm/exynos: Use devm_clk_get in exynos_mixer.c Sachin Kamat
  2012-11-23  8:43 ` [PATCH Resend] drm/exynos: Use devm_* APIs in exynos_hdmi.c Sachin Kamat
  2012-11-23  8:43 ` [PATCH Resend] drm/exynos: Use devm_clk_get in exynos_drm_fimd.c Sachin Kamat
@ 2012-11-23  9:40 ` Inki Dae
  2 siblings, 0 replies; 7+ messages in thread
From: Inki Dae @ 2012-11-23  9:40 UTC (permalink / raw)
  To: 'Sachin Kamat', dri-devel; +Cc: patches

Applied.

Thanks,
Inki Dae

> -----Original Message-----
> From: Sachin Kamat [mailto:sachin.kamat@linaro.org]
> Sent: Friday, November 23, 2012 5:43 PM
> To: dri-devel@lists.freedesktop.org
> Cc: inki.dae@samsung.com; sachin.kamat@linaro.org; patches@linaro.org
> Subject: [PATCH Resend] drm/exynos: Use devm_clk_get in exynos_mixer.c
> 
> devm_clk_get is device managed and makes error handling and exit code
> simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> ---
>  drivers/gpu/drm/exynos/exynos_mixer.c |   59
+++++++++--------------------
> ----
>  1 files changed, 16 insertions(+), 43 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c
> b/drivers/gpu/drm/exynos/exynos_mixer.c
> index 0d3ed28..5712b0e 100644
> --- a/drivers/gpu/drm/exynos/exynos_mixer.c
> +++ b/drivers/gpu/drm/exynos/exynos_mixer.c
> @@ -962,57 +962,45 @@ static int __devinit mixer_resources_init(struct
> exynos_drm_hdmi_context *ctx,
> 
>  	spin_lock_init(&mixer_res->reg_slock);
> 
> -	mixer_res->mixer = clk_get(dev, "mixer");
> +	mixer_res->mixer = devm_clk_get(dev, "mixer");
>  	if (IS_ERR_OR_NULL(mixer_res->mixer)) {
>  		dev_err(dev, "failed to get clock 'mixer'\n");
> -		ret = -ENODEV;
> -		goto fail;
> +		return -ENODEV;
>  	}
> 
> -	mixer_res->sclk_hdmi = clk_get(dev, "sclk_hdmi");
> +	mixer_res->sclk_hdmi = devm_clk_get(dev, "sclk_hdmi");
>  	if (IS_ERR_OR_NULL(mixer_res->sclk_hdmi)) {
>  		dev_err(dev, "failed to get clock 'sclk_hdmi'\n");
> -		ret = -ENODEV;
> -		goto fail;
> +		return -ENODEV;
>  	}
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (res == NULL) {
>  		dev_err(dev, "get memory resource failed.\n");
> -		ret = -ENXIO;
> -		goto fail;
> +		return -ENXIO;
>  	}
> 
>  	mixer_res->mixer_regs = devm_ioremap(&pdev->dev, res->start,
>  							resource_size(res));
>  	if (mixer_res->mixer_regs == NULL) {
>  		dev_err(dev, "register mapping failed.\n");
> -		ret = -ENXIO;
> -		goto fail;
> +		return -ENXIO;
>  	}
> 
>  	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
>  	if (res == NULL) {
>  		dev_err(dev, "get interrupt resource failed.\n");
> -		ret = -ENXIO;
> -		goto fail;
> +		return -ENXIO;
>  	}
> 
>  	ret = devm_request_irq(&pdev->dev, res->start, mixer_irq_handler,
>  							0, "drm_mixer",
ctx);
>  	if (ret) {
>  		dev_err(dev, "request interrupt failed.\n");
> -		goto fail;
> +		return ret;
>  	}
>  	mixer_res->irq = res->start;
> 
>  	return 0;
> -
> -fail:
> -	if (!IS_ERR_OR_NULL(mixer_res->sclk_hdmi))
> -		clk_put(mixer_res->sclk_hdmi);
> -	if (!IS_ERR_OR_NULL(mixer_res->mixer))
> -		clk_put(mixer_res->mixer);
> -	return ret;
>  }
> 
>  static int __devinit vp_resources_init(struct exynos_drm_hdmi_context
> *ctx,
> @@ -1022,25 +1010,21 @@ static int __devinit vp_resources_init(struct
> exynos_drm_hdmi_context *ctx,
>  	struct device *dev = &pdev->dev;
>  	struct mixer_resources *mixer_res = &mixer_ctx->mixer_res;
>  	struct resource *res;
> -	int ret;
> 
> -	mixer_res->vp = clk_get(dev, "vp");
> +	mixer_res->vp = devm_clk_get(dev, "vp");
>  	if (IS_ERR_OR_NULL(mixer_res->vp)) {
>  		dev_err(dev, "failed to get clock 'vp'\n");
> -		ret = -ENODEV;
> -		goto fail;
> +		return -ENODEV;
>  	}
> -	mixer_res->sclk_mixer = clk_get(dev, "sclk_mixer");
> +	mixer_res->sclk_mixer = devm_clk_get(dev, "sclk_mixer");
>  	if (IS_ERR_OR_NULL(mixer_res->sclk_mixer)) {
>  		dev_err(dev, "failed to get clock 'sclk_mixer'\n");
> -		ret = -ENODEV;
> -		goto fail;
> +		return -ENODEV;
>  	}
> -	mixer_res->sclk_dac = clk_get(dev, "sclk_dac");
> +	mixer_res->sclk_dac = devm_clk_get(dev, "sclk_dac");
>  	if (IS_ERR_OR_NULL(mixer_res->sclk_dac)) {
>  		dev_err(dev, "failed to get clock 'sclk_dac'\n");
> -		ret = -ENODEV;
> -		goto fail;
> +		return -ENODEV;
>  	}
> 
>  	if (mixer_res->sclk_hdmi)
> @@ -1049,28 +1033,17 @@ static int __devinit vp_resources_init(struct
> exynos_drm_hdmi_context *ctx,
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
>  	if (res == NULL) {
>  		dev_err(dev, "get memory resource failed.\n");
> -		ret = -ENXIO;
> -		goto fail;
> +		return -ENXIO;
>  	}
> 
>  	mixer_res->vp_regs = devm_ioremap(&pdev->dev, res->start,
>  							resource_size(res));
>  	if (mixer_res->vp_regs == NULL) {
>  		dev_err(dev, "register mapping failed.\n");
> -		ret = -ENXIO;
> -		goto fail;
> +		return -ENXIO;
>  	}
> 
>  	return 0;
> -
> -fail:
> -	if (!IS_ERR_OR_NULL(mixer_res->sclk_dac))
> -		clk_put(mixer_res->sclk_dac);
> -	if (!IS_ERR_OR_NULL(mixer_res->sclk_mixer))
> -		clk_put(mixer_res->sclk_mixer);
> -	if (!IS_ERR_OR_NULL(mixer_res->vp))
> -		clk_put(mixer_res->vp);
> -	return ret;
>  }
> 
>  static struct mixer_drv_data exynos5_mxr_drv_data = {
> --
> 1.7.4.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH Resend] drm/exynos: Use devm_* APIs in exynos_hdmi.c
  2012-11-23  8:43 ` [PATCH Resend] drm/exynos: Use devm_* APIs in exynos_hdmi.c Sachin Kamat
@ 2012-11-23  9:40   ` Inki Dae
  0 siblings, 0 replies; 7+ messages in thread
From: Inki Dae @ 2012-11-23  9:40 UTC (permalink / raw)
  To: 'Sachin Kamat', dri-devel; +Cc: patches

Applied.

Thanks,
Inki Dae

> -----Original Message-----
> From: Sachin Kamat [mailto:sachin.kamat@linaro.org]
> Sent: Friday, November 23, 2012 5:43 PM
> To: dri-devel@lists.freedesktop.org
> Cc: inki.dae@samsung.com; sachin.kamat@linaro.org; patches@linaro.org
> Subject: [PATCH Resend] drm/exynos: Use devm_* APIs in exynos_hdmi.c
> 
> devm_* functions are device managed and make error handling and exit code
> simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> ---
>  drivers/gpu/drm/exynos/exynos_hdmi.c |   60
+++++++-----------------------
> ---
>  1 files changed, 13 insertions(+), 47 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c
> b/drivers/gpu/drm/exynos/exynos_hdmi.c
> index 59839cc..af5c8ac 100644
> --- a/drivers/gpu/drm/exynos/exynos_hdmi.c
> +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
> @@ -2197,27 +2197,27 @@ static int __devinit hdmi_resources_init(struct
> hdmi_context *hdata)
>  	memset(res, 0, sizeof(*res));
> 
>  	/* get clocks, power */
> -	res->hdmi = clk_get(dev, "hdmi");
> +	res->hdmi = devm_clk_get(dev, "hdmi");
>  	if (IS_ERR_OR_NULL(res->hdmi)) {
>  		DRM_ERROR("failed to get clock 'hdmi'\n");
>  		goto fail;
>  	}
> -	res->sclk_hdmi = clk_get(dev, "sclk_hdmi");
> +	res->sclk_hdmi = devm_clk_get(dev, "sclk_hdmi");
>  	if (IS_ERR_OR_NULL(res->sclk_hdmi)) {
>  		DRM_ERROR("failed to get clock 'sclk_hdmi'\n");
>  		goto fail;
>  	}
> -	res->sclk_pixel = clk_get(dev, "sclk_pixel");
> +	res->sclk_pixel = devm_clk_get(dev, "sclk_pixel");
>  	if (IS_ERR_OR_NULL(res->sclk_pixel)) {
>  		DRM_ERROR("failed to get clock 'sclk_pixel'\n");
>  		goto fail;
>  	}
> -	res->sclk_hdmiphy = clk_get(dev, "sclk_hdmiphy");
> +	res->sclk_hdmiphy = devm_clk_get(dev, "sclk_hdmiphy");
>  	if (IS_ERR_OR_NULL(res->sclk_hdmiphy)) {
>  		DRM_ERROR("failed to get clock 'sclk_hdmiphy'\n");
>  		goto fail;
>  	}
> -	res->hdmiphy = clk_get(dev, "hdmiphy");
> +	res->hdmiphy = devm_clk_get(dev, "hdmiphy");
>  	if (IS_ERR_OR_NULL(res->hdmiphy)) {
>  		DRM_ERROR("failed to get clock 'hdmiphy'\n");
>  		goto fail;
> @@ -2225,7 +2225,7 @@ static int __devinit hdmi_resources_init(struct
> hdmi_context *hdata)
> 
>  	clk_set_parent(res->sclk_hdmi, res->sclk_pixel);
> 
> -	res->regul_bulk = kzalloc(ARRAY_SIZE(supply) *
> +	res->regul_bulk = devm_kzalloc(dev, ARRAY_SIZE(supply) *
>  		sizeof(res->regul_bulk[0]), GFP_KERNEL);
>  	if (!res->regul_bulk) {
>  		DRM_ERROR("failed to get memory for regulators\n");
> @@ -2235,7 +2235,7 @@ static int __devinit hdmi_resources_init(struct
> hdmi_context *hdata)
>  		res->regul_bulk[i].supply = supply[i];
>  		res->regul_bulk[i].consumer = NULL;
>  	}
> -	ret = regulator_bulk_get(dev, ARRAY_SIZE(supply), res->regul_bulk);
> +	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(supply), res-
> >regul_bulk);
>  	if (ret) {
>  		DRM_ERROR("failed to get regulators\n");
>  		goto fail;
> @@ -2248,28 +2248,6 @@ fail:
>  	return -ENODEV;
>  }
> 
> -static int hdmi_resources_cleanup(struct hdmi_context *hdata)
> -{
> -	struct hdmi_resources *res = &hdata->res;
> -
> -	regulator_bulk_free(res->regul_count, res->regul_bulk);
> -	/* kfree is NULL-safe */
> -	kfree(res->regul_bulk);
> -	if (!IS_ERR_OR_NULL(res->hdmiphy))
> -		clk_put(res->hdmiphy);
> -	if (!IS_ERR_OR_NULL(res->sclk_hdmiphy))
> -		clk_put(res->sclk_hdmiphy);
> -	if (!IS_ERR_OR_NULL(res->sclk_pixel))
> -		clk_put(res->sclk_pixel);
> -	if (!IS_ERR_OR_NULL(res->sclk_hdmi))
> -		clk_put(res->sclk_hdmi);
> -	if (!IS_ERR_OR_NULL(res->hdmi))
> -		clk_put(res->hdmi);
> -	memset(res, 0, sizeof(*res));
> -
> -	return 0;
> -}
> -
>  static struct i2c_client *hdmi_ddc, *hdmi_hdmiphy;
> 
>  void hdmi_attach_ddc_client(struct i2c_client *ddc)
> @@ -2409,36 +2387,32 @@ static int __devinit hdmi_probe(struct
> platform_device *pdev)
>  	ret = hdmi_resources_init(hdata);
> 
>  	if (ret) {
> -		ret = -EINVAL;
>  		DRM_ERROR("hdmi_resources_init failed\n");
> -		goto err_data;
> +		return -EINVAL;
>  	}
> 
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (!res) {
>  		DRM_ERROR("failed to find registers\n");
> -		ret = -ENOENT;
> -		goto err_resource;
> +		return -ENOENT;
>  	}
> 
>  	hdata->regs = devm_request_and_ioremap(&pdev->dev, res);
>  	if (!hdata->regs) {
>  		DRM_ERROR("failed to map registers\n");
> -		ret = -ENXIO;
> -		goto err_resource;
> +		return -ENXIO;
>  	}
> 
> -	ret = gpio_request(hdata->hpd_gpio, "HPD");
> +	ret = devm_gpio_request(&pdev->dev, hdata->hpd_gpio, "HPD");
>  	if (ret) {
>  		DRM_ERROR("failed to request HPD gpio\n");
> -		goto err_resource;
> +		return ret;
>  	}
> 
>  	/* DDC i2c driver */
>  	if (i2c_add_driver(&ddc_driver)) {
>  		DRM_ERROR("failed to register ddc i2c driver\n");
> -		ret = -ENOENT;
> -		goto err_gpio;
> +		return -ENOENT;
>  	}
> 
>  	hdata->ddc_port = hdmi_ddc;
> @@ -2501,11 +2475,6 @@ err_hdmiphy:
>  	i2c_del_driver(&hdmiphy_driver);
>  err_ddc:
>  	i2c_del_driver(&ddc_driver);
> -err_gpio:
> -	gpio_free(hdata->hpd_gpio);
> -err_resource:
> -	hdmi_resources_cleanup(hdata);
> -err_data:
>  	return ret;
>  }
> 
> @@ -2522,9 +2491,6 @@ static int __devexit hdmi_remove(struct
> platform_device *pdev)
>  	free_irq(hdata->internal_irq, hdata);
>  	free_irq(hdata->external_irq, hdata);
> 
> -	gpio_free(hdata->hpd_gpio);
> -
> -	hdmi_resources_cleanup(hdata);
> 
>  	/* hdmiphy i2c driver */
>  	i2c_del_driver(&hdmiphy_driver);
> --
> 1.7.4.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH Resend] drm/exynos: Use devm_clk_get in exynos_drm_fimd.c
  2012-11-23  8:43 ` [PATCH Resend] drm/exynos: Use devm_clk_get in exynos_drm_fimd.c Sachin Kamat
@ 2012-11-23  9:51   ` Inki Dae
  2012-11-23  9:53     ` Sachin Kamat
  0 siblings, 1 reply; 7+ messages in thread
From: Inki Dae @ 2012-11-23  9:51 UTC (permalink / raw)
  To: 'Sachin Kamat', dri-devel; +Cc: patches

The subject mentions just only 'use devm_clk_get in exynos_dev_fimd.c' but
this patch removes unnecessary clk_disable calls also. Just separate this
patch into two as you mentioned. For this, already applied old one. So could
you send another one? Sorry for inconvenient. :)

Thanks,
Inki Dae

> -----Original Message-----
> From: Sachin Kamat [mailto:sachin.kamat@linaro.org]
> Sent: Friday, November 23, 2012 5:43 PM
> To: dri-devel@lists.freedesktop.org
> Cc: inki.dae@samsung.com; sachin.kamat@linaro.org; patches@linaro.org
> Subject: [PATCH Resend] drm/exynos: Use devm_clk_get in exynos_drm_fimd.c
> 
> devm_clk_get is device managed and makes error handling and exit code
> simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> ---
>  drivers/gpu/drm/exynos/exynos_drm_fimd.c |   31
++++++--------------------
> ---
>  1 files changed, 7 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> index ad04edd..00bd266 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> @@ -846,18 +846,16 @@ static int __devinit fimd_probe(struct
> platform_device *pdev)
>  	if (!ctx)
>  		return -ENOMEM;
> 
> -	ctx->bus_clk = clk_get(dev, "fimd");
> +	ctx->bus_clk = devm_clk_get(dev, "fimd");
>  	if (IS_ERR(ctx->bus_clk)) {
>  		dev_err(dev, "failed to get bus clock\n");
> -		ret = PTR_ERR(ctx->bus_clk);
> -		goto err_clk_get;
> +		return PTR_ERR(ctx->bus_clk);
>  	}
> 
> -	ctx->lcd_clk = clk_get(dev, "sclk_fimd");
> +	ctx->lcd_clk = devm_clk_get(dev, "sclk_fimd");
>  	if (IS_ERR(ctx->lcd_clk)) {
>  		dev_err(dev, "failed to get lcd clock\n");
> -		ret = PTR_ERR(ctx->lcd_clk);
> -		goto err_bus_clk;
> +		return PTR_ERR(ctx->lcd_clk);
>  	}
> 
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> @@ -865,14 +863,13 @@ static int __devinit fimd_probe(struct
> platform_device *pdev)
>  	ctx->regs = devm_request_and_ioremap(&pdev->dev, res);
>  	if (!ctx->regs) {
>  		dev_err(dev, "failed to map registers\n");
> -		ret = -ENXIO;
> -		goto err_clk;
> +		return -ENXIO;
>  	}
> 
>  	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
>  	if (!res) {
>  		dev_err(dev, "irq request failed.\n");
> -		goto err_clk;
> +		return -ENXIO;
>  	}
> 
>  	ctx->irq = res->start;
> @@ -881,7 +878,7 @@ static int __devinit fimd_probe(struct platform_device
> *pdev)
>  							0, "drm_fimd", ctx);
>  	if (ret) {
>  		dev_err(dev, "irq request failed.\n");
> -		goto err_clk;
> +		return ret;
>  	}
> 
>  	ctx->vidcon0 = pdata->vidcon0;
> @@ -915,17 +912,6 @@ static int __devinit fimd_probe(struct
> platform_device *pdev)
>  	exynos_drm_subdrv_register(subdrv);
> 
>  	return 0;
> -
> -err_clk:
> -	clk_disable(ctx->lcd_clk);
> -	clk_put(ctx->lcd_clk);
> -
> -err_bus_clk:
> -	clk_disable(ctx->bus_clk);
> -	clk_put(ctx->bus_clk);
> -
> -err_clk_get:
> -	return ret;
>  }
> 
>  static int __devexit fimd_remove(struct platform_device *pdev)
> @@ -949,9 +935,6 @@ static int __devexit fimd_remove(struct
> platform_device *pdev)
>  out:
>  	pm_runtime_disable(dev);
> 
> -	clk_put(ctx->lcd_clk);
> -	clk_put(ctx->bus_clk);
> -
>  	return 0;
>  }
> 
> --
> 1.7.4.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH Resend] drm/exynos: Use devm_clk_get in exynos_drm_fimd.c
  2012-11-23  9:51   ` Inki Dae
@ 2012-11-23  9:53     ` Sachin Kamat
  0 siblings, 0 replies; 7+ messages in thread
From: Sachin Kamat @ 2012-11-23  9:53 UTC (permalink / raw)
  To: Inki Dae; +Cc: dri-devel, patches

On 23 November 2012 15:21, Inki Dae <inki.dae@samsung.com> wrote:
> The subject mentions just only 'use devm_clk_get in exynos_dev_fimd.c' but
> this patch removes unnecessary clk_disable calls also. Just separate this
> patch into two as you mentioned. For this, already applied old one. So could
> you send another one? Sorry for inconvenient. :)

He he.. no problem.. i will send another patch which just contains
removing clk_disable.

>
> Thanks,
> Inki Dae
>
>> -----Original Message-----
>> From: Sachin Kamat [mailto:sachin.kamat@linaro.org]
>> Sent: Friday, November 23, 2012 5:43 PM
>> To: dri-devel@lists.freedesktop.org
>> Cc: inki.dae@samsung.com; sachin.kamat@linaro.org; patches@linaro.org
>> Subject: [PATCH Resend] drm/exynos: Use devm_clk_get in exynos_drm_fimd.c
>>
>> devm_clk_get is device managed and makes error handling and exit code
>> simpler.
>>
>> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
>> ---
>>  drivers/gpu/drm/exynos/exynos_drm_fimd.c |   31
> ++++++--------------------
>> ---
>>  1 files changed, 7 insertions(+), 24 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
>> b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
>> index ad04edd..00bd266 100644
>> --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
>> @@ -846,18 +846,16 @@ static int __devinit fimd_probe(struct
>> platform_device *pdev)
>>       if (!ctx)
>>               return -ENOMEM;
>>
>> -     ctx->bus_clk = clk_get(dev, "fimd");
>> +     ctx->bus_clk = devm_clk_get(dev, "fimd");
>>       if (IS_ERR(ctx->bus_clk)) {
>>               dev_err(dev, "failed to get bus clock\n");
>> -             ret = PTR_ERR(ctx->bus_clk);
>> -             goto err_clk_get;
>> +             return PTR_ERR(ctx->bus_clk);
>>       }
>>
>> -     ctx->lcd_clk = clk_get(dev, "sclk_fimd");
>> +     ctx->lcd_clk = devm_clk_get(dev, "sclk_fimd");
>>       if (IS_ERR(ctx->lcd_clk)) {
>>               dev_err(dev, "failed to get lcd clock\n");
>> -             ret = PTR_ERR(ctx->lcd_clk);
>> -             goto err_bus_clk;
>> +             return PTR_ERR(ctx->lcd_clk);
>>       }
>>
>>       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> @@ -865,14 +863,13 @@ static int __devinit fimd_probe(struct
>> platform_device *pdev)
>>       ctx->regs = devm_request_and_ioremap(&pdev->dev, res);
>>       if (!ctx->regs) {
>>               dev_err(dev, "failed to map registers\n");
>> -             ret = -ENXIO;
>> -             goto err_clk;
>> +             return -ENXIO;
>>       }
>>
>>       res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
>>       if (!res) {
>>               dev_err(dev, "irq request failed.\n");
>> -             goto err_clk;
>> +             return -ENXIO;
>>       }
>>
>>       ctx->irq = res->start;
>> @@ -881,7 +878,7 @@ static int __devinit fimd_probe(struct platform_device
>> *pdev)
>>                                                       0, "drm_fimd", ctx);
>>       if (ret) {
>>               dev_err(dev, "irq request failed.\n");
>> -             goto err_clk;
>> +             return ret;
>>       }
>>
>>       ctx->vidcon0 = pdata->vidcon0;
>> @@ -915,17 +912,6 @@ static int __devinit fimd_probe(struct
>> platform_device *pdev)
>>       exynos_drm_subdrv_register(subdrv);
>>
>>       return 0;
>> -
>> -err_clk:
>> -     clk_disable(ctx->lcd_clk);
>> -     clk_put(ctx->lcd_clk);
>> -
>> -err_bus_clk:
>> -     clk_disable(ctx->bus_clk);
>> -     clk_put(ctx->bus_clk);
>> -
>> -err_clk_get:
>> -     return ret;
>>  }
>>
>>  static int __devexit fimd_remove(struct platform_device *pdev)
>> @@ -949,9 +935,6 @@ static int __devexit fimd_remove(struct
>> platform_device *pdev)
>>  out:
>>       pm_runtime_disable(dev);
>>
>> -     clk_put(ctx->lcd_clk);
>> -     clk_put(ctx->bus_clk);
>> -
>>       return 0;
>>  }
>>
>> --
>> 1.7.4.1
>



-- 
With warm regards,
Sachin

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-11-23  9:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-23  8:43 [PATCH Resend] drm/exynos: Use devm_clk_get in exynos_mixer.c Sachin Kamat
2012-11-23  8:43 ` [PATCH Resend] drm/exynos: Use devm_* APIs in exynos_hdmi.c Sachin Kamat
2012-11-23  9:40   ` Inki Dae
2012-11-23  8:43 ` [PATCH Resend] drm/exynos: Use devm_clk_get in exynos_drm_fimd.c Sachin Kamat
2012-11-23  9:51   ` Inki Dae
2012-11-23  9:53     ` Sachin Kamat
2012-11-23  9:40 ` [PATCH Resend] drm/exynos: Use devm_clk_get in exynos_mixer.c Inki Dae

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).