[PATCH] Force set console baudrate

Alexey Galakhov agalakhov at gmail.com
Tue Jul 9 16:09:50 EDT 2013


Hi,

On 07/10/2013 12:57 AM, Jean-Christophe PLAGNIOL-VILLARD wrote:
> 
> On Jul 10, 2013, at 1:43 AM, Sascha Hauer <s.hauer at pengutronix.de> wrote:
> 
>> On Tue, Jul 09, 2013 at 09:22:10PM +0600, Alexey Galakhov wrote:
>>> Most serial drivers require setbrg() to be called at least once. Call them
>>> just after the device has been added.
>>>
>>> Signed-off-by: Alexey Galakhov <agalakhov at gmail.com>
> 
> This is wrong if you do this at boot which means you force the same baudrate
> on all the console

This does NOT force the same baudrate. It just ensures that the default
baudrate will not be ignored. There is no problem setting another
baudrate later if desired by using "baudrate" parameter from the shell
or something.

> We must do this only is enable by default of via shell

There is "chicken and egg" problem. barebox_banner() requires valid
baudrate setting and may deadlock without it. (It WILL deadlock on most
serial drivers and really deadlocks on S3C one).

> and some console may not need the setbrg call back (keyboard or fbdev as example)

If the device does not have setbrg() function defined, nothing will be
called. This all is under if (newcdev->setbrg) anyway.

> Also if we want to use a rs232 for controlling a mcu the baud rate may not be the
> CONFIG_BAUDRATE

No problem, there is a parameter. Just set it before activating the device.

> so force it at register is wrong

Not setting it is much worse. It will result in deadlock at the first
attempt to write to the console since setbrg() will not be called at all.

The idea is, if there IS a function to set a baudrate and there IS a
default setting, the baudrate SHOULD be initialized before doing
anything else.  Changing the baudrate on an inactive device multiple
times is (or at least should be) harmless. Trying to activate the device
with baudrate unset is not.

Regards,
Alex



More information about the barebox mailing list