ARM serial driver: Comment termios_baud_rate.

The B0-B115200 defines are flags, and not the actual speed they
represent.

This fixes an incoherency for B0 handling, and documents why it is
required to call the function again after changing the speed flag.

DFL_BAUD is set to one of the flag, so to translate it to an actual
speed, the function calls itself again, which will always be able to
finish without inducing another recursive call.

Change-Id: I04ebfaefee31a88d05f0b726352d1581a966147b
This commit is contained in:
Lionel Sambuc 2013-10-02 10:56:24 +02:00
parent 5e48dc3f40
commit 3af30c2c60

View file

@ -343,7 +343,6 @@ termios_baud_rate(struct termios *term)
{
int baud;
switch(term->c_ospeed) {
case B0: term->c_ospeed = DFLT_BAUD; baud = termios_baud_rate(term);
case B300: baud = 300; break;
case B600: baud = 600; break;
case B1200: baud = 1200; break;
@ -353,7 +352,14 @@ termios_baud_rate(struct termios *term)
case B38400: baud = 38400; break;
case B57600: baud = 57600; break;
case B115200: baud = 115200; break;
default: term->c_ospeed = DFLT_BAUD; baud = termios_baud_rate(term);
case B0:
default:
/* Reset the speed to the default speed, then call ourselves
* to convert the default speed to a baudrate. This call will
* always return a value without inducing another recursive
* call. */
term->c_ospeed = DFLT_BAUD;
baud = termios_baud_rate(term);
}
return baud;