From patchwork Mon Mar 25 15:30:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurentiu Tudor X-Patchwork-Id: 10869517 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 78EAF1390 for ; Mon, 25 Mar 2019 15:31:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CD5B26E3C for ; Mon, 25 Mar 2019 15:31:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5AD4E294B1; Mon, 25 Mar 2019 15:31:31 +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 04E1A26E3C for ; Mon, 25 Mar 2019 15:31:30 +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=Z8/DK4r+xM16ODmpeCtJCkRlarofRDtZpHnK0G2lgPA=; b=TLU ZaskWKaFUPqzHib3lfjV8B4RfzTM+uKaQSE/wbATT1WUVv+W7TE3MK99AoNBgc8u1saDbR9Ftdbyt dng4CdSVHxjUlujGjwjMTgDhtl8NjYfxNF1m46pIaOBpmtsbwOKlLLoy8C9W555rrK8RVHaTlC071 UjJkVxm4a0xaHpKYg6RYt6gA2zs/xNEDQCoGOjBIlDWfGFc9HXvmLMCoqkJKigxOXGX2lZoYHti51 /Lnho+davQ5IzpLdMEwVM8sk2a7F16ILf3mTSeWg/Vuah/G2ZKZEVqQiC81/m4VyQuQFT7nlXiFS6 7gfWcK2PxzyN+HAuVDGqmBGJjYTDYLg==; 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 1h8RZL-0000aM-Ex; Mon, 25 Mar 2019 15:31:23 +0000 Received: from inva020.nxp.com ([92.121.34.13]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8RYR-0007OX-Oa for linux-arm-kernel@lists.infradead.org; Mon, 25 Mar 2019 15:30:36 +0000 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id EC3391A00DE; Mon, 25 Mar 2019 16:30:20 +0100 (CET) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id E000B1A00DD; Mon, 25 Mar 2019 16:30:20 +0100 (CET) Received: from fsr-ub1864-101.ea.freescale.net (fsr-ub1864-101.ea.freescale.net [10.171.74.120]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 5F67A205D8; Mon, 25 Mar 2019 16:30:20 +0100 (CET) From: laurentiu.tudor@nxp.com To: linux-i2c@vger.kernel.org, ying.zhang22455@nxp.com Subject: [RESEND] i2c: imx: defer probing on dma channel request Date: Mon, 25 Mar 2019 17:30:16 +0200 Message-Id: <20190325153016.12626-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-20190325_083029_215362_726E907B X-CRM114-Status: GOOD ( 10.36 ) 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: upstream-release@linux.nxdi.nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de, linux-kernel@vger.kernel.org, leoyang.li@nxp.com, linux-imx@nxp.com, kernel@pengutronix.de, festevam@gmail.com, linux-arm-kernel@lists.infradead.org, Laurentiu Tudor 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 From: Laurentiu Tudor 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 --- 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; }