lkml.org 
[lkml]   [2019]   [May]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 2/3] usb: host: ohci-sm501: init genalloc for local memory
On Thu, May 16, 2019 at 02:47:20PM +0300, laurentiu.tudor@nxp.com wrote:
> + hcd->localmem_pool = devm_gen_pool_create(dev, PAGE_SHIFT,
> + dev_to_node(dev),
> + "ohci-sm501");
> + if (IS_ERR(hcd->localmem_pool)) {
> + retval = PTR_ERR(hcd->localmem_pool);
> + goto err5;
> + }
> +
> + local_mem = devm_ioremap(dev, mem->start, resource_size(mem));
> + if (!local_mem) {
> + retval = -ENOMEM;
> + goto err5;
> + }
> +
> + retval = gen_pool_add_virt(hcd->localmem_pool,
> + (unsigned long)local_mem,
> + mem->start - mem->parent->start,
> + resource_size(mem),
> + dev_to_node(dev));

I wonder if having a helper for these operations would be useful,
explaining what we do here. That is create a pool for a resource,
where the virtual address is the ioremap of said resource. We
could also make that a managed API so that you can get rid of the
cleanup path.

\
 
 \ /
  Last update: 2019-05-21 12:41    [W:0.076 / U:16.352 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site