From 10b9a1fa0c8d68bb7f2c6fac7176669052831401 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 4 Jan 2012 00:14:45 +0000 Subject: 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 --- nuttx/sched/irq_attach.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'nuttx/sched') 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 + * Copyright (C) 2007-2008, 2010, 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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; } -- cgit v1.2.3