From patchwork Tue Jul 31 16:39:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Cassou X-Patchwork-Id: 1261151 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id BD48D3FC71 for ; Tue, 31 Jul 2012 16:40:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755747Ab2GaQja (ORCPT ); Tue, 31 Jul 2012 12:39:30 -0400 Received: from mail1-relais-roc.national.inria.fr ([192.134.164.82]:44887 "EHLO mail1-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755727Ab2GaQj2 (ORCPT ); Tue, 31 Jul 2012 12:39:28 -0400 X-IronPort-AV: E=Sophos;i="4.77,688,1336341600"; d="scan'208";a="168700822" Received: from tytso.inria.fr (HELO localhost.localdomain) ([128.93.60.73]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 31 Jul 2012 18:39:24 +0200 From: Damien Cassou To: Inki Dae Cc: kernel-janitors@vger.kernel.org, Donghwa Lee , Kyungmin Park , Florian Tobias Schandinat , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/5] drivers/video/exynos/exynos_mipi_dsi.c: use devm_ functions Date: Tue, 31 Jul 2012 18:39:21 +0200 Message-Id: <1343752762-16861-5-git-send-email-damien.cassou@lifl.fr> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1343752762-16861-1-git-send-email-damien.cassou@lifl.fr> References: <1343752762-16861-1-git-send-email-damien.cassou@lifl.fr> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org From: Damien Cassou The various devm_ functions allocate memory that is released when a driver detaches. This patch uses these functions for data that is allocated in the probe function of a platform device and is only freed in the remove function. Signed-off-by: Damien Cassou --- drivers/video/exynos/exynos_mipi_dsi.c | 41 ++++++++++++--------------------- 1 file changed, 15 insertions(+), 26 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/video/exynos/exynos_mipi_dsi.c b/drivers/video/exynos/exynos_mipi_dsi.c index 4bc2b8a..c277a07 100644 --- a/drivers/video/exynos/exynos_mipi_dsi.c +++ b/drivers/video/exynos/exynos_mipi_dsi.c @@ -336,7 +336,8 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev) struct mipi_dsim_ddi *dsim_ddi; int ret = -EINVAL; - dsim = kzalloc(sizeof(struct mipi_dsim_device), GFP_KERNEL); + dsim = devm_kzalloc(&pdev->dev, sizeof(struct mipi_dsim_device), + GFP_KERNEL); if (!dsim) { dev_err(&pdev->dev, "failed to allocate dsim object.\n"); return -ENOMEM; @@ -350,13 +351,13 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev) dsim_pd = (struct mipi_dsim_platform_data *)dsim->pd; if (dsim_pd == NULL) { dev_err(&pdev->dev, "failed to get platform data for dsim.\n"); - goto err_clock_get; + goto err_platform_get_irq; } /* get mipi_dsim_config. */ dsim_config = dsim_pd->dsim_config; if (dsim_config == NULL) { dev_err(&pdev->dev, "failed to get dsim config data.\n"); - goto err_clock_get; + goto err_platform_get_irq; } dsim->dsim_config = dsim_config; @@ -367,13 +368,13 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev) ret = regulator_bulk_get(&pdev->dev, ARRAY_SIZE(supplies), supplies); if (ret) { dev_err(&pdev->dev, "Failed to get regulators: %d\n", ret); - goto err_clock_get; + goto err_platform_get_irq; } - dsim->clock = clk_get(&pdev->dev, "dsim0"); + dsim->clock = devm_clk_get(&pdev->dev, "dsim0"); if (IS_ERR(dsim->clock)) { dev_err(&pdev->dev, "failed to get dsim clock source\n"); - goto err_clock_get; + goto err_platform_get_irq; } clk_enable(dsim->clock); @@ -384,15 +385,17 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev) goto err_platform_get; } - dsim->res = request_mem_region(res->start, resource_size(res), - dev_name(&pdev->dev)); + dsim->res = devm_request_mem_region(&pdev->dev, res->start, + resource_size(res), + dev_name(&pdev->dev)); if (!dsim->res) { dev_err(&pdev->dev, "failed to request io memory region\n"); ret = -ENOMEM; - goto err_mem_region; + goto err_platform_get; } - dsim->reg_base = ioremap(res->start, resource_size(res)); + dsim->reg_base = devm_ioremap(&pdev->dev, res->start, + resource_size(res)); if (!dsim->reg_base) { dev_err(&pdev->dev, "failed to remap io region\n"); ret = -ENOMEM; @@ -405,7 +408,7 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev) dsim_ddi = exynos_mipi_dsi_bind_lcd_ddi(dsim, dsim_pd->lcd_panel_name); if (!dsim_ddi) { dev_err(&pdev->dev, "mipi_dsim_ddi object not found.\n"); - goto err_bind; + goto err_ioremap; } dsim->irq = platform_get_irq(pdev, 0); @@ -424,7 +427,7 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev) if (ret != 0) { dev_err(&pdev->dev, "failed to request dsim irq\n"); ret = -EINVAL; - goto err_bind; + goto err_ioremap; } /* enable interrupts */ @@ -466,20 +469,11 @@ done: return 0; -err_bind: - iounmap(dsim->reg_base); - err_ioremap: release_mem_region(dsim->res->start, resource_size(dsim->res)); -err_mem_region: - release_resource(dsim->res); - err_platform_get: clk_disable(dsim->clock); - clk_put(dsim->clock); -err_clock_get: - kfree(dsim); err_platform_get_irq: return ret; @@ -491,12 +485,8 @@ static int __devexit exynos_mipi_dsi_remove(struct platform_device *pdev) struct mipi_dsim_ddi *dsim_ddi, *next; struct mipi_dsim_lcd_driver *dsim_lcd_drv; - iounmap(dsim->reg_base); - clk_disable(dsim->clock); - clk_put(dsim->clock); - release_resource(dsim->res); release_mem_region(dsim->res->start, resource_size(dsim->res)); list_for_each_entry_safe(dsim_ddi, next, &dsim_ddi_list, list) { @@ -514,7 +504,6 @@ static int __devexit exynos_mipi_dsi_remove(struct platform_device *pdev) } regulator_bulk_free(ARRAY_SIZE(supplies), supplies); - kfree(dsim); return 0; }