From 24f1347a443a3cdca9009f6870135759e6a88f02 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 23 May 2008 15:48:36 +0000 Subject: 2008-05-23 Joel Sherrill * console/console.c, console/serial_mouse.c: Eliminate copies of switches to convert termios Bxxx constants to xxx as an integer. Use the shared termios_baud_to_number() routine to do the same conversion. --- c/src/lib/libbsp/i386/pc386/ChangeLog | 7 +++ c/src/lib/libbsp/i386/pc386/console/console.c | 60 ++-------------------- c/src/lib/libbsp/i386/pc386/console/serial_mouse.c | 60 ++-------------------- 3 files changed, 13 insertions(+), 114 deletions(-) (limited to 'c/src') diff --git a/c/src/lib/libbsp/i386/pc386/ChangeLog b/c/src/lib/libbsp/i386/pc386/ChangeLog index 6dc9ae8aae..d97a1ed9e2 100644 --- a/c/src/lib/libbsp/i386/pc386/ChangeLog +++ b/c/src/lib/libbsp/i386/pc386/ChangeLog @@ -1,3 +1,10 @@ +2008-05-23 Joel Sherrill + + * console/console.c, console/serial_mouse.c: Eliminate copies of + switches to convert termios Bxxx constants to xxx as an integer. Use + the shared termios_baud_to_number() routine to do the same + conversion. + 2008-05-15 Joel Sherrill * startup/bspstart.c: Add capability for bootcard.c BSP Initialization diff --git a/c/src/lib/libbsp/i386/pc386/console/console.c b/c/src/lib/libbsp/i386/pc386/console/console.c index 5581c6583c..c3381c6a88 100644 --- a/c/src/lib/libbsp/i386/pc386/console/console.c +++ b/c/src/lib/libbsp/i386/pc386/console/console.c @@ -427,63 +427,9 @@ conSetAttr(int minor, const struct termios *t) { unsigned long baud, databits, parity, stopbits; - switch (t->c_cflag & CBAUD) - { - case B50: - baud = 50; - break; - case B75: - baud = 75; - break; - case B110: - baud = 110; - break; - case B134: - baud = 134; - break; - case B150: - baud = 150; - break; - case B200: - baud = 200; - break; - case B300: - baud = 300; - break; - case B600: - baud = 600; - break; - case B1200: - baud = 1200; - break; - case B1800: - baud = 1800; - break; - case B2400: - baud = 2400; - break; - case B4800: - baud = 4800; - break; - case B9600: - baud = 9600; - break; - case B19200: - baud = 19200; - break; - case B38400: - baud = 38400; - break; - case B57600: - baud = 57600; - break; - case B115200: - baud = 115200; - break; - default: - rtems_fatal_error_occurred (RTEMS_INTERNAL_ERROR); - return 0; - } + baud = termios_baud_to_number(t->c_cflag & CBAUD); + if ( baud > 115200 ) + rtems_fatal_error_occurred (RTEMS_INTERNAL_ERROR); if (t->c_cflag & PARENB) { /* Parity is enabled */ diff --git a/c/src/lib/libbsp/i386/pc386/console/serial_mouse.c b/c/src/lib/libbsp/i386/pc386/console/serial_mouse.c index 15f3d8966d..3b7125c28d 100644 --- a/c/src/lib/libbsp/i386/pc386/console/serial_mouse.c +++ b/c/src/lib/libbsp/i386/pc386/console/serial_mouse.c @@ -263,63 +263,9 @@ conSetAttr(int port, int minor, const struct termios *t) { unsigned long baud, databits, parity, stopbits; - switch (t->c_cflag & CBAUD) - { - case B50: - baud = 50; - break; - case B75: - baud = 75; - break; - case B110: - baud = 110; - break; - case B134: - baud = 134; - break; - case B150: - baud = 150; - break; - case B200: - baud = 200; - break; - case B300: - baud = 300; - break; - case B600: - baud = 600; - break; - case B1200: - baud = 1200; - break; - case B1800: - baud = 1800; - break; - case B2400: - baud = 2400; - break; - case B4800: - baud = 4800; - break; - case B9600: - baud = 9600; - break; - case B19200: - baud = 19200; - break; - case B38400: - baud = 38400; - break; - case B57600: - baud = 57600; - break; - case B115200: - baud = 115200; - break; - default: - rtems_fatal_error_occurred (RTEMS_INTERNAL_ERROR); - return 0; - } + baud = termios_baud_to_number(t->c_cflag & CBAUD); + if ( baud > 115200 ) + rtems_fatal_error_occurred (RTEMS_INTERNAL_ERROR); if (t->c_cflag & PARENB) { /* Parity is enabled */ -- cgit v1.2.3