Changeset 6fe6d017 in rtems


Ignore:
Timestamp:
Nov 26, 2013, 7:56:08 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
1d5d6de
Parents:
1e744ef
git-author:
Sebastian Huber <sebastian.huber@…> (11/26/13 07:56:08)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/04/14 13:54:27)
Message:

bsp/leon3: Avoid copy and paste in console driver

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/sparc/leon3/console/console.c

    r1e744ef r6fe6d017  
    8383static int uarts = 0;
    8484
     85static struct apbuart_priv *leon3_console_get_uart(int minor)
     86{
     87  struct apbuart_priv *uart;
     88
     89  if (minor == 0)
     90    uart = &apbuarts[syscon_uart_index];
     91  else
     92    uart = &apbuarts[minor - 1];
     93
     94  return uart;
     95}
     96
    8597#if CONSOLE_USE_INTERRUPTS
    8698
     
    116128static int leon3_console_write_support(int minor, const char *buf, size_t len)
    117129{
    118   struct apbuart_priv *uart;
     130  struct apbuart_priv *uart = leon3_console_get_uart(minor);
    119131  int sending;
    120 
    121   if (minor == 0)
    122     uart = &apbuarts[syscon_uart_index];
    123   else
    124     uart = &apbuarts[minor - 1];
    125132
    126133  if (len > 0) {
     
    158165ssize_t console_write_polled(int minor, const char *buf, size_t len)
    159166{
    160   int nwrite = 0, port;
    161 
    162   if (minor == 0)
    163     port = syscon_uart_index;
    164   else
    165     port = minor - 1;
     167  struct apbuart_priv *uart = leon3_console_get_uart(minor);
     168  int nwrite = 0;
    166169
    167170  while (nwrite < len) {
    168     apbuart_outbyte_polled(apbuarts[port].regs, *buf++, 1, 0);
     171    apbuart_outbyte_polled(uart->regs, *buf++, 1, 0);
    169172    nwrite++;
    170173  }
     
    174177int console_pollRead(int minor)
    175178{
    176   int port;
    177 
    178   if (minor == 0)
    179     port = syscon_uart_index;
    180   else
    181     port = minor - 1;
    182 
    183   return apbuart_inbyte_nonblocking(apbuarts[port].regs);
     179  struct apbuart_priv *uart = leon3_console_get_uart(minor);
     180
     181  return apbuart_inbyte_nonblocking(uart->regs);
    184182}
    185183
     
    196194int console_set_attributes(int minor, const struct termios *t)
    197195{
     196  struct apbuart_priv *uart = leon3_console_get_uart(minor);
    198197  unsigned int scaler;
    199198  unsigned int ctrl;
    200199  int baud;
    201   struct apbuart_priv *uart;
    202200
    203201  switch (t->c_cflag & CSIZE) {
     
    211209      break;
    212210  }
    213 
    214   if (minor == 0)
    215     uart = &apbuarts[syscon_uart_index];
    216   else
    217     uart = &apbuarts[minor - 1];
    218211
    219212  /*
     
    372365static int leon3_console_first_open(int major, int minor, void *arg)
    373366{
    374   struct apbuart_priv *uart;
     367  struct apbuart_priv *uart = leon3_console_get_uart(minor);
     368
     369#if CONSOLE_USE_INTERRUPTS
    375370  rtems_status_code sc;
    376371
    377   if (minor == 0)
    378     uart = &apbuarts[syscon_uart_index];
    379   else
    380     uart = &apbuarts[minor - 1];
    381 
    382 #if CONSOLE_USE_INTERRUPTS
    383372  uart->cookie = leon3_console_get_tty(arg);
    384373
     
    408397{
    409398  struct rtems_termios_tty *tty = leon3_console_get_tty(arg);
    410   struct apbuart_priv *uart;
     399  struct apbuart_priv *uart = leon3_console_get_uart(minor);
    411400  rtems_interrupt_level level;
    412 
    413   if (minor == 0)
    414     uart = &apbuarts[syscon_uart_index];
    415   else
    416     uart = &apbuarts[minor - 1];
    417401
    418402  /* Turn off RX interrupts */
Note: See TracChangeset for help on using the changeset viewer.