
On 9 August 2018 at 08:17, Jean-Jacques Hiblot jjhiblot@ti.com wrote:
In some cases it can be useful to be able to bind a device to a driver from the command line. The obvious example is for versatile devices such as USB gadget. Another use case is when the devices are not yet ready at startup and require some setup before the drivers are bound (ex: FPGA which bitsream is fetched from a mass storage or ethernet)
usage example:
bind usb_dev_generic 0 usb_ether unbind usb_dev_generic 0 usb_ether or unbind eth 1
bind /ocp/omap_dwc3@48380000/usb@48390000 usb_ether unbind /ocp/omap_dwc3@48380000/usb@48390000
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
Changes in v4:
- Fixed compiler warning: "cmd/bind.c:236:5: warning: ‘ret’ may be used uninitialized in this function [-Wmaybe-uninitialized]"
Changes in v3:
- factorize code based on comments from ML
- remove the devices before unbinding them
- use device_find_global_by_ofnode() to get a device by its node.
Changes in v2:
- Make the bind/unbind command generic, not specific to usb device.
- Update the API to be able to bind/unbind based on DTS node path
- Add a Kconfig option to select the bind/unbind commands
arch/sandbox/dts/test.dts | 11 ++ cmd/Kconfig | 9 ++ cmd/Makefile | 1 + cmd/bind.c | 255 +++++++++++++++++++++++++++++++++++++++++++++ configs/sandbox_defconfig | 1 + test/py/tests/test_bind.py | 178 +++++++++++++++++++++++++++++++ 6 files changed, 455 insertions(+) create mode 100644 cmd/bind.c create mode 100644 test/py/tests/test_bind.py
Reviewed-by: Simon Glass sjg@chromium.org