奇怪的是在2.6用request_irq時發現好幾個問題
我引入的標頭檔如下: 
#include <linux/kernel.h> 
#include <linux/sched.h> 
#include <linux/irq.h> 
#include <linux/interrupt.h> 
#include <linux/signal.h> 
1、不認識SA_INTERRUPT,會提示 implicite declartion of SA_INTERRUPT 
後來發現2.6下沒有對SA_INTERRUPT的宏定義,而在2.4下定義為0x20000000。但是若在request_irq時直接用0x20000000時則可以用,而且成功後傳回值為0 
但是我在2.6下用哪個中斷標誌比較好呢。 
2、編譯的時候提示一個警告: 
warning: passing argument 2 of ‘request_irq’ from incompatible pointer type 
3、運行時觸發中斷時發生: 
irq event 126: bogus return value b0043000 
Call Trace: 
[ <8002043c>] dump_stack+0x8/0x34 
[ <80072314>] __report_bad_irq+0x44/0xd8 
[ <800726f0>] note_interrupt+0x348/0x3c8 
[ <800714d4>] __do_IRQ+0x164/0x1a4 
[ <800115e0>] plat_irq_dispatch+0x268/0x288 
[ <80019340>] ret_from_irq+0x0/0x4 
[ <c05ab700>] MACTasks+0xf54/0x28b4 [zigbee] 
[ <c05a93c8>] ZigBeeTasks+0x1d8/0x43c [zigbee] 
[ <c05b0a58>] testRfd+0xb0/0xca8 [zigbee] 
[ <c05b1688>] uspi_ioctl+0x18/0x30 [zigbee] 
[ <800bea34>] do_ioctl+0xc4/0xd4 
[ <800beab8>] vfs_ioctl+0x74/0x3d4 
[ <800bee68>] sys_ioctl+0x50/0x98 
[ <80022670>] stack_done+0x20/0x3c 
handlers: 
[ <c05a98a0>] (HighISR+0x0/0x474 [zigbee]) 
  
關於問題1,這個是中間過渡版本裡的定義,自從2.6.24後就被remove了。 你可以用對應的現在的宏,IRQF_DISABLED 
原來以SA_開頭的定義很不好,跟訊號容易混到一塊。 
還有SA_INTERRUPT指的是快速中斷也不明顯,現在意思清楚了很多。 
+/* 
+ * Migration helpers. Scheduled for removal in 1/2007 
+ * Do not use for new code ! 
+ */ 
+#define SA_INTERRUPT          IRQF_DISABLED 
+#define SA_SAMPLE_RANDOM      IRQF_SAMPLE_RANDOM 
+#define SA_SHIRQ              IRQF_SHARED 
+#define SA_PROBEIRQ            IRQF_PROBE_SHARED 
  
關於問題2,請檢查你用的核心源碼中request_irq函數的原形,看看與你程式中使用的request_irq函數參數類型是否一致,我記得是改動過。 
如果不相同最好修改程式中的定義方式,改動很小,很容易。 
關於2, 參數strcut pt_regs 去掉了,因為沒有用。 
irqreturn_t (*handler)(int, void *, struct pt_regs *) 
int request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_regs *), 
                unsigned long flags, const char *dev_name, void *dev_id); 
變為 
typedef irqreturn_t (*irq_handler_t)(int, void *); 
int request_irq(unsigned int irq, irq_handler_t handler, 
                unsigned long irqflags, const char *devname, void *dev_id) 
  
關於問題3,你的中斷處理函數  有沒有類似這樣的返回  
    return IRQ_HANDLED; 
從你的log看來是這樣的,你check一下: 
irq event 126: bogus return value b0043000 
Call Trace: 
[ <8002043c>] dump_stack+0x8/0x34 
[ <80072314>] __report_bad_irq+0x44/0xd8 
static void 
__report_bad_irq(unsigned int irq, struct irq_desc *desc, 
                irqreturn_t action_ret) 
{ 
        struct irqaction *action; 
                                                                                                                          
        if (action_ret != IRQ_HANDLED && action_ret != IRQ_NONE) { 
                printk(KERN_ERR "irq event %d: bogus return value %x/n", 
                                irq, action_ret); 
        } else { 
                printk(KERN_ERR "irq %d: nobody cared (try booting with " 
                                "the /"irqpoll/" option)/n", irq); 
        } 
  
原來是在2.6下中斷處理函數一定要有傳回值(0或1),而在2.4下則沒有要求。