Re: [PATCH 3/3] spi: rockchip: check requesting dma channel with EPROBE_DEFER

From: Dan Carpenter
Date: Tue Mar 22 2016 - 08:00:53 EST


On Mon, Mar 21, 2016 at 04:33:32PM -0700, Doug Anderson wrote:
> Presumably Dan would be happy if you just add this right after the dev_warn():
> rs->dma_tx.ch = NULL;
>

Yes. Thanks.

> Presumably from Dan's email it would also be wise to make sure you
> don't pass NULL to PTR_ERR, which you could probably do by just using
> ERR_PTR instead of PTR_ERR. I think you could structure like this:
>
> rs->dma_tx.ch = dma_request_slave_channel(rs->dev, "tx");
> - if (!rs->dma_tx.ch)
> + if (IS_ERR_OR_NULL(rs->dma_tx.ch)) {
> + /* Check tx to see if we need defer probing driver */
> + if (rs->dma_tx.ch == ERR_PTR(-EPROBE_DEFER)) {
> + ret = -EPROBE_DEFER;
> + goto err_get_fifo_len;
> + }
> dev_warn(rs->dev, "Failed to request TX DMA channel\n");
> + rs->dma_tx.ch = NULL;
> + }

My check doesn't care if you pass something to PTR_ERR() that might be
NULL, it complains when PTR_ERR() can only be zero. And it's ok to have
the warning for a while and silence it in another patch when we update
dma_request_slave_channel().

But this also works well.

regards,
dan carpenter