lkml.org 
[lkml]   [2020]   [Sep]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v2 6/9] spi: spi-s3c64xx: Check return values
Date
It was <2020-09-02 śro 10:14>, when Sylwester Nawrocki wrote:
> On 9/1/20 17:21, Lukasz Stelmach wrote:
>> It was <2020-08-25 wto 21:06>, when Sylwester Nawrocki wrote:
>>> On 8/21/20 18:13, Łukasz Stelmach wrote:
>>>> Check return values in prepare_dma() and s3c64xx_spi_config() and
>>>> propagate errors upwards.
>>>>
>>>> Signed-off-by: Łukasz Stelmach<l.stelmach@samsung.com>
>>>> ---
>>>> drivers/spi/spi-s3c64xx.c | 47 ++++++++++++++++++++++++++++++++-------
>>>> 1 file changed, 39 insertions(+), 8 deletions(-)
>>>
>>>> @@ -298,12 +299,24 @@ static void prepare_dma(struct s3c64xx_spi_dma_data *dma,
>>>> desc = dmaengine_prep_slave_sg(dma->ch, sgt->sgl, sgt->nents,
>>>> dma->direction, DMA_PREP_INTERRUPT);
>>>> + if (!desc) {
>>>> + dev_err(&sdd->pdev->dev, "unable to prepare %s scatterlist",
>>>> + dma->direction == DMA_DEV_TO_MEM ? "rx" : "tx");
>>>> + return -ENOMEM;
>>>> + }
>>>> desc->callback = s3c64xx_spi_dmacb;
>>>> desc->callback_param = dma;
>>>> dma->cookie = dmaengine_submit(desc);
>>>> + ret = dma_submit_error(dma->cookie);
>>>> + if (ret) {
>>>> + dev_err(&sdd->pdev->dev, "DMA submission failed");
>>>> + return -EIO;
>>>
>>> Just return the error value from dma_submit_error() here?
>>>
>>
>> --8<---------------cut here---------------start------------->8---
>> static inline int dma_submit_error(dma_cookie_t cookie)
>> {
>> return cookie < 0 ? cookie : 0;
>>
>> }
>> --8<---------------cut here---------------end--------------->8---
>>
>> Not quite meaningful IMHO, is it?
>
> dma_submit_error() returns 0 or an error code, I think it makes sense
> to propagate that error code rather than replacing it with -EIO.

It is not an error code that d_s_e() returns it is a value returned by
dma_cookie_assigned() called from within the tx_submit() operaton of a
DMA driver.

--8<---------------cut here---------------start------------->8---
static inline dma_cookie_t dma_cookie_assign(struct
dma_async_tx_descriptor *tx)
{
struct dma_chan *chan = tx->chan;
dma_cookie_t cookie;

cookie = chan->cookie + 1;
if (cookie < DMA_MIN_COOKIE)
cookie = DMA_MIN_COOKIE;
tx->cookie = chan->cookie = cookie;

return cookie;
}
--8<---------------cut here---------------end--------------->8---

Yes, a non-zero value returned by d_s_e() indicates an error but it
definitely isn't one of error codes from errno*.h.

--
Łukasz Stelmach
Samsung R&D Institute Poland
Samsung Electronics
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2020-09-03 10:46    [W:0.061 / U:0.492 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site