From patchwork Sat Oct 21 08:37:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10021287 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D76C560224 for ; Sat, 21 Oct 2017 08:37:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBD1128C03 for ; Sat, 21 Oct 2017 08:37:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0A1028C1D; Sat, 21 Oct 2017 08:37:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C29D528C1A for ; Sat, 21 Oct 2017 08:37:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0E10A6E097; Sat, 21 Oct 2017 08:37:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lb2-smtp-cloud8.xs4all.net (lb2-smtp-cloud8.xs4all.net [194.109.24.25]) by gabe.freedesktop.org (Postfix) with ESMTPS id A8BBA6E097 for ; Sat, 21 Oct 2017 08:37:52 +0000 (UTC) Received: from [192.168.1.10] ([80.101.105.217]) by smtp-cloud8.xs4all.net with ESMTPA id 5pHxefnebg5cR5pHyerA3G; Sat, 21 Oct 2017 10:37:50 +0200 To: Linux Media Mailing List , "dri-devel@lists.freedesktop.org" , Thierry Reding , linux-tegra@vger.kernel.org From: Hans Verkuil Subject: [PATCH] tegra-cec: fix messy probe() cleanup Message-ID: <001c8577-b77c-6a98-1efa-dc4902940873@xs4all.nl> Date: Sat, 21 Oct 2017 10:37:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 X-CMAE-Envelope: MS4wfDTtityvhPSigeckJraKEH2qhCfoYqJ2T3mmx6IZya/9xYUYNS9GIq2g/649TSrKwGvH+pXeKwMuy4RFhW4iIVLJ+vT8sk/2cB9bNFDhkzhDKxgq/Yu6 gj/kLOdYs4KNNC3DdVJRQCnwv5fJtfTlOhSvP3EVq8+tHiRizB//0WTq4KSbOaspiKBSViCTqf+UFctC45w9t0e/vXj7D7scETnE86uonYHGGnVUBA6hMVaQ qLT7wdXt1j2ufxuzNtvbVJ3LU+RVB9x5/qbyrQ/4Qc9SsySe0nGwQoLroTNgKUeLIJ1/9AOthFhhvTirXMil5w== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The probe() cleanup code ('goto foo_error') was very messy. It appears that this code wasn't updated when I switched to the devm_ functions in an earlier version. Update the code to use 'return error' where it can and do proper cleanup where it needs to. Note that the original code wasn't buggy, it was just messy. Signed-off-by: Hans Verkuil --- Since I already posted the pull request for this driver and since this is just a cleanup I decided to do this as a separate patch on top of the pull request code rather than merging this in the pull request. --- drivers/media/platform/tegra-cec/tegra_cec.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/drivers/media/platform/tegra-cec/tegra_cec.c b/drivers/media/platform/tegra-cec/tegra_cec.c index b53743f555e8..807c94c70049 100644 --- a/drivers/media/platform/tegra-cec/tegra_cec.c +++ b/drivers/media/platform/tegra-cec/tegra_cec.c @@ -356,40 +356,34 @@ static int tegra_cec_probe(struct platform_device *pdev) if (!res) { dev_err(&pdev->dev, "Unable to allocate resources for device\n"); - ret = -EBUSY; - goto cec_error; + return -EBUSY; } if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res), pdev->name)) { dev_err(&pdev->dev, "Unable to request mem region for device\n"); - ret = -EBUSY; - goto cec_error; + return -EBUSY; } cec->tegra_cec_irq = platform_get_irq(pdev, 0); - if (cec->tegra_cec_irq <= 0) { - ret = -EBUSY; - goto cec_error; - } + if (cec->tegra_cec_irq <= 0) + return -EBUSY; cec->cec_base = devm_ioremap_nocache(&pdev->dev, res->start, - resource_size(res)); + resource_size(res)); if (!cec->cec_base) { dev_err(&pdev->dev, "Unable to grab IOs for device\n"); - ret = -EBUSY; - goto cec_error; + return -EBUSY; } cec->clk = devm_clk_get(&pdev->dev, "cec"); if (IS_ERR_OR_NULL(cec->clk)) { dev_err(&pdev->dev, "Can't get clock for CEC\n"); - ret = -ENOENT; - goto clk_error; + return -ENOENT; } clk_prepare_enable(cec->clk); @@ -406,13 +400,13 @@ static int tegra_cec_probe(struct platform_device *pdev) if (ret) { dev_err(&pdev->dev, "Unable to request interrupt for device\n"); - goto cec_error; + goto clk_error; } cec->notifier = cec_notifier_get(&hdmi_dev->dev); if (!cec->notifier) { ret = -ENOMEM; - goto cec_error; + goto clk_error; } cec->adap = cec_allocate_adapter(&tegra_cec_ops, cec, TEGRA_CEC_NAME, @@ -437,8 +431,8 @@ static int tegra_cec_probe(struct platform_device *pdev) if (cec->notifier) cec_notifier_put(cec->notifier); cec_delete_adapter(cec->adap); - clk_disable_unprepare(cec->clk); clk_error: + clk_disable_unprepare(cec->clk); return ret; }