diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-07-24 16:12:49 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-07-24 16:12:49 +0000 |
commit | a5bbb06141592892d13e294d67dc7295accd1c3a (patch) | |
tree | 6381eab26969206f6c0996cbbac5064b22b44a41 /cpukit/libcsupport/src/termios_num2baud.c | |
parent | 2010-07-23 Vinu Rajashekhar <vinutheraj@gmail.com> (diff) | |
download | rtems-a5bbb06141592892d13e294d67dc7295accd1c3a.tar.bz2 |
2010-07-24 Joel Sherrill <joel.sherrill@oarcorp.com>
* libcsupport/Makefile.am, libcsupport/src/termios_baud2num.c,
libcsupport/src/termios_num2baud.c: Use RTEMS associations to
simplify code and make easier for coverage.
* libcsupport/src/termios_baudtable.c: New file.
Diffstat (limited to 'cpukit/libcsupport/src/termios_num2baud.c')
-rw-r--r-- | cpukit/libcsupport/src/termios_num2baud.c | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/cpukit/libcsupport/src/termios_num2baud.c b/cpukit/libcsupport/src/termios_num2baud.c index 465a79794d..3725609135 100644 --- a/cpukit/libcsupport/src/termios_num2baud.c +++ b/cpukit/libcsupport/src/termios_num2baud.c @@ -15,6 +15,9 @@ #include <sys/termios.h> #include <rtems/termiostypes.h> +#include <rtems/assoc.h> + +extern rtems_assoc_t termios_assoc_table[]; int rtems_termios_number_to_baud( int32_t baud @@ -22,29 +25,8 @@ int rtems_termios_number_to_baud( { int termios_baud; - switch (baud) { - case 0: termios_baud = B0; break; - case 50: termios_baud = B50; break; - case 75: termios_baud = B75; break; - case 110: termios_baud = B110; break; - case 134: termios_baud = B134; break; - case 150: termios_baud = B150; break; - case 200: termios_baud = B200; break; - case 300: termios_baud = B300; break; - case 600: termios_baud = B600; break; - case 1200: termios_baud = B1200; break; - case 1800: termios_baud = B1800; break; - case 2400: termios_baud = B2400; break; - case 4800: termios_baud = B4800; break; - case 9600: termios_baud = B9600; break; - case 19200: termios_baud = B19200; break; - case 38400: termios_baud = B38400; break; - case 57600: termios_baud = B57600; break; - case 115200: termios_baud = B115200; break; - case 230400: termios_baud = B230400; break; - case 460800: termios_baud = B460800; break; - default: termios_baud = -1; break; - } - + termios_baud = rtems_assoc_remote_by_local( termios_assoc_table, baud ); + if ( termios_baud == 0 && baud != 0 ) + return -1; return termios_baud; } |