2012-03-28 125 views
2

/proc/devices文件可以看到設備驅動程序的主號碼。 有沒有辦法列出設備驅動程序支持的次要號碼? 我沒有資源,我需要一種方法來從運行的Linux獲取信息。Linux設備驅動程序使用的次要號碼

回答

-1

Linux不記錄它。
當使用次要號碼調用open時,該號碼被傳遞給設備驅動程序。然後司機可以隨心所欲地做它。

給定的驅動程序可以實現一個小數字表,每個指向一個狀態結構。但它可能會處理它,否則。

0

Linux 確實跟蹤哪個區域分配了某個驅動程序。否則,在vc,serial(maj 4)和ttyaux(maj 5)區域發生主要數據共享時,如果沒有額外的調度模塊或類似的東西,就不可行。在fs/char_dev.c,你會發現

kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx); 

所以事實上,Linux是由(主要,次要),而不是隻(主要)尋找CDEV對象。

例如見/sys/dev/char/

lrwxrwxrwx 1 root root 0 Mar 27 17:34 4:62 -> ../../devices/virtual/tty/tty62 
lrwxrwxrwx 1 root root 0 Mar 27 17:34 4:63 -> ../../devices/virtual/tty/tty63 
lrwxrwxrwx 1 root root 0 Mar 27 17:34 4:64 -> ../../devices/pnp0/00:06/tty/ttyS0 
lrwxrwxrwx 1 root root 0 Mar 27 17:34 4:65 -> ../../devices/platform/serial8250/tty/ttyS1 
lrwxrwxrwx 1 root root 0 Mar 27 17:34 4:66 -> ../../devices/platform/serial8250/tty/ttyS2 
... 
lrwxrwxrwx 1 root root 0 Mar 27 17:34 4:79 -> ../../devices/platform/serial8250/tty/ttyS15 

自從我配置我的內核與CONFIG_SERIAL_8250_NR_UARTS=16CONFIG_SERIAL_8250_RUNTIME_UARTS=16,我會在sysfs目錄見條目多達ttyS15。這是設備驅動程序註冊了作爲我的配置操作的結果。這可能比根據Documentation/devices.txt保留的少。

相關問題