最終更新:2017-06-19 (月) 16:15:00 (65d)  

Linux/USB/probe はてなブックマークを見る
Top / Linux / USB / probe

処理の流れ

  • Kernel has a list of registered drivers
  • Each driver has an array of acceptable device IDs ([[usb_driver.id_table])
  • Kernel goes through the list and if some id matches calls driver's probe()
  • If driver is not there udev may load it's module based on alias
  • Module aliases are generated based on acceptable device IDs

usb_driver

メモ

  • driver_info?

マッチング

usb_device_id

  • usb_driver.id_tableに指定
  • linux/usb.hで下記のように定義されている
    #define USB_DEVICE(vend, prod) \
            .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \
            .idVendor = (vend), \
            .idProduct = (prod)
    
    #define USB_DEVICE_VER(vend, prod, lo, hi) \
            .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, \
            .idVendor = (vend), \
            .idProduct = (prod), \
            .bcdDevice_lo = (lo), \
            .bcdDevice_hi = (hi)
    
    #define USB_DEVICE_INTERFACE_CLASS(vend, prod, cl) \
            .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
                           USB_DEVICE_ID_MATCH_INT_CLASS, \
            .idVendor = (vend), \
            .idProduct = (prod), \
            .bInterfaceClass = (cl)
    
    #define USB_DEVICE_INTERFACE_PROTOCOL(vend, prod, pr) \
            .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
                           USB_DEVICE_ID_MATCH_INT_PROTOCOL, \
            .idVendor = (vend), \
            .idProduct = (prod), \
            .bInterfaceProtocol = (pr)
    ... and so on ...

hid_device_id

MODULE_DEVICE_TABLE

関連

参考