[PATCH] Updated Legacy code in arm csb336

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Jul 8 15:09:32 UTC 2013


On 07/08/2013 03:43 PM, Vipul Nayyar wrote:
> ---
>   c/src/lib/libbsp/arm/csb336/console/uart.c    | 128 +++++++++++++++-----------
>   c/src/lib/libbsp/arm/csb336/network/network.c |  46 +++------
>   2 files changed, 86 insertions(+), 88 deletions(-)
>
> diff --git a/c/src/lib/libbsp/arm/csb336/console/uart.c b/c/src/lib/libbsp/arm/csb336/console/uart.c
> index 4dc409b..8156921 100644
> --- a/c/src/lib/libbsp/arm/csb336/console/uart.c
> +++ b/c/src/lib/libbsp/arm/csb336/console/uart.c
[...]
>   /* Define this to use interrupt driver UART driver */
>   #define USE_INTERRUPTS 1
> +#define UART_TX 1
> +#define UART_RX 2
[...]
>   static ssize_t imx_uart_intr_write(int, const char *, size_t);
> +static rtems_irq_number imx_uart_set_name(int,int);

This rtems_irq_number is defined in <rtems/irq.h>.  This it belongs to the 
legacy API we want to get rid of.  Use rtems_vector_number instead.

[...]
> +static rtems_irq_number imx_uart_set_name(int minor,int uart_name)
> +{
> +    if (minor == 0) {
> +        if (uart_name == UART_TX) return BSP_INT_UART1_TX;
> +        else if (uart_name == UART_RX)return BSP_INT_UART1_RX;
> +
> +    } else if (minor == 1) {
> +        if (uart_name == UART_TX) return BSP_INT_UART2_TX;
> +        else if (uart_name == UART_RX) return BSP_INT_UART2_RX;
> +    }
> +
> +    rtems_panic("%s:%d Unknown UART minor number %d\n",
> +                    __FUNCTION__, __LINE__, minor);
> +}
[...]

This function is better than the previous copy and paste approach.

If I naively read imx_uart_set_name() I think this function sets the name of 
the UART.  Instead this function returns an interrupt vector depending on a 
magic number uart_name.

I would use two functions for this, one for the receive and one for the 
transmit interrupt or use at least an enum instead of the int uart_name.  Since 
we already use assert(), you can replace the rtems_panic() (which is a very 
heavy weight function) with an assert(0).

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list