开发者

Linux driver - How to prevent interrupt

I am new to linux driver and writing a char driver for hardware.

What is the exact way to prevent interrupt(software/hardwa开发者_开发百科re) jamming in while the driver functions (eg. ioctl) is executing?

Thanks,

Pui


Did you mean disabling all interrupts in the system ? That is not actually not a good idea.

If you have a section of code and you want to make sure that an unexpected interrupt doesn't come in the way, have a look at spin_lock_irqsave(). This will disable interrupts locally. When you are done, you can then use spin_lock_irqrestore().

If you are concerned about only updating a variable, you might consider making it atomic(atomic_t).

Lastly, if you are only thinking of disabling interrupts from your char hardware when the driver is executing a certain kind of function, that will be hardware dependent. For example, for the LSI 1068E, you have to write 0xFFFFFFFF to the IntMask register. You can also ask the kernel to disable an interrupt line by using disable_irq() on that interrupt line but that is not probably what you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜