devm_request_threaded_irq()函数原型
时间: 2023-08-02 17:07:29 浏览: 55
devm_request_threaded_irq() 函数原型如下:
```
int devm_request_threaded_irq(struct device *dev, unsigned int irq,
irq_handler_t handler, irq_handler_t thread_fn,
unsigned long flags, const char *name, void *dev_id);
```
该函数用于请求一个线程化的中断处理程序,可以自动进行内存管理,避免内存泄露。它需要传入设备对象、中断号、中断处理函数、中断线程函数、中断标志、中断名称和设备 ID 等参数。函数返回值为 0 表示请求中断成功,否则表示失败。
相关问题
devm_request_threaded_irq函数
devm_request_threaded_irq函数是Linux内核中的一个API,用于请求一个中断并注册一个中断处理函数。该函数在请求中断时会为中断处理函数启动一个新的内核线程,以便在中断处理程序中执行长时间运行的操作,而不会阻塞系统的其余部分。
该函数的语法为:
int devm_request_threaded_irq(struct device *dev, unsigned int irq, irq_handler_t handler, irq_handler_t thread_fn, unsigned long flags, const char *name, void *dev_id);
其中,dev是与中断相关联的设备结构体指针,irq是中断号,handler是中断处理函数,thread_fn是中断线程函数,flags是中断标志,name是中断处理程序的名称,dev_id是传递给中断处理函数和线程函数的设备ID。
该函数返回一个整数,表示请求中断是否成功。如果成功,返回值为0;如果失败,返回一个负数错误代码。
使用devm_request_threaded_irq函数可以方便地管理中断处理程序和线程函数的内存,并且可以自动释放它们。此外,它还支持多个设备共享同一个中断处理程序和线程函数,从而减少内核中断处理程序的复杂性。
devm_request_threaded_irq原型
devm_request_threaded_irq是Linux内核中用于申请带线程的中断的函数,其原型定义在头文件`<linux/interrupt.h>`中,如下所示:
```
int devm_request_threaded_irq(struct device *dev, unsigned int irq,
irq_handler_t handler, irq_handler_t thread_fn,
unsigned long irqflags, const char *devname,
void *dev_id);
```
该函数的参数含义如下:
- `dev`:设备节点,表示要申请中断的设备节点。
- `irq`:中断号,表示要申请的中断号。
- `handler`:中断处理函数,用于处理中断事件。
- `thread_fn`:中断处理线程函数,用于在处理中断时创建一个新的线程来执行。
- `irqflags`:中断标志位,用于设置中断的一些属性和特性。
- `devname`:设备名称,用于标识设备。
- `dev_id`:设备ID,用于表示设备的ID信息。
该函数的返回值为0表示申请成功,否则表示申请失败。
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)