Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1664170 > unrolled thread

Re: [PATCH v2 2/3] EDAC: altera: simplify calculation of total memory

Started byThor Thayer <thor.thayer@linux.intel.com>
First post2017-06-12 20:40 +0200
Last post2017-06-14 14:00 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v2 2/3] EDAC: altera: simplify calculation of total memory Thor Thayer <thor.thayer@linux.intel.com> - 2017-06-12 20:40 +0200
    Re: [PATCH v2 2/3] EDAC: altera: simplify calculation of total memory Borislav Petkov <bp@alien8.de> - 2017-06-14 14:00 +0200

#1664170 — Re: [PATCH v2 2/3] EDAC: altera: simplify calculation of total memory

FromThor Thayer <thor.thayer@linux.intel.com>
Date2017-06-12 20:40 +0200
SubjectRe: [PATCH v2 2/3] EDAC: altera: simplify calculation of total memory
Message-ID<tRCpQ-5OW-19@gated-at.bofh.it>
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>

[toc] | [next] | [standalone]


#1665734

FromBorislav Petkov <bp@alien8.de>
Date2017-06-14 14:00 +0200
Message-ID<tSf7P-4I9-5@gated-at.bofh.it>
In reply to#1664170
On Mon, Jun 12, 2017 at 01:34:05PM -0500, Thor Thayer wrote:
> 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>
> > ---

...

> Nice change! Tested on Cyclone5 DevKit & Arria10 DevKit.
> 
> Tested-by: Thor Thayer <thor.thayer@linux.intel.com>

Applied, thanks.

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web