On Mon, May 18, 2015 at 01:24:59PM -0500, wda...@nvidia.com wrote:
> +static inline dma_addr_t dma_map_resource_attrs(struct device *dev,
> +                                             struct resource *res,
> +                                             size_t offset, size_t size,
> +                                             enum dma_data_direction dir,
> +                                             struct dma_attrs *attrs)
> +{
> +     const struct dma_map_ops *ops = get_dma_ops(dev);
> +     dma_addr_t addr = 0;
> +
> +     BUG_ON(!valid_dma_direction(dir));
> +     if (ops->map_resource)
> +             addr = ops->map_resource(dev, res, offset, size, dir,
                > atops->map_resourcetrs);
> +     debug_dma_map_resource(dev, res, offset, size, dir, addr);
> +
> +     return addr;
> +}

Please just do a BUG_ON(ops->map_resource == NULL) instead of checking the
pointer and returning 0 if it is NULL. The 0 could be a valid dma_addr
in some implementations, drivers are supposed to check the returned addr
with dma_mapping_error only (and no '== 0' checks).


        Joerg

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to