lkml.org 
[lkml]   [2011]   [Jul]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v2] new helper to define common struct resource constructs
    Date
    resource definitions that just define start, end and flags =
    IORESOURCE_MEM or IORESOURCE_IRQ (with start=end) are quite common. So
    introduce a shortcut for them. For completeness add macros for
    IORESOURCE_DMA and IORESOURCE_IO, too and also make available a set of
    macros to specify named resources of all types.

    Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    ---
    changes since v1:
    - also add _IO and _DMA variants

    include/linux/ioport.h | 30 ++++++++++++++++++++++++++++++
    1 files changed, 30 insertions(+), 0 deletions(-)

    diff --git a/include/linux/ioport.h b/include/linux/ioport.h
    index 63eb429..f98124f 100644
    --- a/include/linux/ioport.h
    +++ b/include/linux/ioport.h
    @@ -109,6 +109,36 @@ struct resource_list {
    /* PCI control bits. Shares IORESOURCE_BITS with above PCI ROM. */
    #define IORESOURCE_PCI_FIXED (1<<4) /* Do not move resource */

    +
    +/* helpers to define resources */
    +#define DEFINE_RES_NAMED(_start, _size, _name, _flags) \
    + { \
    + .start = _start, \
    + .end = _start + _size - 1, \
    + .name = _name, \
    + .flags = _flags, \
    + }
    +
    +#define DEFINE_RES_IO_NAMED(_start, _size, _name) \
    + DEFINE_RES_NAMED(_start, _size, _name, IORESOURCE_IO)
    +#define DEFINE_RES_IO(_start, _size) \
    + DEFINE_RES_IO_NAMED(_start, _size, NULL)
    +
    +#define DEFINE_RES_MEM_NAMED(_start, _size, _name) \
    + DEFINE_RES_NAMED(_start, _size, _name, IORESOURCE_MEM)
    +#define DEFINE_RES_MEM(_start, _size) \
    + DEFINE_RES_MEM_NAMED(_start, _size, NULL)
    +
    +#define DEFINE_RES_IRQ_NAMED(_irq, _name) \
    + DEFINE_RES_NAMED(_irq, 1, _name, IORESOURCE_IRQ)
    +#define DEFINE_RES_IRQ(_irq) \
    + DEFINE_RES_IRQ_NAMED(_irq, NULL)
    +
    +#define DEFINE_RES_DMA_NAMED(_dma, _name) \
    + DEFINE_RES_NAMED(_dma, 1, _name, IORESOURCE_DMA)
    +#define DEFINE_RES_DMA(_dma) \
    + DEFINE_RES_DMA_NAMED(_dma, NULL)
    +
    /* PC/ISA/whatever - the normal PC address spaces: IO and memory */
    extern struct resource ioport_resource;
    extern struct resource iomem_resource;
    --
    1.7.5.4
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2011-07-12 20:33    [W:0.025 / U:20.332 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site