summaryrefslogtreecommitdiff
path: root/nuttx/sched/irq_attach.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-01-04 00:14:45 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-01-04 00:14:45 +0000
commit10b9a1fa0c8d68bb7f2c6fac7176669052831401 (patch)
tree7b8e16865ed3a998f215f9fc53a0db979b4f3b97 /nuttx/sched/irq_attach.c
parent6ab3a2a10626f28693ff0b7db7c41e5b9e760131 (diff)
downloadpx4-nuttx-10b9a1fa0c8d68bb7f2c6fac7176669052831401.tar.gz
px4-nuttx-10b9a1fa0c8d68bb7f2c6fac7176669052831401.tar.bz2
px4-nuttx-10b9a1fa0c8d68bb7f2c6fac7176669052831401.zip
Fix an issue for architectures where interrupt numbers and vector numbers do not match 1-to-1
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4258 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/irq_attach.c')
-rw-r--r--nuttx/sched/irq_attach.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/nuttx/sched/irq_attach.c b/nuttx/sched/irq_attach.c
index 85f6b93ed..99fb62078 100644
--- a/nuttx/sched/irq_attach.c
+++ b/nuttx/sched/irq_attach.c
@@ -1,8 +1,8 @@
/****************************************************************************
* sched/irq_attach.c
*
- * Copyright (C) 2007-2008, 2010 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Copyright (C) 2007-2008, 2010, 2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -91,9 +91,23 @@ int irq_attach(int irq, xcpt_t isr)
state = irqsave();
if (isr == NULL)
{
-#ifndef CONFIG_ARCH_NOINTC
- up_disable_irq(irq);
+ /* Disable the interrupt if we can before detaching it. We might
+ * not be able to do this if: (1) the device does not have a
+ * centralized interrupt controller (so up_disable_irq() is not
+ * supported. Or (2) if the device has different number for vector
+ * numbers and IRQ numbers (in that case, we don't know the correct
+ * IRQ number to use to disable the interrupt. In those cases, the
+ * code will just need to be careful that it disables all interrupt
+ * sources before detaching from the interrupt vector.
+ */
+
+#if !defined(CONFIG_ARCH_NOINTC) && !defined(CONFIG_ARCH_VECNOTIRQ)
+ up_disable_irq(irq);
#endif
+ /* Detaching the ISR really means re-attaching it to the
+ * unexpected exception handler.
+ */
+
isr = irq_unexpected_isr;
}