From: Florian Fainelli <f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org
Subject: Re: [PATCH] of/flattree: print memory scan node results in CPU endian
Date: Wed, 08 Apr 2015 20:17:23 -0700 [thread overview]
Message-ID: <5525EF43.1040309@gmail.com> (raw)
In-Reply-To: <55259B4D.2020304-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Le 08/04/2015 14:19, Frank Rowand a écrit :
> On 4/7/2015 11:44 PM, Florian Fainelli wrote:
>> Commit 51975db0b7333 ("of/flattree: merge early_init_dt_scan_memory()
>> common code") consolidated some code from PowerPC (typically
>> big-endian), and ended-up adding a pr_debug() printing reg properties in
>> big-endian (DT native) format, not CPU endian. Unsurprisingly, when
>> these messages are turned on a little-endian systems, this is confusing,
>> so do the conversion while printing the values.
>>
>> Signed-off-by: Florian Fainelli <f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> ---
>> drivers/of/fdt.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
>> index 3a896c9aeb74..0d8f0e4bd107 100644
>> --- a/drivers/of/fdt.c
>> +++ b/drivers/of/fdt.c
>> @@ -880,7 +880,8 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,
>> endp = reg + (l / sizeof(__be32));
>>
>> pr_debug("memory scan node %s, reg size %d, data: %x %x %x %x,\n",
>> - uname, l, reg[0], reg[1], reg[2], reg[3]);
>> + uname, l, be32_to_cpu(reg[0]), be32_to_cpu(reg[1]),
>> + be32_to_cpu(reg[2]), be32_to_cpu(reg[3]));
>
> The pr_debug() assumes that the length of reg[] is >= 4 elements, which might not be true.
> Since the following while loop checks the length of reg[] and then uses pr_debug() to
> print each (base, size) tuple with the correct endian, maybe it would be better to
> just remove reg[0] through reg[3] from the above pr_debug() instead of fixing the
> endian issue.
Right, that works too, will follow-up with a patch removing the
reg[0..3] prints.
Thanks!
--
Florian
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Florian Fainelli <f.fainelli@gmail.com>
To: frowand.list@gmail.com
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
robh+dt@kernel.org, grant.likely@linaro.org
Subject: Re: [PATCH] of/flattree: print memory scan node results in CPU endian
Date: Wed, 08 Apr 2015 20:17:23 -0700 [thread overview]
Message-ID: <5525EF43.1040309@gmail.com> (raw)
In-Reply-To: <55259B4D.2020304@gmail.com>
Le 08/04/2015 14:19, Frank Rowand a écrit :
> On 4/7/2015 11:44 PM, Florian Fainelli wrote:
>> Commit 51975db0b7333 ("of/flattree: merge early_init_dt_scan_memory()
>> common code") consolidated some code from PowerPC (typically
>> big-endian), and ended-up adding a pr_debug() printing reg properties in
>> big-endian (DT native) format, not CPU endian. Unsurprisingly, when
>> these messages are turned on a little-endian systems, this is confusing,
>> so do the conversion while printing the values.
>>
>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>> ---
>> drivers/of/fdt.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
>> index 3a896c9aeb74..0d8f0e4bd107 100644
>> --- a/drivers/of/fdt.c
>> +++ b/drivers/of/fdt.c
>> @@ -880,7 +880,8 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,
>> endp = reg + (l / sizeof(__be32));
>>
>> pr_debug("memory scan node %s, reg size %d, data: %x %x %x %x,\n",
>> - uname, l, reg[0], reg[1], reg[2], reg[3]);
>> + uname, l, be32_to_cpu(reg[0]), be32_to_cpu(reg[1]),
>> + be32_to_cpu(reg[2]), be32_to_cpu(reg[3]));
>
> The pr_debug() assumes that the length of reg[] is >= 4 elements, which might not be true.
> Since the following while loop checks the length of reg[] and then uses pr_debug() to
> print each (base, size) tuple with the correct endian, maybe it would be better to
> just remove reg[0] through reg[3] from the above pr_debug() instead of fixing the
> endian issue.
Right, that works too, will follow-up with a patch removing the
reg[0..3] prints.
Thanks!
--
Florian
next prev parent reply other threads:[~2015-04-09 3:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-08 6:44 [PATCH] of/flattree: print memory scan node results in CPU endian Florian Fainelli
2015-04-08 21:19 ` Frank Rowand
[not found] ` <55259B4D.2020304-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-04-09 3:17 ` Florian Fainelli [this message]
2015-04-09 3:17 ` Florian Fainelli
2015-04-12 20:16 ` [PATCH] of/fdt: Remove "reg" data prints from early_init_dt_scan_memory Florian Fainelli
2015-04-12 20:16 ` Florian Fainelli
[not found] ` <1428869786-26897-1-git-send-email-f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-04-15 12:52 ` Rob Herring
2015-04-15 12:52 ` Rob Herring
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=5525EF43.1040309@gmail.com \
--to=f.fainelli-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.