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