Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1659309
| From | Chris Packham <chris.packham@alliedtelesis.co.nz> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 1/3] EDAC: mv64x60: calculate memory size correctly |
| Date | 2017-06-07 02:00 +0200 |
| Message-ID | <tPwye-7dr-21@gated-at.bofh.it> (permalink) |
| References | <tPwye-7dr-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
The #address-cells and #size-cells properties need to be accounted for
when dealing with the "memory" device tree node. Use
of_address_to_resource() and resource_size() to retrieve the size of the
memory node which will automatically take the #cells into account.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
Changes in v2:
- Use of_address_to_resource() instead of manually parsing the reg property.
drivers/edac/mv64x60_edac.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/edac/mv64x60_edac.c b/drivers/edac/mv64x60_edac.c
index 3461db3723cb..93623e704623 100644
--- a/drivers/edac/mv64x60_edac.c
+++ b/drivers/edac/mv64x60_edac.c
@@ -16,6 +16,7 @@
#include <linux/io.h>
#include <linux/edac.h>
#include <linux/gfp.h>
+#include <linux/of_address.h>
#include <linux/of_platform.h>
#include <linux/of_device.h>
@@ -644,15 +645,19 @@ static irqreturn_t mv64x60_mc_isr(int irq, void *dev_id)
static void get_total_mem(struct mv64x60_mc_pdata *pdata)
{
struct device_node *np = NULL;
- const unsigned int *reg;
+ struct resource res;
+ int ret;
+ unsigned long total_mem = 0;
- np = of_find_node_by_type(NULL, "memory");
- if (!np)
- return;
+ for_each_node_by_type(np, "memory") {
+ ret = of_address_to_resource(np, 0, &res);
+ if (ret)
+ continue;
- reg = of_get_property(np, "reg", NULL);
+ total_mem += resource_size(&res);
+ }
- pdata->total_mem = reg[1];
+ pdata->total_mem = total_mem;
}
static void mv64x60_init_csrows(struct mem_ctl_info *mci,
--
2.13.0
Back to linux.kernel | Previous | Next — Previous 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