From patchwork Wed Jan 16 11:28:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurentiu Tudor X-Patchwork-Id: 10765769 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AF46A13B4 for ; Wed, 16 Jan 2019 11:29:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 995632C6EA for ; Wed, 16 Jan 2019 11:29:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B0472C70C; Wed, 16 Jan 2019 11:29:06 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 303B62C6EA for ; Wed, 16 Jan 2019 11:29:06 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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:In-Reply-To: References:List-Owner; bh=fIBVISq2z74no7Fchikrt3RM8zCqbU3zHyYNhGVqM5Q=; b=C3H Hkc9Yt5jbhLyu1K3q3ZWU9gB5Kq7mVyCU8psaoc9dgOD1Blp7xy3hW1xzhKF0T6OSu41Ww/UeHvDp RG1YDS3wPfBzIQnwvs6iWL3P9Hs5JaJBN4ph6ftDoI/U4HSh88SNEuASd4xJ9k0tA8gQ0sfzjS0F7 Weo92EaVggIstNFwqL1nPd53g56rRdyAjnyGkCI3+ZBOKj1a1n5nRJarUpHU8Xe0Dy9qOfslPFs/m lnvgYkcSbwjCwGGwOv6J2RVg3ZXE/XPQsgE3GheUBMG4TMLXCTQUBYSQNGAH/n+gaqQW06jcE6MC2 G7CCuUDI1StgRUArvlvBCnrbovUJ8TQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gjjNW-0004Kx-Si; Wed, 16 Jan 2019 11:29:02 +0000 Received: from inva021.nxp.com ([92.121.34.21]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gjjNU-0004KS-3m for linux-arm-kernel@lists.infradead.org; Wed, 16 Jan 2019 11:29:01 +0000 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 487B320001D; Wed, 16 Jan 2019 12:28:58 +0100 (CET) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 3BCEB200018; Wed, 16 Jan 2019 12:28:58 +0100 (CET) Received: from fsr-ub1864-101.ea.freescale.net (fsr-ub1864-101.ea.freescale.net [10.171.82.46]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 9555D2060F; Wed, 16 Jan 2019 12:28:57 +0100 (CET) From: Laurentiu Tudor To: linux-i2c@vger.kernel.org, linux-imx@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, wsa@the-dreams.de Subject: [PATCH v2 1/2] i2c: imx: fix dma_request_chan error handling Date: Wed, 16 Jan 2019 13:28:54 +0200 Message-Id: <20190116112855.13824-1-laurentiu.tudor@nxp.com> X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190116_032900_290865_5D9DCC40 X-CRM114-Status: GOOD ( 10.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fabio.estevam@nxp.com, Laurentiu Tudor , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, leoyang.li@nxp.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Use the correct error pointer when extracting the error code. Fixes: ea1e5f176e97 ("i2c: imx: notify about real errors on dma i2c_imx_dma_request") Signed-off-by: Laurentiu Tudor Reviewed-by: Uwe Kleine-König --- drivers/i2c/busses/i2c-imx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 09b124547669..42fed40198a0 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -287,7 +287,7 @@ static int i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx, dma->chan_tx = dma_request_chan(dev, "tx"); if (IS_ERR(dma->chan_tx)) { - ret = PTR_ERR(dma->chan_rx); + ret = PTR_ERR(dma->chan_tx); if (ret != -ENODEV && ret != -EPROBE_DEFER) dev_err(dev, "can't request DMA tx channel (%d)\n", ret); goto fail_al; From patchwork Wed Jan 16 11:28:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurentiu Tudor X-Patchwork-Id: 10765771 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 900B1139A for ; Wed, 16 Jan 2019 11:29:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D4E82CBAD for ; Wed, 16 Jan 2019 11:29:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70CD62CE4E; Wed, 16 Jan 2019 11:29:38 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 08E412CBAD for ; Wed, 16 Jan 2019 11:29:37 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=HIp0IGsVUOmZXsGCMfsHHj3mp4Vhn63lx9hKLSbgCfw=; b=GPa13xOLo1yR2R65EhTjWt9S5o 2wVzNQXDh8GJdN6LgVZQTIcWpTBPA1uY/vSGhnY2kYHyFSXwdeeQ2NWL5q4j8458eiXywNdHSHMeK CcyIF1TPY3F5RqSkQUzwqVywILZsmX+I1q/puB48s1jdliZ1r3gyKHPvWnQ51tOjTDiw7DPGzhxER 6ANQlmeRm6ybv1AVOGHH/81PZ2Uu3xX7XC7L/dKy1EYchxa9lwBLRXNJj3Be8CZkld4VPUWbMlakN cdPNq3QJUKANRlUECuwEmJxhfodgPZbRKlFqtM8vRBE4br85CcuoW8RhiHPkZ72ES8uYqnDhm2fG0 CTWMIb8A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gjjO3-0004bq-9n; Wed, 16 Jan 2019 11:29:35 +0000 Received: from inva021.nxp.com ([92.121.34.21]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gjjNz-0004bR-VO for linux-arm-kernel@lists.infradead.org; Wed, 16 Jan 2019 11:29:33 +0000 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 847BB2000BB; Wed, 16 Jan 2019 12:29:30 +0100 (CET) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 77A3C200046; Wed, 16 Jan 2019 12:29:30 +0100 (CET) Received: from fsr-ub1864-101.ea.freescale.net (fsr-ub1864-101.ea.freescale.net [10.171.82.46]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id DAC532060F; Wed, 16 Jan 2019 12:29:29 +0100 (CET) From: Laurentiu Tudor To: linux-i2c@vger.kernel.org, linux-imx@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, wsa@the-dreams.de Subject: [PATCH v2 2/2] i2c: imx: defer probing on dma channel request Date: Wed, 16 Jan 2019 13:28:55 +0200 Message-Id: <20190116112855.13824-2-laurentiu.tudor@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190116112855.13824-1-laurentiu.tudor@nxp.com> References: <20190116112855.13824-1-laurentiu.tudor@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190116_032932_197005_2E3B32BC X-CRM114-Status: GOOD ( 11.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fabio.estevam@nxp.com, Laurentiu Tudor , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, leoyang.li@nxp.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If the dma controller is not yet probed, defer i2c probe. The error path in probe was slightly modified (no functional change) to avoid triggering this WARN_ON(): "cg-pll0-div1 already disabled WARNING: CPU: 1 PID: 1 at drivers/clk/clk.c:828 clk_core_disable+0xa8/0xb0" Signed-off-by: Laurentiu Tudor --- Changes in v2: - rebased on latest i2c tree - fix small error introduced by a previous commit (first patch) drivers/i2c/busses/i2c-imx.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 42fed40198a0..4e34b1572756 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -1111,7 +1111,8 @@ static int i2c_imx_probe(struct platform_device *pdev) pdev->name, i2c_imx); if (ret) { dev_err(&pdev->dev, "can't claim irq %d\n", irq); - goto clk_disable; + clk_disable_unprepare(i2c_imx->clk); + return ret; } /* Init queue */ @@ -1161,19 +1162,25 @@ static int i2c_imx_probe(struct platform_device *pdev) pm_runtime_mark_last_busy(&pdev->dev); pm_runtime_put_autosuspend(&pdev->dev); + /* Init DMA config if supported */ + ret = i2c_imx_dma_request(i2c_imx, phy_addr); + if (ret) { + if (ret != -EPROBE_DEFER) + dev_info(&pdev->dev, "can't use DMA, using PIO instead.\n"); + else + goto del_adapter; + } + dev_dbg(&i2c_imx->adapter.dev, "claimed irq %d\n", irq); dev_dbg(&i2c_imx->adapter.dev, "device resources: %pR\n", res); dev_dbg(&i2c_imx->adapter.dev, "adapter name: \"%s\"\n", i2c_imx->adapter.name); - /* Init DMA config if supported */ - ret = i2c_imx_dma_request(i2c_imx, phy_addr); - if (ret < 0) - goto clk_notifier_unregister; - dev_info(&i2c_imx->adapter.dev, "IMX I2C adapter registered\n"); return 0; /* Return OK */ +del_adapter: + i2c_del_adapter(&i2c_imx->adapter); clk_notifier_unregister: clk_notifier_unregister(i2c_imx->clk, &i2c_imx->clk_change_nb); rpm_disable: @@ -1182,8 +1189,6 @@ static int i2c_imx_probe(struct platform_device *pdev) pm_runtime_set_suspended(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev); -clk_disable: - clk_disable_unprepare(i2c_imx->clk); return ret; }