From patchwork Fri Nov 14 13:47:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ludovic Desroches X-Patchwork-Id: 5306641 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 818E7C11AC for ; Fri, 14 Nov 2014 13:50:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AB8E020142 for ; Fri, 14 Nov 2014 13:50:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4692B200F4 for ; Fri, 14 Nov 2014 13:50:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XpHEk-00078a-7l; Fri, 14 Nov 2014 13:48:30 +0000 Received: from eusmtp01.atmel.com ([212.144.249.243]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XpHEg-00073Q-QN for linux-arm-kernel@lists.infradead.org; Fri, 14 Nov 2014 13:48:27 +0000 Received: from ibiza.corp.atmel.com (10.161.101.13) by eusmtp01.atmel.com (10.161.101.31) with Microsoft SMTP Server id 14.2.347.0; Fri, 14 Nov 2014 14:47:57 +0100 From: Ludovic Desroches To: , Subject: [PATCH] i2c: at91: introduce probe deferring Date: Fri, 14 Nov 2014 14:47:59 +0100 Message-ID: <1415972879-26509-1-git-send-email-ludovic.desroches@atmel.com> X-Mailer: git-send-email 2.0.3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141114_054827_019513_94C3ECA4 X-CRM114-Status: GOOD ( 11.39 ) X-Spam-Score: -0.0 (/) Cc: Ludovic Desroches , nicolas.ferre@atmel.com, wsa@the-dreams.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Return probe defer if requesting a dma channel without a dma controller probed. Signed-off-by: Ludovic Desroches --- drivers/i2c/busses/i2c-at91.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c index 77fb647..df3f4c4 100644 --- a/drivers/i2c/busses/i2c-at91.c +++ b/drivers/i2c/busses/i2c-at91.c @@ -679,14 +679,21 @@ static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr) dma_cap_zero(mask); dma_cap_set(DMA_SLAVE, mask); - dma->chan_tx = dma_request_slave_channel_compat(mask, filter, pdata, - dev->dev, "tx"); - if (!dma->chan_tx) { + dma->chan_tx = dma_request_slave_channel_reason(dev->dev, "tx"); + if (IS_ERR(dma->chan_tx)) { + ret = PTR_ERR(dma->chan_tx); + if (ret == -EPROBE_DEFER) { + dev_warn(dev->dev, "no DMA channel available at the moment\n"); + return ret; + } dev_err(dev->dev, "can't get a DMA channel for tx\n"); - ret = -EBUSY; goto error; } + /* + * No reason to check EPROBE_DEFER here since we have already request + * tx channel. If it fails here, it's for another reason. + */ dma->chan_rx = dma_request_slave_channel_compat(mask, filter, pdata, dev->dev, "rx"); if (!dma->chan_rx) { @@ -722,7 +729,7 @@ error: dev_info(dev->dev, "can't use DMA\n"); if (dma->chan_rx) dma_release_channel(dma->chan_rx); - if (dma->chan_tx) + if (!IS_ERR(dma->chan_tx)) dma_release_channel(dma->chan_tx); return ret; } @@ -788,8 +795,11 @@ static int at91_twi_probe(struct platform_device *pdev) clk_prepare_enable(dev->clk); if (dev->pdata->has_dma_support) { - if (at91_twi_configure_dma(dev, phy_addr) == 0) + rc = at91_twi_configure_dma(dev, phy_addr); + if (rc == 0) dev->use_dma = true; + else if (rc == -EPROBE_DEFER) + return rc; } rc = of_property_read_u32(dev->dev->of_node, "clock-frequency",