作者karta298905 (hay)
看板LinuxDev
标题[问题] shared handlers时参数dev的用途是什麽?
时间Sat Feb 27 13:38:34 2016
小弟最近在学习linux kernel,然後有在阅读linux kernel development这本书
http://moodle2.insa-lyon.fr/pluginfile.php/16715/course/section/4469/
Linux%20Kernel%20Development%203rd%20Edition%20-%20Love%20-%202010.pdf
对於shared handlers中的参数dev有一些疑问
由116页可以知道利用下面的function可以注册一个handler
int request_irq(unsigned int irq,
irq_handler_t handler,
unsigned long flags,
const char *name,
void *dev)
然後对於指标dev在书上有两个解释,
(1) dev, is used for shared interrupt lines.When an interrupt handler
is freed, dev provides a unique cookie to enable the removal of only
the desired interrupt handler from the interrupt line. Without this
parameter, it would be impossible for the kernel to know which
handler to remove on a given interrupt line. (page 117)
(2) If this value (dev) is unique, it can act as a cookie to
differentiate between multiple devices potentially using the same
interrupt handler.
以下是小弟个人的解释:
第一个解释是在说当不同handler share同一个interrupt line的情况下dev
可以判断哪一个handler是要被移除的,而第二个则是说在多个device使用
相同handler之下,dev可以帮忙分辨是哪一个device。
如果上面的解释是对的那麽指标dev真正的用途是什麽呢?
是在区分同一个interrupt line上的handler还是区分同一个handler中的device?
其他书籍好像都没有对这点特别做解释。
另外,在第二点中有提到multiple device,是指完全一样的device吗?(同厂牌同
型号)还是不同的device可以用相同的handler呢? 感谢各位大大帮忙解惑
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 1.160.158.40
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/LinuxDev/M.1456551517.A.669.html
1F:推 aweilin: 可以传入自己定义的资料结构,透过读取Reg去看是哪一个 03/08 08:10
2F:→ aweilin: 中断源 03/08 08:10