Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1659308
| From | Chris Packham <chris.packham@alliedtelesis.co.nz> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 2/3] EDAC: altera: simplify calculation of total memory |
| Date | 2017-06-07 02:00 +0200 |
| Message-ID | <tPwye-7dr-15@gated-at.bofh.it> (permalink) |
| References | <tPwye-7dr-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Use of_address_to_resource() and resource_size() instead of manually
parsing the "reg" property from the "memory" node(s).
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
Changes in v2:
- New
drivers/edac/altera_edac.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
index 7717b094fabb..f8b623352627 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -214,24 +214,16 @@ static void altr_sdr_mc_create_debugfs_nodes(struct mem_ctl_info *mci)
static unsigned long get_total_mem(void)
{
struct device_node *np = NULL;
- const unsigned int *reg, *reg_end;
- int len, sw, aw;
- unsigned long start, size, total_mem = 0;
+ struct resource res;
+ int ret;
+ unsigned long total_mem = 0;
for_each_node_by_type(np, "memory") {
- aw = of_n_addr_cells(np);
- sw = of_n_size_cells(np);
- reg = (const unsigned int *)of_get_property(np, "reg", &len);
- reg_end = reg + (len / sizeof(u32));
-
- total_mem = 0;
- do {
- start = of_read_number(reg, aw);
- reg += aw;
- size = of_read_number(reg, sw);
- reg += sw;
- total_mem += size;
- } while (reg < reg_end);
+ ret = of_address_to_resource(np, 0, &res);
+ if (ret)
+ continue;
+
+ total_mem += resource_size(&res);
}
edac_dbg(0, "total_mem 0x%lx\n", total_mem);
return total_mem;
--
2.13.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
EDAC: simplify total memory calculation Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-06-07 02:00 +0200 [PATCH v2 2/3] EDAC: altera: simplify calculation of total memory Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-06-07 02:00 +0200 [PATCH v2 1/3] EDAC: mv64x60: calculate memory size correctly Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-06-07 02:00 +0200
csiph-web