简体   繁体   English

错误:设备或资源繁忙

[英]Error: Device or resourse is busy

I'm trying to write a simple module, which should replace irq 1 handler. 我正在尝试编写一个简单的模块,该模块应该替换irq 1处理程序。 And all the time I get following error:'-1 Device or resourse busy'. 而且一直出现以下错误:'-1设备或资源繁忙。 Is it any way to fix it? 有什么办法解决吗? Here's my code: 这是我的代码:

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/workqueue.h>
#include <linux/interrupt.h>
#include <asm/io.h>


irqreturn_t myhandler(int irq, void *dev_id, struct pt_regs *regs) 
{
  printk(KERN_ALERT"\n\nMy interrupt handler\n\n");
  return IRQ_HANDLED;
}

int init_module()
{
  int res;
  free_irq(1, NULL);                  
  res = request_irq(1, (void*)myhandler,0, "my_handler", (void*)(myhandler)); 
  return res;
}

void cleanup_module()
{
  free_irq(1, NULL);
}
MODULE_LICENSE("GPL");

Maybe anybody can say what's wrong. 也许有人可以说出什么问题了。 PS. PS。 I'm working with 2.6.39.3 kernel. 我正在使用2.6.39.3内核。

What type of system (architecture) are you on? 您正在使用哪种类型的系统(架构)?

On a normal PC, IRQ 1 is the 8042 (keyboard controller) and already has an interrupt handler. 在普通PC上,IRQ 1是8042(键盘控制器),并且已经具有中断处理程序。 You are passing 0 into request_irq() for flags , so you're asking to register a handler for a non-shared interrupt. 您正在将0传递给flags request_irq() ,因此您要注册一个非共享中断的处理程序。 The core kernel interrupt code will look and see that there is already another handler registered for that IRQ, and return -EBUSY from request_irq . 核心内核中断代码将查看并发现已经为该IRQ注册了另一个处理程序,并从request_irq返回-EBUSY

You can't override the existing handler by registering another handler for the same IRQ. 您不能通过为同一IRQ注册另一个处理程序来覆盖现有处理程序。 You need to unregister the first one before you can register a new one. 您需要先注销第一个,然后才能注册新的。

You can look at /proc/interrupts to see what is already using IRQ 1 on your system. 您可以查看/ proc / interrupts来查看系统上已经使用的IRQ 1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM