From patchwork Tue Jul 12 18:31:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 104418 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 55AF8B6F68 for ; Wed, 13 Jul 2011 04:32:18 +1000 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QghkZ-0003Hz-C5; Tue, 12 Jul 2011 18:32:03 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QghkY-0003uA-Qq; Tue, 12 Jul 2011 18:32:02 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qghk8-0003qi-IH for linux-mtd@lists.infradead.org; Tue, 12 Jul 2011 18:31:41 +0000 Received: from octopus.hi.pengutronix.de ([2001:6f8:1178:2:215:17ff:fe12:23b0]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Qghk0-00075v-PV; Tue, 12 Jul 2011 20:31:28 +0200 Received: from ukl by octopus.hi.pengutronix.de with local (Exim 4.76) (envelope-from ) id 1Qghjx-0005qv-Cv; Tue, 12 Jul 2011 20:31:25 +0200 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2] new helper to define common struct resource constructs Date: Tue, 12 Jul 2011 20:31:15 +0200 Message-Id: <1310495475-22469-1-git-send-email-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: References: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:6f8:1178:2:215:17ff:fe12:23b0 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-mtd@lists.infradead.org X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110712_143137_031507_F8E94D5A X-CRM114-Status: GOOD ( 16.26 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: Arnd Bergmann , Sascha Hauer , linux-kernel@vger.kernel.org, Wolfram Sang , thierry.nolf.barco@gmail.com, Huang Shijie , linux-mtd@lists.infradead.org, H Hartley Sweeten , Andrew Morton , =?UTF-8?q?Lothar=20Wa=C3=9Fmann?= X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.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. Signed-off-by: Uwe Kleine-König --- 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;