[PATCH 2/2] console: respect baudrate specified in device-tree stdout-path

Ahmad Fatoum a.fatoum at pengutronix.de
Sun Jun 20 22:04:11 PDT 2021


Hi,

On 21.06.21 06:59, Sascha Hauer wrote:
> 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.

Ouch. Will fix.

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



More information about the barebox mailing list