From patchwork Sat Jun 20 21:43:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 6651741 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DD4799F326 for ; Sat, 20 Jun 2015 21:44:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 39E98206FA for ; Sat, 20 Jun 2015 21:44:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B2D620701 for ; Sat, 20 Jun 2015 21:44:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932561AbbFTVoJ (ORCPT ); Sat, 20 Jun 2015 17:44:09 -0400 Received: from mail-qk0-f170.google.com ([209.85.220.170]:34446 "EHLO mail-qk0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932548AbbFTVoI (ORCPT ); Sat, 20 Jun 2015 17:44:08 -0400 Received: by qkeo142 with SMTP id o142so62799564qke.1 for ; Sat, 20 Jun 2015 14:44:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=1Oh1CrJZm8Fx8E/luuhJqDPZMYtwTGC3pc6Ja5zQ4aM=; b=I7oQxOe+HREeSTzD43VpCB2pbz7xiZl7oe72gVB8U2u6ZVXg7RmmQNZzjV+AYpi4+v Ipvs+7uSlXL2k3Pa3gfdgFkRlst+Lf3V2TtSd65+ungNYqyN8iNV7ihTBUE3mQbfrx9I i68UbgpDFFkDCLklPgSKNHVOm2DKuBtDUW83GwVCiVtXjSC68zv6gideCa+1XNa17ZfU OhXF8OveL5KbN8bnjtxyP6C5RMW/fvcI22A4wY16QSKaX7ZqxuRNW7DL+/mTPtGBN6S0 Ze/2DuaPq+OZArfoi+LYnSVg7ku/7eMLQY3mQHI7FOp8ssh9zq8F82xwHmJQjLetkDYq mKWQ== X-Received: by 10.55.25.167 with SMTP id 39mr49537246qkz.89.1434836647457; Sat, 20 Jun 2015 14:44:07 -0700 (PDT) Received: from localhost.localdomain ([189.101.187.123]) by mx.google.com with ESMTPSA id f196sm7764019qhe.49.2015.06.20.14.44.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 20 Jun 2015 14:44:06 -0700 (PDT) From: Fabio Estevam To: vinod.koul@intel.com Cc: shawnguo@kernel.org, kernel@pengutronix.de, dmaengine@vger.kernel.org, Fabio Estevam Subject: [PATCH] dmaengine: imx-dma: Check for clk_prepare_enable() error Date: Sat, 20 Jun 2015 18:43:44 -0300 Message-Id: <1434836625-29098-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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: Fabio Estevam clk_prepare_enable() may fail, so we should better check its return value and propagate it in the case of error. While at it, change the label 'err' to a more descriptive naming. Signed-off-by: Fabio Estevam --- drivers/dma/imx-dma.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c index 865501fc..139c567 100644 --- a/drivers/dma/imx-dma.c +++ b/drivers/dma/imx-dma.c @@ -1083,8 +1083,12 @@ static int __init imxdma_probe(struct platform_device *pdev) if (IS_ERR(imxdma->dma_ahb)) return PTR_ERR(imxdma->dma_ahb); - clk_prepare_enable(imxdma->dma_ipg); - clk_prepare_enable(imxdma->dma_ahb); + ret = clk_prepare_enable(imxdma->dma_ipg); + if (ret) + return ret; + ret = clk_prepare_enable(imxdma->dma_ahb); + if (ret) + goto disable_dma_ipg_clk; /* reset DMA module */ imx_dmav1_writel(imxdma, DCR_DRST, DMA_DCR); @@ -1094,20 +1098,20 @@ static int __init imxdma_probe(struct platform_device *pdev) dma_irq_handler, 0, "DMA", imxdma); if (ret) { dev_warn(imxdma->dev, "Can't register IRQ for DMA\n"); - goto err; + goto disable_dma_ahb_clk; } irq_err = platform_get_irq(pdev, 1); if (irq_err < 0) { ret = irq_err; - goto err; + goto disable_dma_ahb_clk; } ret = devm_request_irq(&pdev->dev, irq_err, imxdma_err_handler, 0, "DMA", imxdma); if (ret) { dev_warn(imxdma->dev, "Can't register ERRIRQ for DMA\n"); - goto err; + goto disable_dma_ahb_clk; } } @@ -1144,7 +1148,7 @@ static int __init imxdma_probe(struct platform_device *pdev) dev_warn(imxdma->dev, "Can't register IRQ %d " "for DMA channel %d\n", irq + i, i); - goto err; + goto disable_dma_ahb_clk; } init_timer(&imxdmac->watchdog); imxdmac->watchdog.function = &imxdma_watchdog; @@ -1190,7 +1194,7 @@ static int __init imxdma_probe(struct platform_device *pdev) ret = dma_async_device_register(&imxdma->dma_device); if (ret) { dev_err(&pdev->dev, "unable to register\n"); - goto err; + goto disable_dma_ahb_clk; } if (pdev->dev.of_node) { @@ -1206,9 +1210,10 @@ static int __init imxdma_probe(struct platform_device *pdev) err_of_dma_controller: dma_async_device_unregister(&imxdma->dma_device); -err: - clk_disable_unprepare(imxdma->dma_ipg); +disable_dma_ahb_clk: clk_disable_unprepare(imxdma->dma_ahb); +disable_dma_ipg_clk: + clk_disable_unprepare(imxdma->dma_ipg); return ret; }