From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753359AbcLGC2M (ORCPT ); Tue, 6 Dec 2016 21:28:12 -0500 Received: from vern.gendns.com ([206.190.152.46]:44982 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751722AbcLGC2L (ORCPT ); Tue, 6 Dec 2016 21:28:11 -0500 Subject: Re: [PATCH] spi: davinci: Allow device tree devices to use DMA To: Sekhar Nori , Mark Brown References: <1479530464-12538-1-git-send-email-david@lechnology.com> <79f186b5-ac71-189f-c19f-977670395043@ti.com> <946d60bc-ac14-7934-c1b3-e2de03831459@lechnology.com> Cc: khilman@kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org From: David Lechner Message-ID: <588633b2-99c2-528f-35f4-fef898a79961@lechnology.com> Date: Tue, 6 Dec 2016 20:28:10 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/21/2016 02:37 AM, Sekhar Nori wrote: > On Sunday 20 November 2016 10:31 PM, David Lechner wrote: > >> On 11/20/2016 06:59 AM, Sekhar Nori wrote: > >>> On Saturday 19 November 2016 10:11 AM, David Lechner wrote: > >>>> @@ -400,6 +401,9 @@ static int davinci_spi_of_setup(struct spi_device >>>> *spi) >>>> if (!of_property_read_u32(np, "ti,spi-wdelay", &prop)) >>>> spicfg->wdelay = (u8)prop; >>>> spi->controller_data = spicfg; >>>> + /* Use DMA for device if master supports it */ >>>> + if (dspi->dma_rx) >>> >>> This should be >>> >>> if (!(IS_ERR(dpsi->dma_rx) || IS_ERR(dspi->dma_tx)) >> >> >> There is the following code in davinci_spi_probe(): >> >> ret = davinci_spi_request_dma(dspi); >> if (ret == -EPROBE_DEFER) { >> goto free_clk; >> } else if (ret) { >> dev_info(&pdev->dev, "DMA is not supported (%d)\n", ret); >> dspi->dma_rx = NULL; >> dspi->dma_tx = NULL; >> } >> >> So, I does not look like it is possible to get anything other than NULL >> or a valid pointer for dpsi->dma_rx and that checking dpsi->dma_tx is >> not necessary. >> >> So, I think if (dspi->dma_rx) is sufficient. In fact the same check is >> used during unwinding if the probe function fails. > > You are right, I see it now. Setting dma_rx to NULL overriding the error > value is confusing since dma_request_chan() itself does not use NULL as > an error value. > > I think it is better to fix the existing code to remove the NULL > overwrite and use IS_ERR() instead. You should probably wait for some > feedback from the SPI maintainer though. > > Thanks, > Sekhar > There don't seem to be any further comments. Using NULL here makes more sense to me, so I am inclined to leave this patch as-is.