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

2014-05-20 Thread Tejun Heo
Hello, On Tue, May 20, 2014 at 08:54:09AM +0300, Eli Billauer wrote: > That seems OK to me, but the problem I'm concerned with is this: In > devm_get_free_pages() it says > > devres = devres_alloc(devm_pages_release, > sizeof(struct pages_devres), GFP_KERNEL); > if

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

2014-05-20 Thread Eli Billauer
Hello, Tejun. On 19/05/14 23:17, Tejun Heo wrote: 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

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

2014-05-20 Thread Eli Billauer
Hello, Tejun. On 19/05/14 23:17, Tejun Heo wrote: 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

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

2014-05-20 Thread Tejun Heo
Hello, On Tue, May 20, 2014 at 08:54:09AM +0300, Eli Billauer wrote: That seems OK to me, but the problem I'm concerned with is this: In devm_get_free_pages() it says devres = devres_alloc(devm_pages_release, sizeof(struct pages_devres), GFP_KERNEL); if

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

2014-05-19 Thread Tejun Heo
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

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

2014-05-19 Thread Tejun Heo
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

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

2014-05-17 Thread Eli Billauer
Hello Tejun, On 17/05/14 00:08, Tejun Heo wrote: Don't we wanna map the underlying operation - dma_map_single_attrs() - instead? I'll resubmit this patch promptly, with a follow-up patch for the diff to implement dmam_map_single_attrs() instead. Plus a define-statement for

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

2014-05-17 Thread Eli Billauer
Hello Tejun, On 17/05/14 00:08, Tejun Heo wrote: Don't we wanna map the underlying operation - dma_map_single_attrs() - instead? I'll resubmit this patch promptly, with a follow-up patch for the diff to implement dmam_map_single_attrs() instead. Plus a define-statement for

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

2014-05-16 Thread Tejun Heo
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 =

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

2014-05-16 Thread Eli Billauer
dmam_map_single() and dmam_unmap_single() are the managed counterparts for the respective dma_* functions. Note that dmam_map_single() returns zero on failure, and not a value to be handled by dma_mapping_error(): The error check is done by dmam_map_single() to avoid the registration of a mapping

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

2014-05-16 Thread Eli Billauer
dmam_map_single() and dmam_unmap_single() are the managed counterparts for the respective dma_* functions. Note that dmam_map_single() returns zero on failure, and not a value to be handled by dma_mapping_error(): The error check is done by dmam_map_single() to avoid the registration of a mapping

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

2014-05-16 Thread Tejun Heo
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 =