devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Hurley <peter@hurleysoftware.com>
To: Masahiro Yamada <yamada.masahiro@socionext.com>,
	devicetree@vger.kernel.org
Cc: Rob Herring <robh@kernel.org>,
	linux-serial@vger.kernel.org,
	Frank Rowand <frowand.list@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	linux-kernel@vger.kernel.org,
	Grant Likely <grant.likely@linaro.org>,
	Ley Foon Tan <lftan@altera.com>
Subject: Re: [PATCH] of/fdt: fix error checking for earlycon address
Date: Fri, 23 Oct 2015 09:15:22 -0400	[thread overview]
Message-ID: <562A32EA.20808@hurleysoftware.com> (raw)
In-Reply-To: <1445600840-26749-1-git-send-email-yamada.masahiro@socionext.com>

Hi Masahiro,

On 10/23/2015 07:47 AM, Masahiro Yamada wrote:
> fdt_translate_address() returns OF_BAD_ADDR on error.  It is defined as
> a u64 value, so the variable "addr" should be defined as u64 as well.

Good catch.

I would prefer if fdt_translate_address() returned resource_size_t (which
is the proper type for handling addresses as integers) and that type
was propagated through early_init_dt_scan_chosen_serial => of_setup_earlycon.

Regards,
Peter Hurley


PS - It seems that there is a new user of fdt_translate_address() in the
nios arch:

commit e8bf5bc776edef44777b13b2eb4461d653519bae
Author: Ley Foon Tan <lftan@altera.com>
Date:   Tue Feb 10 23:21:08 2015 +0800

    nios2: add early printk support
    
    Signed-off-by: Ley Foon Tan <lftan@altera.com>

I've copied the author as that should have been an earlycon in the
altera uart driver(s) rather than early_printk. Oh well.


> Fixes: fb11ffe74c79 ("of/fdt: add FDT serial scanning for earlycon")
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
> 
>  drivers/of/fdt.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 9fc3568..196e449 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -822,14 +822,15 @@ static int __init early_init_dt_scan_chosen_serial(void)
>  		return -ENODEV;
>  
>  	while (match->compatible[0]) {
> -		unsigned long addr;
> +		u64 addr;
> +
>  		if (fdt_node_check_compatible(fdt, offset, match->compatible)) {
>  			match++;
>  			continue;
>  		}
>  
>  		addr = fdt_translate_address(fdt, offset);
> -		if (!addr)
> +		if (addr == OF_BAD_ADDR)
>  			return -ENXIO;
>  
>  		of_setup_earlycon(addr, match->data);
> 

  reply	other threads:[~2015-10-23 13:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-23 11:47 [PATCH] of/fdt: fix error checking for earlycon address Masahiro Yamada
2015-10-23 13:15 ` Peter Hurley [this message]
     [not found]   ` <562A32EA.20808-WaGBZJeGNqdsbIuE7sb01tBPR1lH4CV8@public.gmane.org>
2015-10-27 20:46     ` Rob Herring
     [not found]       ` <CAL_JsqK6UJxvGt3_y5T+VMxpr7G=PCmQ_Nx0QW-EfeTHOCDMKQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-28 14:56         ` Peter Hurley
2015-10-29  4:07 ` 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=562A32EA.20808@hurleysoftware.com \
    --to=peter@hurleysoftware.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=grant.likely@linaro.org \
    --cc=lftan@altera.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=robh@kernel.org \
    --cc=yamada.masahiro@socionext.com \
    /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).