From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] new helper to define common struct resource constructs
Date: Mon, 11 Jul 2011 16:40:15 +0200 [thread overview]
Message-ID: <E1QgHeh-0004k8-2m@octopus.hi.pengutronix.de> (raw)
In-Reply-To: <201107072304.05626.arnd@arndb.de>
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. Also make available a macro to specify named resources of both
types which are less common.
Signed-off-by: Uwe Kleine-K??nig <u.kleine-koenig@pengutronix.de>
---
Hello,
On Thu, 7 Jul 2011 23:04:05 +0200, Arnd Bergmann <arnd@arndb.de> wrote:
> On Thursday 07 July 2011 22:48:33 Uwe Kleine-K??nig wrote:
> > My thoughts on this is that it should better go to where struct resource
> > is defined (<linux/ioports.h>, as Arndt suggested) but then probably a
> > bit more generic as:
> >
> > #define RES_MEM_NAMED(_start, _end, _name) \
> > { \
> > .start = _start, \
> > .end = _end, \
> > .name = _name, \
> > .flags = IORESOURCE_MEM, \
> > }
> > #define RES_MEM(_start, _end) \
> > RES_MEM_NAMED(_start, _end, NULL)
> >
> > (Maybe alternatively take a _size parameter instead of _end?)
> > While this makes the repetition shorter, it's still there.
> >
>
> This sounds reasonable, and I'd also prefer the size instead of end
> argument here. If you prepare a patch to do this, I can ack it for you.
Did that now. In reply to this mail I'll send a patch that converts
arch/arm/plat-mxc/devices to these new helpers which saves ~200 lines.
BTW, this bases on next-20110707. I will coordinate with Sascha and
rebase the follow-up patch accordingly when this one got in.
Best regards
Uwe
include/linux/ioport.h | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 63eb429..6d493a1 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -109,6 +109,26 @@ 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_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)
+
/* 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
--
Pengutronix e.K. | Uwe Kleine-K??nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
next prev parent reply other threads:[~2011-07-11 14:40 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 ` Uwe Kleine-König [this message]
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 ` [PATCH v3] " Uwe Kleine-König
2011-07-14 11:34 ` 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=E1QgHeh-0004k8-2m@octopus.hi.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).