Index: c/src/lib/libbsp/powerpc/gen5200/ChangeLog
===================================================================
--- c/src/lib/libbsp/powerpc/gen5200/ChangeLog	(revision c0357a8bd9cf5600638c74a8e66fb96c313c82eb)
+++ c/src/lib/libbsp/powerpc/gen5200/ChangeLog	(revision 07edbef54e01e4864a019c37f74b62d78c85ad4b)
@@ -1,2 +1,7 @@
+2008-05-22	Joel Sherrill <joel.sherrill@oarcorp.com>
+
+	* console/console.c: Remove explicit switch and call
+	termios_baud_to_number().
+
 2008-05-22	Joel Sherrill <joel.sherrill@oarcorp.com>
 
Index: c/src/lib/libbsp/powerpc/gen5200/console/console.c
===================================================================
--- c/src/lib/libbsp/powerpc/gen5200/console/console.c	(revision c0357a8bd9cf5600638c74a8e66fb96c313c82eb)
+++ c/src/lib/libbsp/powerpc/gen5200/console/console.c	(revision 07edbef54e01e4864a019c37f74b62d78c85ad4b)
@@ -119,15 +119,15 @@
 
 #if defined(UARTS_USE_TERMIOS_INT)
-  uint8_t psc_minor_to_irqname[NUM_PORTS] =
-    {BSP_SIU_IRQ_PSC1,
+  uint8_t psc_minor_to_irqname[NUM_PORTS] = {
+     BSP_SIU_IRQ_PSC1,
      BSP_SIU_IRQ_PSC2,
      BSP_SIU_IRQ_PSC3,
      BSP_SIU_IRQ_PSC4,
      BSP_SIU_IRQ_PSC5,
-     BSP_SIU_IRQ_PSC6};
-
-  static int mpc5200_psc_irqname_to_minor(int name)
-  {
-    int minor;
+     BSP_SIU_IRQ_PSC6
+  };
+
+  static int mpc5200_psc_irqname_to_minor(int name) {
+    int      minor;
     uint8_t *chrptr;
 
@@ -149,6 +149,5 @@
 
 /* per channel info structure */
-struct per_channel_info
-  {
+struct per_channel_info {
   uint16_t shadow_imr;
   uint8_t shadow_mode1;
@@ -163,13 +162,13 @@
   int parity_errors;
   int overrun_errors;
-  };
+};
 
 /* Used to handle more than one channel */
 struct per_channel_info channel_info[NUM_PORTS];
 
-  /*
-   * XXX: there are only 6 PSCs, but PSC6 has an extra register gap
-   *      from PSC5, therefore we instantiate seven(!) PSC register sets
-   */
+/*
+ * XXX: there are only 6 PSCs, but PSC6 has an extra register gap
+ *      from PSC5, therefore we instantiate seven(!) PSC register sets
+ */
 uint8_t psc_minor_to_regset[MPC5200_PSC_NO] = {0,1,2,3,4,6};
 
@@ -177,6 +176,9 @@
 struct rtems_termios_tty *ttyp[NUM_PORTS];
 
-int mpc5200_psc_setAttributes(int minor, const struct termios *t)
-  {
+int mpc5200_psc_setAttributes(
+  int                   minor,
+  const struct termios *t
+)
+{
   int baud;
   uint8_t csize=0, cstopb, parenb, parodd;
@@ -185,31 +187,6 @@
 
   /* Baud rate */
-  switch(t->c_cflag & CBAUD)
-    {
-    default:      baud = -1;      break;
-    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;
-    case B230400: baud = 230400;  break;
-    case B460800: baud = 460800;  break;
-    }
-
-  if(baud > 0)
-    {
-
+  baud = termios_baud_to_number(t->c_cflag & CBAUD);
+  if (baud > 0) {
    /*
     * Calculate baud rate
@@ -217,35 +194,26 @@
     */
     baud = (IPB_CLOCK + baud *16) / (baud * 32);
-
-    }
+  }
 
   /* Number of data bits */
-  switch ( t->c_cflag & CSIZE )
-    {
+  switch ( t->c_cflag & CSIZE ) {
     case CS5:     csize = 0x00;  break;
     case CS6:     csize = 0x01;  break;
     case CS7:     csize = 0x02;  break;
     case CS8:     csize = 0x03;  break;
-    }
+  }
 
   /* Stop bits */
-  if(csize == 0)
-    {
-
+  if(csize == 0) {
     if(t->c_cflag & CSTOPB)
       cstopb = 0x0F;           /* Two stop bits */
     else
       cstopb = 0x00;           /* One stop bit */
-
-    }
-  else
-    {
-
+  } else {
     if(t->c_cflag & CSTOPB)
       cstopb = 0x0F;           /* Two stop bits */
     else
       cstopb = 0x07;           /* One stop bit */
-
-    }
+  }
 
   /* Parity */
@@ -289,11 +257,9 @@
   return 0;
 
-  }
+}
 
 
 int mpc5200_uart_setAttributes(int minor, const struct termios *t)
-  {
-
-
+{
   /*
    * Check that port number is valid
@@ -304,6 +270,5 @@
   return mpc5200_psc_setAttributes(minor, t);
 
-  }
-
+}
 
 #ifdef UARTS_USE_TERMIOS_INT
@@ -312,5 +277,5 @@
  */
 static void mpc5200_psc_interrupt_handler(rtems_irq_hdl_param handle)
-  {
+{
   unsigned char c;
   uint16_t isr;
@@ -328,6 +293,5 @@
    * Character received?
    */
-  if(isr & ISR_RX_RDY_FULL)
-    {
+  if (isr & ISR_RX_RDY_FULL) {
 
     channel_info[minor].rx_interrupts++;
@@ -335,12 +299,10 @@
 
 #ifndef SINGLE_CHAR_MODE
-    while(psc->rfnum)
-      {
+    while(psc->rfnum) {
 #endif
-
-     /*
-      * get the character
-      */
-      c = (psc->rb_tb >> 24);
+      /*
+       * get the character
+       */
+       c = (psc->rb_tb >> 24);
 
       if (ttyp[minor] != NULL) {
@@ -351,15 +313,13 @@
 
 #ifndef SINGLE_CHAR_MODE
-      }
+    }
 #endif
 
-    }
+  }
 
   /*
    * Character transmitted ?
    */
-  if(isr & ISR_TX_RDY & channel_info[minor].shadow_imr)
-    {
-
+  if (isr & ISR_TX_RDY & channel_info[minor].shadow_imr) {
     channel_info[minor].tx_interrupts++;
 
@@ -370,28 +330,22 @@
 
     if (ttyp[minor] != NULL) {
-#ifndef SINGLE_CHAR_MODE
-           rtems_termios_dequeue_characters((void *)ttyp[minor], channel_info[minor].cur_tx_len);
-
-           channel_info[minor].tx_characters += channel_info[minor].cur_tx_len;
-#else
-           rtems_termios_dequeue_characters((void *)ttyp[minor], (int)1);
-
-           channel_info[minor].tx_characters++;
-#endif
-      }
+      #ifndef SINGLE_CHAR_MODE
+        rtems_termios_dequeue_characters(
+           (void *)ttyp[minor], channel_info[minor].cur_tx_len);
+        channel_info[minor].tx_characters += channel_info[minor].cur_tx_len;
+      #else
+        rtems_termios_dequeue_characters((void *)ttyp[minor], (int)1);
+        channel_info[minor].tx_characters++;
+      #endif
     }
-
-  if(isr & ISR_ERROR)
-    {
-
+  }
+
+  if(isr & ISR_ERROR) {
     if(isr & ISR_RB)
       channel_info[minor].breaks_detected++;
-
     if(isr & ISR_FE)
       channel_info[minor].framing_errors++;
-
     if(isr & ISR_PE)
       channel_info[minor].parity_errors++;
-
     if(isr & ISR_OE)
       channel_info[minor].overrun_errors++;
@@ -401,10 +355,11 @@
      */
     psc->cr = ((4 << 4) << 8);
-
-    }
-
-  }
-
-void mpc5200_psc_enable(const rtems_irq_connect_data* ptr) {
+  }
+}
+
+void mpc5200_psc_enable(
+  const rtems_irq_connect_data* ptr
+)
+{
   struct mpc5200_psc *psc;
   int minor =  mpc5200_psc_irqname_to_minor(ptr->name);
@@ -418,5 +373,8 @@
 
 
-void mpc5200_psc_disable(const rtems_irq_connect_data* ptr) {
+void mpc5200_psc_disable(
+  const rtems_irq_connect_data* ptr
+)
+{
   struct mpc5200_psc *psc;
   int minor =  mpc5200_psc_irqname_to_minor(ptr->name);
@@ -429,6 +387,8 @@
 }
 
-
-int mpc5200_psc_isOn(const rtems_irq_connect_data* ptr) {
+int mpc5200_psc_isOn(
+  const rtems_irq_connect_data* ptr
+)
+{
   struct mpc5200_psc *psc;
   int minor =  mpc5200_psc_irqname_to_minor(ptr->name);
@@ -438,7 +398,5 @@
     return ((psc->isr_imr & IMR_RX_RDY_FULL) & (psc->isr_imr & IMR_TX_RDY));
   }
-  else {
-    return FALSE;
-  }
+  return FALSE;
 }
 
@@ -447,5 +405,8 @@
 #endif
 
-void mpc5200_uart_psc_initialize(int minor) {
+void mpc5200_uart_psc_initialize(
+  int minor
+)
+{
   uint32_t baud_divider;
   struct mpc5200_psc *psc =
@@ -455,5 +416,5 @@
    * Check that minor number is valid
    */
-  if((minor < PSC1_MINOR) || (minor >= (PSC1_MINOR + NUM_PORTS)))
+  if ((minor < PSC1_MINOR) || (minor >= (PSC1_MINOR + NUM_PORTS)))
     return;
 
@@ -462,5 +423,4 @@
    */
   memset((void *)&channel_info[minor], 0, sizeof(struct per_channel_info));
-
 
   /*
@@ -537,11 +497,8 @@
    * Install rtems irq handler
    */
-  if(!BSP_install_rtems_irq_handler (&consoleIrqData))
-    {
-
+  if (!BSP_install_rtems_irq_handler (&consoleIrqData)) {
     printk("Unable to connect PSC Irq handler\n");
     rtems_fatal_error_occurred(1);
-
-    }
+  }
 #endif
 
@@ -572,33 +529,35 @@
    */
   psc->cr = ((1 << 2) << 8);
-
-  }
-
-
-int mpc5200_uart_pollRead(int minor)
-  {
+}
+
+
+int mpc5200_uart_pollRead(
+  int minor
+)
+{
   unsigned char c;
   struct mpc5200_psc *psc =
     (struct mpc5200_psc *)(&mpc5200.psc[psc_minor_to_regset[minor]]);
 
-  if(psc->sr_csr & (1 << 8))
+  if (psc->sr_csr & (1 << 8))
      c = (psc->rb_tb >> 24);
-      else
-        return -1;
+  else
+     return -1;
 
   return c;
-
-  }
-
-
-int mpc5200_uart_pollWrite(int minor, const char *buf, int len)
-  {
+}
+
+
+int mpc5200_uart_pollWrite(
+  int minor,
+  const char *buf,
+  int len
+)
+{
   const char *tmp_buf = buf;
   struct mpc5200_psc *psc =
     (struct mpc5200_psc *)(&mpc5200.psc[psc_minor_to_regset[minor]]);
 
-  while(len--)
-    {
-
+  while(len--) {
     while(!(psc->sr_csr & (1 << 11)))
       continue;
@@ -610,13 +569,16 @@
     tmp_buf++;
 
-    }
-
+  }
   return 0;
 
-  }
-
-
-int mpc5200_uart_write(int minor, const char *buf, int len)
-  {
+}
+
+
+int mpc5200_uart_write(
+  int         minor,
+  const char *buf,
+  int len
+)
+{
   int frame_len = len;
   const char *frame_buf = buf;
@@ -638,5 +600,5 @@
  /*rtems_cache_flush_multiple_data_lines( (void *)frame_buf, frame_len);*/
 
-  while(frame_len--)
+  while (frame_len--)
     /* perform byte write to avoid extra NUL characters */
     (* (volatile char *)&(psc->rb_tb)) = *frame_buf++;
@@ -648,11 +610,12 @@
 
   return 0;
-
-  }
+}
 
 /*
  *  Print functions prototyped in bspIo.h
  */
-static void A_BSP_output_char( char c )
+static void A_BSP_output_char(
+  char c
+)
 {
   char cr = '\r';
@@ -683,5 +646,4 @@
  */
 
-
 /*
  * Initialize and register the device
@@ -692,6 +654,5 @@
   void *arg
 )
-  {
-
+{
   rtems_status_code status;
   rtems_device_minor_number console_minor;
@@ -706,6 +667,6 @@
 
   for (console_minor = PSC1_MINOR;
-      console_minor < PSC1_MINOR + NUM_PORTS;
-      console_minor++) {
+       console_minor < PSC1_MINOR + NUM_PORTS;
+       console_minor++) {
      /*
       * check, whether UART is available for this board
@@ -719,8 +680,6 @@
       status = rtems_io_register_name (dev_name, major, console_minor);
 
-      if(status != RTEMS_SUCCESSFUL)
-        {
+      if (status != RTEMS_SUCCESSFUL)
         rtems_fatal_error_occurred(status);
-        }
 
       tty_num++;
@@ -736,7 +695,5 @@
   console_initialized = TRUE;
   return RTEMS_SUCCESSFUL;
-
-  }
-
+}
 
 /*
@@ -753,6 +710,5 @@
 
 #ifdef UARTS_USE_TERMIOS_INT
-  static const rtems_termios_callbacks intrCallbacks =
-    {
+  static const rtems_termios_callbacks intrCallbacks = {
     NULL,                           /* firstOpen */
     NULL,                           /* lastClose */
@@ -763,8 +719,7 @@
     NULL,
     1                               /* outputUsesInterrupts */
-    };
+  };
 #else
-  static const rtems_termios_callbacks pollCallbacks =
-    {
+  static const rtems_termios_callbacks pollCallbacks = {
     NULL,                           /* firstOpen */
     NULL,                           /* lastClose */
@@ -775,5 +730,5 @@
     NULL,
     0                               /* output don't use Interrupts */
-    };
+  };
 #endif
 
@@ -800,7 +755,10 @@
  * Close the device
  */
-rtems_device_driver console_close(rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
-  {
-
+rtems_device_driver console_close(
+  rtems_device_major_number  major,
+  rtems_device_minor_number  minor,
+  void                      *arg
+)
+{
   if ( minor > NUM_PORTS-1 )
     return RTEMS_INVALID_NUMBER;
@@ -809,7 +767,5 @@
 
   return rtems_termios_close( arg );
-  return 0;
-
-  }
+}
 
 
@@ -817,44 +773,42 @@
  * Read from the device
  */
-rtems_device_driver console_read(rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
-  {
-
+rtems_device_driver console_read(
+  rtems_device_major_number  major,
+  rtems_device_minor_number  minor,
+  void                      *arg
+)
+{
   if(minor > NUM_PORTS-1)
     return RTEMS_INVALID_NUMBER;
 
   return rtems_termios_read(arg);
-
-  return 0;
-
-  }
-
+}
 
 /*
  * Write to the device
  */
-rtems_device_driver console_write(rtems_device_major_number major,rtems_device_minor_number minor,void *arg)
-  {
-
-  if( minor > NUM_PORTS-1 )
-    return RTEMS_INVALID_NUMBER;
-
-  return rtems_termios_write(arg);
-
-  return 0;
-  }
-
-
-/*
- * Handle ioctl request.
- */
-rtems_device_driver console_control(rtems_device_major_number major,rtems_device_minor_number minor,void *arg)
-  {
-
+rtems_device_driver console_write(
+  rtems_device_major_number  major,
+  rtems_device_minor_number  minor,
+  void                      *arg
+)
+{
   if ( minor > NUM_PORTS-1 )
     return RTEMS_INVALID_NUMBER;
+  return rtems_termios_write(arg);
+}
+
+/*
+ * Handle ioctl request.
+ */
+rtems_device_driver console_control(
+  rtems_device_major_number  major,
+  rtems_device_minor_number  minor,
+  void                      *arg
+)
+{
+  if ( minor > NUM_PORTS-1 )
+    return RTEMS_INVALID_NUMBER;
 
   return rtems_termios_ioctl(arg);
-
-  return 0;
-
-  }
+}
