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

From: Tejun Heo
Date: Fri May 16 2014 - 17:08:15 EST


Hello,

On Fri, May 16, 2014 at 11:26:36AM +0300, Eli Billauer wrote:
> +dma_addr_t dmam_map_single(struct device *dev, void *ptr, size_t size,
> + enum dma_data_direction direction)
> +
> +{
> + struct dma_devres *dr;
> + dma_addr_t dma_handle;
> +
> + dr = devres_alloc(dmam_map_single_release, sizeof(*dr), GFP_KERNEL);
> + if (!dr)
> + return 0;
> +
> + dma_handle = dma_map_single(dev, ptr, size, direction);

Don't we wanna map the underlying operation - dma_map_single_attrs() -
instead?

> + 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.

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/