mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <ahmad@a3f.at>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/2] console: respect baudrate specified in device-tree stdout-path
Date: Mon, 21 Jun 2021 06:59:53 +0200	[thread overview]
Message-ID: <20210621045953.GJ9782@pengutronix.de> (raw)
In-Reply-To: <20210619032654.455801-2-ahmad@a3f.at>

Hi Ahmad,

On Sat, Jun 19, 2021 at 05:26:54AM +0200, Ahmad Fatoum wrote:
> -static void console_set_stdoutpath(struct console_device *cdev)
> +static void console_set_stdoutpath(struct console_device *cdev, unsigned baudrate)
>  {
>  	int id;
>  	char *str;
> @@ -232,8 +232,7 @@ static void console_set_stdoutpath(struct console_device *cdev)
>  	if (id < 0)
>  		return;
>  
> -	str = basprintf("console=%s%d,%dn8", cdev->linux_console_name, id,
> -			  cdev->baudrate);
> +	str = basprintf("console=%s%d,%dn8", cdev->linux_console_name, id, baudrate);
>  
>  	globalvar_add_simple("linux.bootargs.console", str);
>  
> @@ -297,6 +296,7 @@ int console_register(struct console_device *newcdev)
>  	struct device_node *serdev_node = console_is_serdev_node(newcdev);
>  	struct device_d *dev = &newcdev->class_dev;
>  	int activate = 0, ret;
> +	unsigned baudrate = CONFIG_BAUDRATE;

You initialize baudrate to CONFIG_BAUDRATE here in order to use that as
a default, ...

>  
>  	if (!serdev_node && initialized == CONSOLE_UNINITIALIZED)
>  		console_init_early();
> @@ -327,11 +327,16 @@ int console_register(struct console_device *newcdev)
>  	if (serdev_node)
>  		return of_platform_populate(serdev_node, NULL, dev);
>  
> +	if (newcdev->dev && of_device_is_stdout_path(newcdev->dev, &baudrate)) {

...but of_device_is_stdout_path() unconditionally overwrites &baudrate...

> -int of_device_is_stdout_path(struct device_d *dev)
> +int of_device_is_stdout_path(struct device_d *dev, unsigned int *baudrate)
>  {
> -	if (!dev->device_node)
> -		return 0;
> +	unsigned int tmp;
> +
> +	if (!dev || !dev->device_node || dev->device_node != of_get_stdoutpath(&tmp))
> +		return false;
>  
> -	return dev->device_node == of_get_stdoutpath();
> +	*baudrate = tmp;

...here. This would break boards which don't have the baudrate given in
the devicetree.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  reply	other threads:[~2021-06-21  5:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-19  3:26 [PATCH 1/2] string: implement strchrnul Ahmad Fatoum
2021-06-19  3:26 ` [PATCH 2/2] console: respect baudrate specified in device-tree stdout-path Ahmad Fatoum
2021-06-21  4:59   ` Sascha Hauer [this message]
2021-06-21  5:04     ` Ahmad Fatoum
2021-06-21  4:52 ` [PATCH 1/2] string: implement strchrnul Sascha Hauer
2021-06-21  5:03   ` Ahmad Fatoum

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=20210621045953.GJ9782@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=ahmad@a3f.at \
    --cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox