[RFC PATCH 2/2] lib: devres: Add exec versions of devm_ioremap_resource and friends

Geert Uytterhoeven geert at linux-m68k.org
Thu Nov 27 01:41:23 PST 2014


On Wed, Nov 26, 2014 at 10:14 PM, Dave Gerlach <d-gerlach at 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 at 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



More information about the linux-arm-kernel mailing list