From patchwork Thu Jul 30 00:03:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 6896781 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id ED35DC05AC for ; Thu, 30 Jul 2015 00:04:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 09E7F20622 for ; Thu, 30 Jul 2015 00:04:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F2A9B20621 for ; Thu, 30 Jul 2015 00:04:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754127AbbG3AEU (ORCPT ); Wed, 29 Jul 2015 20:04:20 -0400 Received: from mail-yk0-f179.google.com ([209.85.160.179]:35634 "EHLO mail-yk0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754010AbbG3AEU (ORCPT ); Wed, 29 Jul 2015 20:04:20 -0400 Received: by ykdu72 with SMTP id u72so21794692ykd.2 for ; Wed, 29 Jul 2015 17:04:19 -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=x8GIQdQb74/NjHUmPHnx5BaAPScS+xHsGRw6DLIejVg=; b=HThW38lWSA9xnTas6OQGq1UXvk6gXhSeBuEawcxiYvnjlIQusQt5C/jcZrFz1Nn4b8 U29nQr3lFORu32RRjJZLQuEFtgUX7NEVGWIuwZ5sjBl6VedTMxqPu1+ZXetk8O+DyYVe LrE7LvnlrgdxEHQ40A2HmzaG6anRddq30oZepPRUHq1KuvPC+USY2vKs0vdetB5PBbI6 VcqCA1KHMXRqLPQYQb1sTO8Lm6h1vBYwY7+CHsJAhoGbUBlToUUxg7DYqJn+2AcfsWd0 oNiLHz2nWZFTZPiEk9fhVWf2pQfiZ0xzf3Jg9AHwQS0gcaGj/jwUZdF77VUovHb0EfdB lgwg== X-Received: by 10.13.204.130 with SMTP id o124mr14800871ywd.171.1438214659710; Wed, 29 Jul 2015 17:04:19 -0700 (PDT) Received: from localhost.localdomain ([179.159.8.198]) by smtp.gmail.com with ESMTPSA id f2sm25318160ywf.5.2015.07.29.17.04.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Jul 2015 17:04:18 -0700 (PDT) From: Fabio Estevam To: vinod.koul@intel.com Cc: dmaengine@vger.kernel.org, Fabio Estevam Subject: [PATCH] dmaengine: imx-sdma: Check for clk_enable() errors Date: Wed, 29 Jul 2015 21:03:49 -0300 Message-Id: <1438214629-24386-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=-8.2 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=ham 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_enable() may fail, so we should better check the return value and propagate it in the case of error. Signed-off-by: Fabio Estevam --- drivers/dma/imx-sdma.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 77b6aab..432451e 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -988,16 +988,20 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan) sdmac->peripheral_type = data->peripheral_type; sdmac->event_id0 = data->dma_request; - clk_enable(sdmac->sdma->clk_ipg); - clk_enable(sdmac->sdma->clk_ahb); + ret = clk_enable(sdmac->sdma->clk_ipg); + if (ret) + return ret; + ret = clk_enable(sdmac->sdma->clk_ahb); + if (ret) + goto disable_clk_ipg; ret = sdma_request_channel(sdmac); if (ret) - return ret; + goto disable_clk_ahb; ret = sdma_set_channel_priority(sdmac, prio); if (ret) - return ret; + goto disable_clk_ahb; dma_async_tx_descriptor_init(&sdmac->desc, chan); sdmac->desc.tx_submit = sdma_tx_submit; @@ -1005,6 +1009,12 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan) sdmac->desc.flags = DMA_CTRL_ACK; return 0; + +disable_clk_ahb: + clk_disable(sdmac->sdma->clk_ahb); +disable_clk_ipg: + clk_disable(sdmac->sdma->clk_ipg); + return ret; } static void sdma_free_chan_resources(struct dma_chan *chan) @@ -1354,8 +1364,12 @@ static int sdma_init(struct sdma_engine *sdma) int i, ret; dma_addr_t ccb_phys; - clk_enable(sdma->clk_ipg); - clk_enable(sdma->clk_ahb); + ret = clk_enable(sdma->clk_ipg); + if (ret) + return ret; + ret = clk_enable(sdma->clk_ahb); + if (ret) + goto disable_clk_ipg; /* Be sure SDMA has not started yet */ writel_relaxed(0, sdma->regs + SDMA_H_C0PTR); @@ -1411,8 +1425,9 @@ static int sdma_init(struct sdma_engine *sdma) return 0; err_dma_alloc: - clk_disable(sdma->clk_ipg); clk_disable(sdma->clk_ahb); +disable_clk_ipg: + clk_disable(sdma->clk_ipg); dev_err(sdma->dev, "initialisation failed with %d\n", ret); return ret; }