[Patch] Removing legacy method from arm csb336

Vipul Nayyar nayyar_vipul at yahoo.com
Sun Jun 30 10:47:34 UTC 2013


Hello,

Trying once gain with the arm csb336 patch. I'm explicitly checking the status code returned now, but am I doing the right thing if the status code returned is not RTEMS_SUCCESSFUL ? For now I'm doing the same what happens in BSP_install_rtems_irq_handler & BSP_remove_rtems_irq_handler ? 

commit 1887514fd17d17c089c4305f34963c244324eba3
Author: Vipul Nayyar <nayyar_vipul at yahoo.com>
Date:   Sun Jun 30 16:08:43 2013 +0530

    Updated Legacy code in arm csb336

diff --git a/c/src/lib/libbsp/arm/csb336/console/uart.c b/c/src/lib/libbsp/arm/csb336/console/uart.c
index 4dc409b..758f103 100644
--- a/c/src/lib/libbsp/arm/csb336/console/uart.c
+++ b/c/src/lib/libbsp/arm/csb336/console/uart.c
@@ -246,9 +246,36 @@ static int imx_uart_first_open(int major, int minor, void *arg)
 
     imx_uart_data[minor].tty   = args->iop->data1;
 
+    rtems_status_code sc = RTEMS_SUCCESSFUL;
+
 #if defined(USE_INTERRUPTS)
-    BSP_install_rtems_irq_handler(&imx_uart_tx_isr_data[minor]);
-    BSP_install_rtems_irq_handler(&imx_uart_rx_isr_data[minor]);
+    sc = rtems_interrupt_handler_install(
+      imx_uart_tx_isr_data[minor].name,
+      "Console",
+      RTEMS_INTERRUPT_UNIQUE,
+      imx_uart_tx_isr_data[minor].hdl,
+      imx_uart_tx_isr_data[minor].handle
+    );
+    if (sc != RTEMS_SUCCESSFUL) {
+    return 0;
+    }
+    if (imx_uart_tx_isr_data[minor].on != NULL) {
+    imx_uart_tx_isr_data[minor].on(&imx_uart_tx_isr_data[minor]);
+    }
+
+    sc = rtems_interrupt_handler_install(
+      imx_uart_rx_isr_data[minor].name,
+      "Console",
+      RTEMS_INTERRUPT_UNIQUE,
+      imx_uart_rx_isr_data[minor].hdl,
+      imx_uart_rx_isr_data[minor].handle
+    );
+    if (sc != RTEMS_SUCCESSFUL) {
+    return 0;
+    }
+    if (imx_uart_rx_isr_data[minor].on != NULL) {
+    imx_uart_rx_isr_data[minor].on(&imx_uart_rx_isr_data[minor]);
+    }
 
     imx_uart_data[minor].regs->cr1 |= MC9328MXL_UART_CR1_RRDYEN;
 #endif
@@ -258,9 +285,32 @@ static int imx_uart_first_open(int major, int minor, void *arg)
 
 static int imx_uart_last_close(int major, int minor, void *arg)
 {
+    rtems_status_code sc = RTEMS_SUCCESSFUL;
+
 #if defined(USE_INTERRUPTS)
-    BSP_remove_rtems_irq_handler(&imx_uart_tx_isr_data[minor]);
-    BSP_remove_rtems_irq_handler(&imx_uart_rx_isr_data[minor]);
+    if (imx_uart_tx_isr_data[minor].off != NULL) {
+    imx_uart_tx_isr_data[minor].off(&imx_uart_tx_isr_data[minor]);
+    }
+    sc = rtems_interrupt_handler_remove(
+        imx_uart_tx_isr_data[minor].name,
+        imx_uart_tx_isr_data[minor].hdl,
+        imx_uart_tx_isr_data[minor].handle
+    );
+    if (sc != RTEMS_SUCCESSFUL) {
+    return 0;
+    }
+    if (imx_uart_rx_isr_data[minor].off != NULL) {
+    imx_uart_rx_isr_data[minor].off(&imx_uart_rx_isr_data[minor]);
+    }
+
+    sc = rtems_interrupt_handler_remove(
+        imx_uart_rx_isr_data[minor].name,
+        imx_uart_rx_isr_data[minor].hdl,
+        imx_uart_rx_isr_data[minor].handle
+    );
+    if (sc != RTEMS_SUCCESSFUL) {
+    return 0;
+    }
 #endif
 
     return 0;
diff --git a/c/src/lib/libbsp/arm/csb336/network/network.c b/c/src/lib/libbsp/arm/csb336/network/network.c
index e513595..2441c01 100644
--- a/c/src/lib/libbsp/arm/csb336/network/network.c
+++ b/c/src/lib/libbsp/arm/csb336/network/network.c
@@ -238,6 +238,7 @@ void  mc9328mxl_enet_init_hw(mc9328mxl_enet_softc_t *sc)
 {
     uint16_t stat;
     uint16_t my = 0;
+    rtems_status_code sc = RTEMS_SUCCESSFUL;
 
     lan91c11x_write_reg(LAN91C11X_RCR, LAN91C11X_RCR_RST);
     lan91c11x_write_reg(LAN91C11X_RCR, 0);
@@ -334,7 +335,19 @@ void  mc9328mxl_enet_init_hw(mc9328mxl_enet_softc_t *sc)
     MC9328MXL_GPIOA_IMR |= bit(3);
 
     /* Install the interrupt handler */
-    BSP_install_rtems_irq_handler(&mc9328mxl_enet_isr_data);
+    sc = rtems_interrupt_handler_install(
+      mc9328mxl_enet_isr_data.name,
+      "Network",
+      RTEMS_INTERRUPT_UNIQUE,
+      mc9328mxl_enet_isr_data.hdl,
+      mc9328mxl_enet_isr_data.handle
+    );
+    if (sc != RTEMS_SUCCESSFUL) {
+    return 0;
+    }
+    if (mc9328mxl_enet_isr_data.on != NULL) {
+    mc9328mxl_enet_isr_data.on(&mc9328mxl_enet_isr_data);
+  }
 
 } /* mc9328mxl_enet_init_hw() */
 
Regards

Vipul Nayyar 



________________________________
 From: Joel Sherrill <Joel.Sherrill at OARcorp.com>
To: Vipul Nayyar <nayyar_vipul at yahoo.com> 
Cc: "rtems-devel at rtems.org" <rtems-devel at rtems.org>; Sebastian Huber <sebastian.huber at embedded-brains.de>; "gedare at rtems.org" <gedare at rtems.org> 
Sent: Sunday, 30 June 2013 2:04 AM
Subject: Re: [Patch] Removing legacy method from arm csb336
 


Please return the status code into a variable and test it separately in the assert. I will defer to Sebastian on whether assert should be used. I tend to think it should be a fatal error call with an explicit test. Using assert increases the code size. Plus this first one gives you a pattern for the rest. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20130630/17d87b17/attachment-0001.html>


More information about the devel mailing list