From: Lionel Sambuc Date: Wed, 2 Oct 2013 08:56:24 +0000 (+0200) Subject: ARM serial driver: Comment termios_baud_rate. X-Git-Tag: v3.3.0~577 X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=3af30c2c608ea7c75726c9e7aa916bac401d21e3;p=minix.git 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 --- diff --git a/drivers/tty/arch/earm/rs232.c b/drivers/tty/arch/earm/rs232.c index 9d30c8e48..3cba19ef5 100644 --- a/drivers/tty/arch/earm/rs232.c +++ b/drivers/tty/arch/earm/rs232.c @@ -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;