[En-Nut-Discussion] Probably flaws in nut/arch/cm3/dev/nxp/lpc177x_8x_gpio.c

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Wed Jul 18 17:23:45 CEST 2012


Hallo Ole,

implementing the STM32 EXTI GPIO Interrupts, by looking at your code, I
stumbled on appended possible flaws. 
1. The basic interrupt handler must get the GPIO_VECTOR as argument.
2. If alloc fails, you must return as writing to 
   NULL[bit].iov_handle will fail in that case

Bye
-- 
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
diff --git a/nut/arch/cm3/dev/nxp/lpc177x_8x_gpio.c b/nut/arch/cm3/dev/nxp/lpc177x_8x_gpio.c
index 11749b6..734304c 100644
--- a/nut/arch/cm3/dev/nxp/lpc177x_8x_gpio.c
+++ b/nut/arch/cm3/dev/nxp/lpc177x_8x_gpio.c
@@ -396,7 +396,7 @@ int GpioRegisterIrqHandler(GPIO_SIGNAL * sig, int bit, void (*handler) (void *),
             memset(sig->ios_vector, 0, sizeof(GPIO_VECTOR) * 32);
             /* Register our internal PIO interrupt service. */
             if (sig_PIO.ir_handler == NULL) {
-                rc = NutRegisterIrqHandler(&sig_PIO, sig->ios_handler, NULL);
+                rc = NutRegisterIrqHandler(&sig_PIO, sig->ios_handler, sig->ios_vector);
                 if (rc == 0) {
                     /* Clear any pending interrupts */
                     LPC_GPIOINT->IO0IntClr = 0xFFFFFFFF;
@@ -407,7 +407,7 @@ int GpioRegisterIrqHandler(GPIO_SIGNAL * sig, int bit, void (*handler) (void *),
             }
         }
         else {
-            rc = -1;
+            return -1;
         }
     }
     sig->ios_vector[bit].iov_handler = handler;



More information about the En-Nut-Discussion mailing list