From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 05/12] resource: introduce add_generic_device_res to add multiple resource
Date: Mon, 19 Sep 2011 14:15:42 +0200 [thread overview]
Message-ID: <1316434549-15243-5-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1316434549-15243-1-git-send-email-plagnioj@jcrosoft.com>
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
drivers/base/resource.c | 67 ++++++++++++++++++++++++----------------------
include/driver.h | 7 +++++
2 files changed, 42 insertions(+), 32 deletions(-)
diff --git a/drivers/base/resource.c b/drivers/base/resource.c
index 175beb9..f6c429f 100644
--- a/drivers/base/resource.c
+++ b/drivers/base/resource.c
@@ -41,33 +41,42 @@ struct device_d *add_generic_device(const char* devname, int id, const char *res
resource_size_t start, resource_size_t size, unsigned int flags,
void *pdata)
{
+ struct resource *res;
+
+ res = xzalloc(sizeof(struct resource));
+ if (resname)
+ res[0].name = xstrdup(resname);
+ res[0].start = start;
+ res[0].size = size;
+ res[0].flags = flags;
+
+ return add_generic_device_res(devname, id, res, 1, pdata);
+}
+EXPORT_SYMBOL(add_generic_device);
+
+struct device_d *add_generic_device_res(const char* devname, int id,
+ struct resource *res, int nb, void *pdata)
+{
struct device_d *dev;
dev = alloc_device(devname, id, pdata);
- dev->resource = xzalloc(sizeof(struct resource));
- dev->num_resources = 1;
- if (resname)
- dev->resource[0].name = xstrdup(resname);
- dev->resource[0].start = start;
- dev->resource[0].size = size;
- dev->resource[0].flags = flags;
+ dev->resource = res;
+ dev->num_resources = nb;
register_device(dev);
return dev;
}
-EXPORT_SYMBOL(add_generic_device);
+EXPORT_SYMBOL(add_generic_device_res);
#ifdef CONFIG_DRIVER_NET_DM9000
struct device_d *add_dm9000_device(int id, resource_size_t base,
resource_size_t data, int flags, void *pdata)
{
- struct device_d *dev;
+ struct resource *res;
resource_size_t size;
- dev = alloc_device("dm9000", id, pdata);
- dev->resource = xzalloc(sizeof(struct resource) * 2);
- dev->num_resources = 2;
+ res = xzalloc(sizeof(struct resource) * 2);
switch (flags) {
case IORESOURCE_MEM_32BIT:
@@ -84,16 +93,14 @@ struct device_d *add_dm9000_device(int id, resource_size_t base,
return NULL;
}
- dev->resource[0].start = base;
- dev->resource[0].size = size;
- dev->resource[0].flags = IORESOURCE_MEM | flags;
- dev->resource[1].start = data;
- dev->resource[1].size = size;
- dev->resource[1].flags = IORESOURCE_MEM | flags;
-
- register_device(dev);
+ res[0].start = base;
+ res[0].size = size;
+ res[0].flags = IORESOURCE_MEM | flags;
+ res[1].start = data;
+ res[1].size = size;
+ res[1].flags = IORESOURCE_MEM | flags;
- return dev;
+ return add_generic_device_res("dm9000", id, res, 2, pdata);
}
EXPORT_SYMBOL(add_dm9000_device);
#endif
@@ -102,19 +109,15 @@ EXPORT_SYMBOL(add_dm9000_device);
struct device_d *add_usb_ehci_device(int id, resource_size_t hccr,
resource_size_t hcor, void *pdata)
{
- struct device_d *dev;
-
- dev = alloc_device("ehci", id, pdata);
- dev->resource = xzalloc(sizeof(struct resource) * 2);
- dev->num_resources = 2;
- dev->resource[0].start = hccr;
- dev->resource[0].flags = IORESOURCE_MEM;
- dev->resource[1].start = hcor;
- dev->resource[1].flags = IORESOURCE_MEM;
+ resource_size_t *res;
- register_device(dev);
+ res = xzalloc(sizeof(struct resource) * 2);
+ res[0].start = hccr;
+ res[0].flags = IORESOURCE_MEM;
+ res[1].start = hcor;
+ res[1].flags = IORESOURCE_MEM;
- return dev;
+ return add_generic_device_res("ehci", id, res, 2, pdata);
}
EXPORT_SYMBOL(add_usb_ehci_device);
#endif
diff --git a/include/driver.h b/include/driver.h
index e9ac727..80de0c8 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -205,6 +205,13 @@ struct device_d *add_generic_device(const char* devname, int id, const char *res
void *pdata);
/*
+ * register a generic device
+ * with multiple resources
+ */
+struct device_d *add_generic_device_res(const char* devname, int id,
+ struct resource *res, int nb, void *pdata);
+
+/*
* register a memory device
*/
static inline struct device_d *add_mem_device(const char *name, resource_size_t start,
--
1.7.5.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2011-09-19 12:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-19 12:15 [PATCH 01/12 v2] arm: export arch_number to env Jean-Christophe PLAGNIOL-VILLARD
2011-09-19 12:15 ` [PATCH 02/12] at91: fix cpu clock speed display Jean-Christophe PLAGNIOL-VILLARD
2011-09-19 12:15 ` [PATCH 03/12] at91: Fix uhpck clock rate in upll case Jean-Christophe PLAGNIOL-VILLARD
2011-09-19 12:15 ` [PATCH 04/12] at91/boards: switch to software ecc as in linux kernel Jean-Christophe PLAGNIOL-VILLARD
2011-09-19 12:15 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2011-09-19 12:15 ` [PATCH 06/12] at91: nand switch ecc base to resource Jean-Christophe PLAGNIOL-VILLARD
2011-09-19 12:15 ` [PATCH 07/12] usb/core: make print dev like linux lsusb Jean-Christophe PLAGNIOL-VILLARD
2011-09-19 12:15 ` [PATCH 08/12] usb: honour timeout fields Jean-Christophe PLAGNIOL-VILLARD
2011-09-19 12:15 ` [PATCH 09/12] initial ohci support Jean-Christophe PLAGNIOL-VILLARD
2011-09-19 12:15 ` [PATCH 10/12] at91: add " Jean-Christophe PLAGNIOL-VILLARD
2011-09-19 13:05 ` Hubert Feurstein
2011-09-19 12:15 ` [PATCH 11/12] at91: add Calao USB-A960 and USB-A9G20 C01 & C11 board support Jean-Christophe PLAGNIOL-VILLARD
2011-09-19 12:15 ` [PATCH 12/12] at91: add Calao USB-A9263 Jean-Christophe PLAGNIOL-VILLARD
2011-09-20 19:13 ` [PATCH 01/12 v2] arm: export arch_number to env Sascha Hauer
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=1316434549-15243-5-git-send-email-plagnioj@jcrosoft.com \
--to=plagnioj@jcrosoft.com \
--cc=barebox@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