lkml.org 
[lkml]   [2014]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RFC PATCH 2/2] lib: devres: Add exec versions of devm_ioremap_resource and friends
From
On Wed, Nov 26, 2014 at 10:14 PM, Dave Gerlach <d-gerlach@ti.com> wrote:
> --- a/lib/devres.c
> +++ b/lib/devres.c
> @@ -72,6 +72,64 @@ void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
> EXPORT_SYMBOL(devm_ioremap_nocache);
>
> /**
> + * devm_ioremap_exec - Managed ioremap_exec()
> + * @dev: Generic device to remap IO address for
> + * @offset: BUS offset to map
> + * @size: Size of map
> + *
> + * Managed ioremap_exec(). Map is automatically unmapped on driver detach.
> + */
> +void __iomem *devm_ioremap_exec(struct device *dev, resource_size_t offset,
> + unsigned long size)
> +{

[...]

> + addr = ioremap_exec(offset, size);

[...]

> +}
> +EXPORT_SYMBOL(devm_ioremap_exec);
> +
> +/**
> + * devm_ioremap_exec_nocache - Managed ioremap_exec_nocache()
> + * @dev: Generic device to remap IO address for
> + * @offset: BUS offset to map
> + * @size: Size of map
> + *
> + * Managed ioremap_exec_nocache(). Map is automatically unmapped on driver
> + * detach.
> + */
> +void __iomem *devm_ioremap_exec_nocache(struct device *dev,
> + resource_size_t offset,
> + unsigned long size)
> +{

[...]

> + addr = ioremap_exec_nocache(offset, size);

[...]

> +}
> +EXPORT_SYMBOL(devm_ioremap_exec_nocache);
> +

Both of these are identical to the already-existing devm_ioremap() and
devm_ioremap_nocache(), except for the call to the underlying
ioremap*() variant.

Can't the variant selection be done by passing a flag around, set by
the top-level inline functions, to avoid code duplication?
Some architecture-specific ioremap() implementations already work that
way, cfr. arch/m68k/include/asm/io_mm.h:

static inline void __iomem *ioremap(unsigned long physaddr, unsigned long size)
{
return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
}
static inline void __iomem *ioremap_nocache(unsigned long physaddr,
unsigned lonn
g size)
{
return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
}
static inline void __iomem *ioremap_writethrough(unsigned long physaddr,
unsigned long size)
{
return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
}
static inline void __iomem *ioremap_fullcache(unsigned long physaddr,
unsigned long size)
{
return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
}

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


\
 
 \ /
  Last update: 2014-11-27 11:21    [W:0.065 / U:0.468 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site