irq自动探测机制
如果一个设备的驱动程序无法确定它说管理的设备的软件中断号irq,此时设备驱动程序可以使用irq的自动探测机制来获取其正在使用的irq。
使用自动探测机制的条件
- 内核与驱动,必须共同努力才能完成
- 只限于非共享中断的情况
探测前,驱动的设备关联到了某个irq,但是因为设备驱动程序还不清楚是哪个irq,因此无法调用request_irq来向该irq安装中断处理例程,所以对应irq的action为空,下面是一个设备驱动程序的使用示例:
probe_irq_on和probe_irq_off是内核为驱动程序员设计的两个自动探测的接口函数
irq自动探测的原理描述
probe_irq_on
/**
* probe_irq_on - begin an interrupt autodetect
*
* Commence probing for an interrupt. The interrupts are scanned
* and a mask of potential interrupt lines is returned.
*
* 开始探测中断,扫描中断并返回潜在中断线的mask
*/
unsigned long probe_irq_on(void)
{
struct irq_desc *desc;
unsigned long mask = 0;
int i;
/*
* quiesce the kernel, or at least the asynchronous portion
*/
async_synchronize_full();
mutex_lock(&probing_active);
/*
* something may have generated an irq long ago and we want to
* flush such a longstanding irq before considering it as spurious.
*/
for_each_irq_desc_reverse(i, desc) {
raw_spin_lock_irq(&desc->lock);
if (