Re: [PATCH 2/5] dma-mapping: Add devm_ interface for dma_map_single()

From: Tejun Heo
Date: Mon May 19 2014 - 16:17:21 EST


Hello, Eli.

On Sat, May 17, 2014 at 03:19:21PM +0300, Eli Billauer wrote:
> >>+ if (dma_mapping_error(dev, dma_handle)) {
> >>+ devres_free(dr);
> >>+ return 0;
> >Can't we just keep returning dma_handle? Even if that means invoking
> >->mapping_error() twice? It's yucky to have subtly different error
> >return especially because in most cases it won't fail.
> Yucky it is indeed. There are however two problems with keeping the existing
> API:
>
> * What to do if devres_alloc() fails. How do I signal back an error? The
> only way I can think of is returning zero. But if the caller should know
> that zero means failure, I've already broken the API. I might as well return
> zero for any kind of failure.

What can't it just do the following?

if (dma_mapping_error(dev, dma_handle)) {
devres_free(dr);
return dma_handle;
}

The caller would have to invoke dma_mapping_error() again but is that
a problem?

Thanks.

--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/