From patchwork Thu Feb 27 12:37:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 183937 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4461908ile; Thu, 27 Feb 2020 04:38:49 -0800 (PST) X-Google-Smtp-Source: APXvYqy1Z0HACKu+oNO5mSNnp52nxTNV4HWLQGwA6zaw+EbrXBYbIzDUMbUPSDrKvReBKAG+r/Bz X-Received: by 2002:a17:902:b682:: with SMTP id c2mr4413651pls.127.1582807129092; Thu, 27 Feb 2020 04:38:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582807129; cv=none; d=google.com; s=arc-20160816; b=CSbXR/LgccCvHn2V/sC+e/NCYzW/k3uoNx9g3K59OFrejwcGE4Wt/YPjVMNcveBpNJ /sKnKfLsRh231YYqDu+hpo+x3jJWR3CEvSt2XpjUFpUYqSC33kXXld+XG/PW3UQFe1is /iL5ihK/awXUvYPUPHPwpO5V0ydcwkLAYpXKOjGYyRX860UdB/hd6HruVqI0NPTm7o/x JBhT6z3gC7+CIEm60eFtrs4kCnHGyGD+K5fpyItKJz+juiTWIbMzpwbv9VVROyxmNN+l SrH6WrUHpxDzat3q2YPZzcrUeFh2ZQZBErDmNGBV10iSvUOq1X+vRr6BcrDot+cBHwkJ jc6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:dkim-signature; bh=IB6R43NdlZpqr7IUWKf0qFOCIerwv8/vPAdGwMYm+n0=; b=kQ8eElVI0LLJgCo2kP1GGaKJPeGOOrdsLAxRLOSR5+eF5v5lpbmGLgG3sQOXvW/K4i pfhlfJUTpxYY0qFDZrpHV7IGd6k+0o3coiW7fpOjTxiMD9kzV6jDBoHFiLMYkqEpcTR9 IkYw4HG1k8xbuCSZEdC0zotYqanpCcdv2bAqxNe5Tp4f7yIiAHuUm7V4jYyJldLUvfu3 LcrR1Nb72g3JRwZ/GaPp6fZ63NTb93dde3iPzXMEY1mX1NA6lFxmIDML8NSV2TH/4nSH +vVGkfAUFn4NEaZbb95wzBjlfst7lm/L8TSvLfzTk0r7NgFMXxnR4v3n6ALq3B7SZtQv nZNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=b+HNoJzp; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b="xq/zkBRH"; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id u10si2829265pgn.319.2020.02.27.04.38.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 04:38:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=b+HNoJzp; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b="xq/zkBRH"; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IB6R43NdlZpqr7IUWKf0qFOCIerwv8/vPAdGwMYm+n0=; b=b+HNoJzpk2RQ+I NhabCUntdDGySMK+gcU3ZKEc3C4qVA1WERxHsxUK2sOl8gtgL04LEq4YMqvKoCpIOFC5UhNHJaz1g c+zS4CFvSXRgB1XeesjzKwE+uVJGqdIm5Q4jT5ulJNvCfiwOlCmDs+LJFqIW3njVpcMbcG8NeZ/cj hhHjSeWXheuXc+4FTyZ2j/cn/W1IK1fS0h4GQ1kNVWd0vq1S4UciH9bNvuvYHIJjWBeevHmFkU4Y6 7SZSEnOI4gOPQKlOySgVZplQf0mI5j0iYv50/U6TCR63QKWLQzteqzcxd4nUJihboIu81Isixl5u3 2WrvqBnV4iJ/LAR0uYpA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j7IR3-000285-4s; Thu, 27 Feb 2020 12:38:37 +0000 Received: from fllv0015.ext.ti.com ([198.47.19.141]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j7IQZ-0001ha-O4; Thu, 27 Feb 2020 12:38:09 +0000 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 01RCc0fk117345; Thu, 27 Feb 2020 06:38:00 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1582807080; bh=ixAPQJdNXHfaYAwd0a821FNFCS6Wv9ULBLSO6ySWj1A=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=xq/zkBRHiJQJC5RR8xX2pyd9YnKnKWXTyhGYh56sQ4fF78VZqrOluvTurQXNR+yo4 dPOhdBCJrsyn+dui1NYm4C4GHvzCQ4EY6d/h+4MlhGOVMW1Oa9FyjO06nmeI1qgfQU tJY/Ht/25QVtZEBYq7v1Yzk2qihUbePwgVB4LGBw= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 01RCc02h127709 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 27 Feb 2020 06:38:00 -0600 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Thu, 27 Feb 2020 06:37:58 -0600 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Thu, 27 Feb 2020 06:37:58 -0600 Received: from feketebors.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 01RCbnvP100207; Thu, 27 Feb 2020 06:37:56 -0600 From: Peter Ujfalusi To: , , , , , , , Subject: [PATCH 2/7] mtd: rawnand: marvell: Release DMA channel on error Date: Thu, 27 Feb 2020 14:37:44 +0200 Message-ID: <20200227123749.24064-3-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227123749.24064-1-peter.ujfalusi@ti.com> References: <20200227123749.24064-1-peter.ujfalusi@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200227_043807_888766_AC318E35 X-CRM114-Status: GOOD ( 14.13 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [198.47.19.141 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vkoul@kernel.org, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org Release the DMA channel on errors after the channel has been successfully requested. Signed-off-by: Peter Ujfalusi --- drivers/mtd/nand/raw/marvell_nand.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) -- Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c index fb5abdcfb007..b6c7e1903396 100644 --- a/drivers/mtd/nand/raw/marvell_nand.c +++ b/drivers/mtd/nand/raw/marvell_nand.c @@ -2751,8 +2751,10 @@ static int marvell_nfc_init_dma(struct marvell_nfc *nfc) } r = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!r) - return -ENXIO; + if (!r) { + ret = -ENXIO; + goto release_channel; + } config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; @@ -2763,7 +2765,7 @@ static int marvell_nfc_init_dma(struct marvell_nfc *nfc) ret = dmaengine_slave_config(nfc->dma_chan, &config); if (ret < 0) { dev_err(nfc->dev, "Failed to configure DMA channel\n"); - return ret; + goto release_channel; } /* @@ -2773,12 +2775,20 @@ static int marvell_nfc_init_dma(struct marvell_nfc *nfc) * the provided buffer. */ nfc->dma_buf = kmalloc(MAX_CHUNK_SIZE, GFP_KERNEL | GFP_DMA); - if (!nfc->dma_buf) - return -ENOMEM; + if (!nfc->dma_buf) { + ret = -ENOMEM; + goto release_channel; + } nfc->use_dma = true; return 0; + +release_channel: + dma_release_channel(nfc->dma_chan); + nfc->dma_chan = NULL; + + return ret; } static void marvell_nfc_reset(struct marvell_nfc *nfc) @@ -2920,10 +2930,13 @@ static int marvell_nfc_probe(struct platform_device *pdev) ret = marvell_nand_chips_init(dev, nfc); if (ret) - goto unprepare_reg_clk; + goto release_dma; return 0; +release_dma: + if (nfc->use_dma) + dma_release_channel(nfc->dma_chan); unprepare_reg_clk: clk_disable_unprepare(nfc->reg_clk); unprepare_core_clk: