From patchwork Fri Dec 20 02:50:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 3392401 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C3D3F9F344 for ; Fri, 20 Dec 2013 23:32:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0037F206EC for ; Fri, 20 Dec 2013 23:32:05 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2FD83206E6 for ; Fri, 20 Dec 2013 23:32:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A5E08FA502; Fri, 20 Dec 2013 15:32:02 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com [209.85.214.53]) by gabe.freedesktop.org (Postfix) with ESMTP id 095EB43895 for ; Thu, 19 Dec 2013 18:50:55 -0800 (PST) Received: by mail-bk0-f53.google.com with SMTP id na10so990796bkb.26 for ; Thu, 19 Dec 2013 18:50:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=Qc5itf7xyALp6s5bObrKPTvRg9x5LFTPOZGiGNoSRtw=; b=rlgaHEjbstTsQIK9ihzR589YiTZBRqlAc3pX7yOvagrvI4a9D1PlCx2mNfILjWDMSb E+uMhQkThpG+oZwvTDuVzeVWYWBfqI8lzSjANpOdog7ywzxN7HJV98b2Mkbtn7m0eiTx 4Le9yyTmSyBYIbidAGMQqkrqGLjKirR/Yd7MtuZF2lZQz8g0WnyPLa2hj93DjV85ZZpk Arz8rQkN0lAYaibxD3viTIjgCggaeHcYVbXhZaSKkg9EPYkgfsnaQJ1kRwKLZXY/Orvm 54VPL6aja9SrOWyTMAMGMw7uZaoyj6VIuVQmSHOt5DWBpVmQER/Yz3zwr7KyVbqUiXq4 +19A== MIME-Version: 1.0 X-Received: by 10.205.43.200 with SMTP id ud8mr19011bkb.39.1387507853453; Thu, 19 Dec 2013 18:50:53 -0800 (PST) Received: by 10.204.74.130 with HTTP; Thu, 19 Dec 2013 18:50:53 -0800 (PST) Date: Fri, 20 Dec 2013 10:50:53 +0800 Message-ID: Subject: [PATCH -next] drm/tegra: Fix the error handling in tegra_dsi_probe() From: Wei Yongjun To: thierry.reding@gmail.com, tbergstrom@nvidia.com, airlied@linux.ie, swarren@wwwdotorg.org, grant.likely@linaro.org, robh+dt@kernel.org X-Mailman-Approved-At: Fri, 20 Dec 2013 15:30:20 -0800 Cc: linux-tegra@vger.kernel.org, yongjun_wei@trendmicro.com.cn, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wei Yongjun Fix the error handling to release all alloced resources before return from tegra_dsi_probe() in the error handling case. Signed-off-by: Wei Yongjun --- drivers/gpu/drm/tegra/dsi.c | 53 ++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c index d452faab..677ebca 100644 --- a/drivers/gpu/drm/tegra/dsi.c +++ b/drivers/gpu/drm/tegra/dsi.c @@ -847,61 +847,70 @@ static int tegra_dsi_probe(struct platform_device *pdev) dsi->lanes = 4; dsi->rst = devm_reset_control_get(&pdev->dev, "dsi"); - if (IS_ERR(dsi->rst)) - return PTR_ERR(dsi->rst); + if (IS_ERR(dsi->rst)) { + err = PTR_ERR(dsi->rst); + goto err_reset_control_get; + } dsi->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(dsi->clk)) { dev_err(&pdev->dev, "cannot get DSI clock\n"); - return PTR_ERR(dsi->clk); + err = PTR_ERR(dsi->clk); + goto err_reset_control_get; } err = clk_prepare_enable(dsi->clk); if (err < 0) { dev_err(&pdev->dev, "cannot enable DSI clock\n"); - return err; + goto err_reset_control_get; } dsi->clk_lp = devm_clk_get(&pdev->dev, "lp"); if (IS_ERR(dsi->clk_lp)) { dev_err(&pdev->dev, "cannot get low-power clock\n"); - return PTR_ERR(dsi->clk_lp); + err = PTR_ERR(dsi->clk_lp); + goto err_clk_get_lp; } err = clk_prepare_enable(dsi->clk_lp); if (err < 0) { dev_err(&pdev->dev, "cannot enable low-power clock\n"); - return err; + goto err_clk_get_lp; } dsi->clk_parent = devm_clk_get(&pdev->dev, "parent"); if (IS_ERR(dsi->clk_parent)) { dev_err(&pdev->dev, "cannot get parent clock\n"); - return PTR_ERR(dsi->clk_parent); + err = PTR_ERR(dsi->clk_parent); + goto err_clk_get_parent; } err = clk_prepare_enable(dsi->clk_parent); if (err < 0) { dev_err(&pdev->dev, "cannot enable parent clock\n"); - return err; + goto err_clk_get_parent; } err = tegra_dsi_setup_clocks(dsi); if (err < 0) { dev_err(&pdev->dev, "cannot setup clocks\n"); - return err; + goto err_setup_clocks; } regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); dsi->regs = devm_ioremap_resource(&pdev->dev, regs); - if (IS_ERR(dsi->regs)) - return PTR_ERR(dsi->regs); + if (IS_ERR(dsi->regs)) { + err = PTR_ERR(dsi->regs); + goto err_setup_clocks; + } tegra_dsi_initialize(dsi); dsi->mipi = tegra_mipi_request(&pdev->dev); - if (IS_ERR(dsi->mipi)) - return PTR_ERR(dsi->mipi); + if (IS_ERR(dsi->mipi)) { + err = PTR_ERR(dsi->mipi); + goto err_setup_clocks; + } dsi->host.ops = &tegra_dsi_host_ops; dsi->host.dev = &pdev->dev; @@ -909,7 +918,7 @@ static int tegra_dsi_probe(struct platform_device *pdev) err = mipi_dsi_host_register(&dsi->host); if (err < 0) { dev_err(&pdev->dev, "failed to register DSI host: %d\n", err); - return err; + goto err_host_register; } INIT_LIST_HEAD(&dsi->client.list); @@ -920,12 +929,26 @@ static int tegra_dsi_probe(struct platform_device *pdev) if (err < 0) { dev_err(&pdev->dev, "failed to register host1x client: %d\n", err); - return err; + goto err_client_register; } platform_set_drvdata(pdev, dsi); return 0; + +err_client_register: + mipi_dsi_host_unregister(&dsi->host); +err_host_register: + tegra_mipi_free(dsi->mipi); +err_setup_clocks: + clk_disable_unprepare(dsi->clk_parent); +err_clk_get_parent: + clk_disable_unprepare(dsi->clk_lp); +err_clk_get_lp: + clk_disable_unprepare(dsi->clk); +err_reset_control_get: + tegra_output_remove(&dsi->output); + return err; } static int tegra_dsi_remove(struct platform_device *pdev)