linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3] new helper to define common struct resource constructs
Date: Thu, 14 Jul 2011 10:11:05 +0200	[thread overview]
Message-ID: <1310631065-4271-1-git-send-email-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <20110713141849.b8cbf675.akpm@linux-foundation.org>

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 which are less common.

Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
changes since v2:
- add parentheses around macro parameter usages

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..9d57a71 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

  parent reply	other threads:[~2011-07-14  8:11 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-30 16:12 reply: [PATCH v5 1/3] ARM: mxs: add GPMI-NFC support for imx23/imx28 Huang Shijie-B32955
2011-06-30 22:29 ` Arnd Bergmann
2011-07-01  6:44   ` Uwe Kleine-König
2011-07-01  8:57   ` Huang Shijie
2011-07-01  9:09     ` Arnd Bergmann
2011-07-07  8:56       ` Huang Shijie
2011-07-07 15:57         ` Arnd Bergmann
2011-07-07 20:48           ` reply: [PATCH v5 1/3] ARM: mxs: add GPMI-NFC support for?imx23/imx28 Uwe Kleine-König
2011-07-07 21:04             ` Arnd Bergmann
2011-07-11 14:40               ` [PATCH] new helper to define common struct resource constructs Uwe Kleine-König
2011-07-11 15:03                 ` [PATCH] ARM: mxc: use new helpers to define common struct resource entries Uwe Kleine-König
2011-07-12 13:29                 ` [PATCH] new helper to define common struct resource constructs Arnd Bergmann
2011-07-12 17:13                   ` H Hartley Sweeten
2011-07-12 18:31                     ` [PATCH v2] " Uwe Kleine-König
2011-07-13 21:18                   ` [PATCH] " Andrew Morton
2011-07-13 21:42                     ` Arnd Bergmann
2011-07-13 22:15                       ` H Hartley Sweeten
2011-07-14  8:11                     ` Uwe Kleine-König [this message]
2011-07-14 11:34                       ` [PATCH v3] " Lothar Waßmann
2011-07-01 14:52     ` reply: [PATCH v5 1/3] ARM: mxs: add GPMI-NFC support for imx23/imx28 Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1310631065-4271-1-git-send-email-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).