[問題] shared handlers時參數dev的用途是什麼?

看板LinuxDev作者 (hay)時間9年前 (2016/02/27 13:38), 編輯推噓1(101)
留言2則, 1人參與, 最新討論串1/1
小弟最近在學習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://www.ptt.cc/bbs/LinuxDev/M.1456551517.A.669.html

03/08 08:10, , 1F
可以傳入自己定義的資料結構,透過讀取Reg去看是哪一個
03/08 08:10, 1F

03/08 08:10, , 2F
中斷源
03/08 08:10, 2F
文章代碼(AID): #1MqJPTPf (LinuxDev)
文章代碼(AID): #1MqJPTPf (LinuxDev)