On Jul 10, 2013, at 4:09 AM, Alexey Galakhov <agalakhov@xxxxxxxxx> wrote: > 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@xxxxxxxxxxxxxx> 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@xxxxxxxxx> >> >> 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. This does force the same baud rate on ALL console device at register time => wrong > >> 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). so do is at enable time not register time > >> 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. this will result is a call of a NULL pointer -> crash > >> 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. > If the console is not enable there no need to do anything you need to set the baud rate ONLY if the device is enable > Regards, > Alex _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox