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: 10021285 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 73D0A60224 for ; Sat, 21 Oct 2017 08:37:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63F5A28C03 for ; Sat, 21 Oct 2017 08:37:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 567BC28D69; Sat, 21 Oct 2017 08:37:56 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F82F28C03 for ; Sat, 21 Oct 2017 08:37:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752991AbdJUIhx (ORCPT ); Sat, 21 Oct 2017 04:37:53 -0400 Received: from lb1-smtp-cloud8.xs4all.net ([194.109.24.21]:58590 "EHLO lb1-smtp-cloud8.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752862AbdJUIhw (ORCPT ); Sat, 21 Oct 2017 04:37:52 -0400 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== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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; }