最終更新:2015-11-26 (木) 18:58:23 (3072d)
probe
Top / probe
デバイスの検出とか。
Linux/プラットフォームデバイス
呼び出され例
- module_platform_driver/platform_driver_probe -> platform_driver_register -> __platform_driver_register -> driver_register -> driver_register -> bus_add_driver -> driver_attach -> driver_probe_device -> really_probe
platform_driver.probe(platform_device)
コールバック関数の登録
- その1:
- その2:
- platform_driver_probeで (register driver for non-hotpluggable device)
- drv->probe = probe;//例:hidg_plat_driver_probe
- platform_driver_probeで (register driver for non-hotpluggable device)
- その後__platform_driver_registerで
- if (platform_driver.probe) - 宣言時に指定されている場合
- device_driver.probe platform_driver.device.probe? = platform_drv_probe;
呼び出し元
device_driver.probe
コールバック関数の登録
- __platform_driver_registerで
- platform_driver.probeが指定されていればその関数
- 指定されていない場合はplatform_drv_probe
呼び出し元 (dwc3_driverの例)
- __platform_driver_register(dwc3_driver)
- if (drv->probe)drv->driver.probe = platform_drv_probe; <=ここでコールバックを設定
- driver_register -> bus_add_driver -> driver_attach -> driver_probe_device -> really_probe
- device.bus.probe()
- device_driver.probe() <=ここで設定したコールバック(platform_drv_probe)を呼び出し。コールバック先でさらにplatform_driver.probe(dwc3_probe)が呼ばれる
USB
- The probe() function is called by the USB core to see if the driver is willing to manage a particular interface on a device.
- The driver should then make checks on the information passed to it about the device.
- If it decides to manage the interface, the probe() function will return 0. Otherwise, it will return a negative value.
- The disconnect() function is called by the USB core when a driver should no longer control the device (even if the driver is still loaded), and should do some cleanup.
- The probe() and disconnect() callbacks are called in the context of the USB hub kernel thread.
- So, it is legal to call functions which may sleep in these functions.
- However, all addition and removal of devices is managed by this single thread.
- Most of the probe function work should indeed be done when the device is actually opened by a userThis way, this doesn't impact the performance of the kernel thread in managing other devices.
usbcore
- usb_probe_device - called from driver core with dev locked
- usbhid_probe - usbhid
- usb_mouse_probe? - usbmouse
- usb_kbd_probe? - usbkbd
- usb_serial_probe? - usbserial?
usb_driver
- usb_driver.probe - called by the USB core to see if the driver is willing to manage a particular interface on a device.
- usb_register_driver(usb_driver new_driver)
- new_driver->drvwrap.driver.probe = usb_probe_interface;
- new_driver->drvwrap.driver.remove = usb_unbind_interface?;
hid_driver
- hid_allocate_device? - allocate new hid device descriptor
- hid_bus_type.probe? = hid_device_probe
- hid_match_device
- if(hid_driver.probe)
- else
- #default probe
- hid_open_report - open a driver-specific device report
- hid_hw_start - start underlaying HW ->hid_connect
- hid_close_report?