From patchwork Mon Oct 5 13:22:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 11816647 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2091139A for ; Mon, 5 Oct 2020 13:22:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9467208A9 for ; Mon, 5 Oct 2020 13:22:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725939AbgJENWj (ORCPT ); Mon, 5 Oct 2020 09:22:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725936AbgJENWj (ORCPT ); Mon, 5 Oct 2020 09:22:39 -0400 Received: from mail-out.m-online.net (mail-out.m-online.net [IPv6:2001:a60:0:28:0:1:25:1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB367C0613CE for ; Mon, 5 Oct 2020 06:22:38 -0700 (PDT) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4C4h9760Hqz1s5VH; Mon, 5 Oct 2020 15:22:35 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4C4h97537gz1qqkK; Mon, 5 Oct 2020 15:22:35 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id bzkkvaEfiYd1; Mon, 5 Oct 2020 15:22:34 +0200 (CEST) X-Auth-Info: 8ge+jIr5f8nayvLs8bUvV5P8XW8PWVTtHbnAQLSHH3I= Received: from desktop.lan (ip-89-176-112-137.net.upcbroadband.cz [89.176.112.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Mon, 5 Oct 2020 15:22:34 +0200 (CEST) From: Marek Vasut To: linux-spi@vger.kernel.org Cc: Marek Vasut , Fabio Estevam , Mark Brown , NXP Linux Team , Robin Gong , Shawn Guo , linux-arm-kernel@lists.infradead.org Subject: [PATCH] spi: imx: Fix freeing of DMA channels if spi_bitbang_start() fails Date: Mon, 5 Oct 2020 15:22:29 +0200 Message-Id: <20201005132229.513119-1-marex@denx.de> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org If the SPI controller has has_dmamode = true and spi_bitbang_start() fails in spi_imx_probe(), then the driver must release the DMA channels acquired in spi_imx_sdma_init() by calling spi_imx_sdma_exit() in the fail path. Fixes: f62caccd12c1 ("spi: spi-imx: add DMA support") Signed-off-by: Marek Vasut Cc: Fabio Estevam Cc: Mark Brown Cc: NXP Linux Team Cc: Robin Gong Cc: Shawn Guo Cc: linux-arm-kernel@lists.infradead.org To: linux-spi@vger.kernel.org --- drivers/spi/spi-imx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 38a5f1304cec..e38e5ad3c706 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -1707,7 +1707,7 @@ static int spi_imx_probe(struct platform_device *pdev) ret = spi_bitbang_start(&spi_imx->bitbang); if (ret) { dev_err(&pdev->dev, "bitbang start failed with %d\n", ret); - goto out_runtime_pm_put; + goto out_bitbang_start; } dev_info(&pdev->dev, "probed\n"); @@ -1717,6 +1717,9 @@ static int spi_imx_probe(struct platform_device *pdev) return ret; +out_bitbang_start: + if (spi_imx->devtype_data->has_dmamode) + spi_imx_sdma_exit(spi_imx); out_runtime_pm_put: pm_runtime_dont_use_autosuspend(spi_imx->dev); pm_runtime_put_sync(spi_imx->dev);