From: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
To: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: barebox@lists.infradead.org
Subject: [PATCH v3 09/10] OF: base: convert of_add_memory to OF API
Date: Tue, 2 Jul 2013 20:14:38 +0200 [thread overview]
Message-ID: <1372788879-11028-10-git-send-email-sebastian.hesselbarth@gmail.com> (raw)
In-Reply-To: <1372152047-28134-1-git-send-email-sebastian.hesselbarth@gmail.com>
Convert of_add_memory parsing to make use of of_address_to_resource
instead of parsing memory ranges itself. This makes some functions
dead code which are also removed.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
Changelog:
v1->v2:
- fix check for return value of of_address_to_resource (Reported by
Sascha Hauer)
Cc: barebox@lists.infradead.org
---
drivers/of/base.c | 57 +++++++---------------------------------------------
1 files changed, 8 insertions(+), 49 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 0244281..1cf7a5f 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -99,21 +99,6 @@ int of_n_size_cells(struct device_node *np)
}
EXPORT_SYMBOL(of_n_size_cells);
-static void of_bus_default_count_cells(struct device_node *dev,
- int *addrc, int *sizec)
-{
- if (addrc)
- *addrc = of_n_addr_cells(dev);
- if (sizec)
- *sizec = of_n_size_cells(dev);
-}
-
-static void of_bus_count_cells(struct device_node *dev,
- int *addrc, int *sizec)
-{
- of_bus_default_count_cells(dev, addrc, sizec);
-}
-
struct property *of_find_property(const struct device_node *np,
const char *name, int *lenp)
{
@@ -1543,48 +1528,22 @@ int of_set_property(struct device_node *np, const char *name, const void *val, i
return 0;
}
-static u64 dt_mem_next_cell(int s, const __be32 **cellp)
-{
- const __be32 *p = *cellp;
-
- *cellp = p + s;
- return of_read_number(p, s);
-}
-
int of_add_memory(struct device_node *node, bool dump)
{
- int na, nc;
- const __be32 *reg, *endp;
- int len, r = 0, ret;
const char *device_type;
+ struct resource res;
+ int n = 0, ret;
ret = of_property_read_string(node, "device_type", &device_type);
- if (ret)
+ if (ret || of_node_cmp(device_type, "memory"))
return -ENXIO;
- if (of_node_cmp(device_type, "memory"))
- return -ENXIO;
-
- of_bus_count_cells(node, &na, &nc);
-
- reg = of_get_property(node, "reg", &len);
- if (!reg)
- return -EINVAL;
-
- endp = reg + (len / sizeof(__be32));
-
- while ((endp - reg) >= (na + nc)) {
- u64 base, size;
-
- base = dt_mem_next_cell(na, ®);
- size = dt_mem_next_cell(nc, ®);
-
- if (size == 0)
+ while (!of_address_to_resource(node, n, &res)) {
+ if (!resource_size(&res))
continue;
-
- of_add_memory_bank(node, dump, r, base, size);
-
- r++;
+ of_add_memory_bank(node, dump, n,
+ res.start, resource_size(&res));
+ n++;
}
return 0;
--
1.7.2.5
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-07-02 18:15 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-25 9:20 [PATCH 0/9] OF: address and device related sync and cleanup Sebastian Hesselbarth
2013-06-25 9:20 ` [PATCH 1/9] OF: import address related functions from Linux OF API Sebastian Hesselbarth
2013-06-25 9:20 ` [PATCH 2/9] OF: convert of_translate_address to new API Sebastian Hesselbarth
2013-06-25 9:20 ` [PATCH 3/9] OF: base: move OF_ROOT_NODE_ defines to local OF code Sebastian Hesselbarth
2013-06-25 9:20 ` [PATCH 4/9] OF: import bus/device related functions from Linux OF API Sebastian Hesselbarth
2013-06-25 12:55 ` Sebastian Hesselbarth
2013-06-26 6:11 ` Sascha Hauer
2013-06-26 8:23 ` Sebastian Hesselbarth
2013-06-26 8:43 ` [PATCH v2 " Sebastian Hesselbarth
2013-06-25 9:20 ` [PATCH 5/9] OF: base: use of_platform_populate for probing Sebastian Hesselbarth
2013-06-29 14:22 ` Sascha Hauer
2013-06-25 9:20 ` [PATCH 6/9] OF: base: remove dead device related functions Sebastian Hesselbarth
2013-06-25 9:20 ` [PATCH 7/9] OF: remove device and resource pointer from struct device_node Sebastian Hesselbarth
2013-06-29 14:28 ` Sascha Hauer
2013-06-29 14:31 ` Sascha Hauer
2013-06-29 16:03 ` Sebastian Hesselbarth
2013-06-29 16:09 ` Sascha Hauer
2013-06-25 9:20 ` [PATCH 8/9] OF: base: convert of_add_memory to OF API Sebastian Hesselbarth
2013-06-25 19:48 ` Sascha Hauer
2013-06-25 19:57 ` Sebastian Hesselbarth
2013-06-25 21:38 ` Sebastian Hesselbarth
2013-06-26 8:43 ` [PATCH v2 " Sebastian Hesselbarth
2013-06-25 9:20 ` [PATCH 9/9] OF: base: rename of_free to of_delete_node Sebastian Hesselbarth
2013-06-27 6:51 ` [PATCH 0/9] OF: address and device related sync and cleanup Sascha Hauer
2013-06-27 7:50 ` Sebastian Hesselbarth
2013-06-27 8:58 ` Sascha Hauer
2013-06-27 9:00 ` Sebastian Hesselbarth
2013-06-27 18:19 ` Sascha Hauer
2013-06-27 18:27 ` Sebastian Hesselbarth
2013-07-02 18:14 ` [PATCH v3 00/10] " Sebastian Hesselbarth
2013-07-05 6:45 ` Sascha Hauer
2013-07-02 18:14 ` [PATCH v3 01/10] OF: import address related functions from Linux OF API Sebastian Hesselbarth
2013-07-02 18:14 ` [PATCH v3 02/10] OF: convert of_translate_address to new API Sebastian Hesselbarth
2013-07-02 18:14 ` [PATCH v3 03/10] OF: base: move OF_ROOT_NODE_ defines to local OF code Sebastian Hesselbarth
2013-07-02 18:14 ` [PATCH v3 04/10] OF: import bus/device related functions from Linux OF API Sebastian Hesselbarth
2013-07-02 18:14 ` [PATCH v3 05/10] OF: gpio: convert DT based gpio handling to new " Sebastian Hesselbarth
2013-07-02 18:14 ` [PATCH v3 06/10] OF: base: use of_platform_populate for probing Sebastian Hesselbarth
2013-07-02 18:14 ` [PATCH v3 07/10] OF: base: remove dead device related functions Sebastian Hesselbarth
2013-07-02 18:14 ` [PATCH v3 08/10] OF: remove device and resource pointer from struct device_node Sebastian Hesselbarth
2013-07-02 18:14 ` Sebastian Hesselbarth [this message]
2013-07-02 18:14 ` [PATCH v3 10/10] OF: base: rename of_free to of_delete_node Sebastian Hesselbarth
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=1372788879-11028-10-git-send-email-sebastian.hesselbarth@gmail.com \
--to=sebastian.hesselbarth@gmail.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