From: Thor Thayer <thor.thayer@linux.intel.com>
To: Chris Packham <chris.packham@alliedtelesis.co.nz>,
bp@alien8.de, linux-edac@vger.kernel.org
Cc: mchehab@kernel.org, mpe@ellerman.id.au,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] EDAC: altera: simplify calculation of total memory
Date: Mon, 12 Jun 2017 13:34:05 -0500 [thread overview]
Message-ID: <b052bfda-c5a3-7b23-682c-ab59c9c8ad3a@linux.intel.com> (raw)
In-Reply-To: <20170606235500.22772-3-chris.packham@alliedtelesis.co.nz>
On 06/06/2017 06:54 PM, Chris Packham wrote:
> 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;
>
Nice change! Tested on Cyclone5 DevKit & Arria10 DevKit.
Tested-by: Thor Thayer <thor.thayer@linux.intel.com>
next prev parent reply other threads:[~2017-06-12 18:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-06 23:54 EDAC: simplify total memory calculation Chris Packham
2017-06-06 23:54 ` [PATCH v2 1/3] EDAC: mv64x60: calculate memory size correctly Chris Packham
2017-06-06 23:54 ` [PATCH v2 2/3] EDAC: altera: simplify calculation of total memory Chris Packham
2017-06-12 18:34 ` Thor Thayer [this message]
2017-06-14 11:50 ` Borislav Petkov
2017-06-06 23:55 ` [PATCH v2 3/3] EDAC: cpc925: " Chris Packham
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=b052bfda-c5a3-7b23-682c-ab59c9c8ad3a@linux.intel.com \
--to=thor.thayer@linux.intel.com \
--cc=bp@alien8.de \
--cc=chris.packham@alliedtelesis.co.nz \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mchehab@kernel.org \
--cc=mpe@ellerman.id.au \
/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;
as well as URLs for NNTP newsgroup(s).