devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] of/fdt: Remove duplicate check in early_init_dt_scan_memory()
@ 2020-08-14 22:56 Qi Zheng
  2020-08-17 18:21 ` Rob Herring
  0 siblings, 1 reply; 3+ messages in thread
From: Qi Zheng @ 2020-08-14 22:56 UTC (permalink / raw)
  To: robh+dt, frowand.list, robh; +Cc: devicetree, linux-kernel, Qi Zheng

When the value of the first reg is not NULL, there will be
two repeated checks. So modify it.

Signed-off-by: Qi Zheng <arch0.zheng@gmail.com>
---
 drivers/of/fdt.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 4602e467ca8b..f54412c00642 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -1002,10 +1002,11 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,
 		return 0;
 
 	reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l);
-	if (reg == NULL)
+	if (reg == NULL) {
 		reg = of_get_flat_dt_prop(node, "reg", &l);
-	if (reg == NULL)
-		return 0;
+		if (reg == NULL)
+			return 0;
+	}
 
 	endp = reg + (l / sizeof(__be32));
 	hotpluggable = of_get_flat_dt_prop(node, "hotpluggable", NULL);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] of/fdt: Remove duplicate check in early_init_dt_scan_memory()
  2020-08-14 22:56 [PATCH] of/fdt: Remove duplicate check in early_init_dt_scan_memory() Qi Zheng
@ 2020-08-17 18:21 ` Rob Herring
  2020-08-17 22:18   ` Qi Zheng
  0 siblings, 1 reply; 3+ messages in thread
From: Rob Herring @ 2020-08-17 18:21 UTC (permalink / raw)
  To: Qi Zheng; +Cc: Frank Rowand, devicetree, linux-kernel

On Fri, Aug 14, 2020 at 4:57 PM Qi Zheng <arch0.zheng@gmail.com> wrote:
>
> When the value of the first reg is not NULL, there will be
> two repeated checks. So modify it.

I prefer the way it was. I'm sure the compiler is smart enough to
throw out the 2nd check. Plus, 'linux,usable-memory' being present is
the exception, so usually 'reg' will be NULL.

> Signed-off-by: Qi Zheng <arch0.zheng@gmail.com>
> ---
>  drivers/of/fdt.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 4602e467ca8b..f54412c00642 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -1002,10 +1002,11 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,
>                 return 0;
>
>         reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l);
> -       if (reg == NULL)
> +       if (reg == NULL) {
>                 reg = of_get_flat_dt_prop(node, "reg", &l);
> -       if (reg == NULL)
> -               return 0;
> +               if (reg == NULL)
> +                       return 0;
> +       }
>
>         endp = reg + (l / sizeof(__be32));
>         hotpluggable = of_get_flat_dt_prop(node, "hotpluggable", NULL);
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] of/fdt: Remove duplicate check in early_init_dt_scan_memory()
  2020-08-17 18:21 ` Rob Herring
@ 2020-08-17 22:18   ` Qi Zheng
  0 siblings, 0 replies; 3+ messages in thread
From: Qi Zheng @ 2020-08-17 22:18 UTC (permalink / raw)
  To: Rob Herring; +Cc: Frank Rowand, devicetree, linux-kernel

On 2020/8/18 上午2:21, Rob Herring wrote:
> On Fri, Aug 14, 2020 at 4:57 PM Qi Zheng <arch0.zheng@gmail.com> wrote:
>>
>> When the value of the first reg is not NULL, there will be
>> two repeated checks. So modify it.
> 
> I prefer the way it was. I'm sure the compiler is smart enough to
> throw out the 2nd check. Plus, 'linux,usable-memory' being present is
> the exception, so usually 'reg' will be NULL.

I got it, and thanks for your review.
Please ignore this patch.

> 
>> Signed-off-by: Qi Zheng <arch0.zheng@gmail.com>
>> ---
>>   drivers/of/fdt.c | 7 ++++---
>>   1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
>> index 4602e467ca8b..f54412c00642 100644
>> --- a/drivers/of/fdt.c
>> +++ b/drivers/of/fdt.c
>> @@ -1002,10 +1002,11 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,
>>                  return 0;
>>
>>          reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l);
>> -       if (reg == NULL)
>> +       if (reg == NULL) {
>>                  reg = of_get_flat_dt_prop(node, "reg", &l);
>> -       if (reg == NULL)
>> -               return 0;
>> +               if (reg == NULL)
>> +                       return 0;
>> +       }
>>
>>          endp = reg + (l / sizeof(__be32));
>>          hotpluggable = of_get_flat_dt_prop(node, "hotpluggable", NULL);
>> --
>> 2.25.1
>>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-17 22:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-14 22:56 [PATCH] of/fdt: Remove duplicate check in early_init_dt_scan_memory() Qi Zheng
2020-08-17 18:21 ` Rob Herring
2020-08-17 22:18   ` Qi Zheng

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).