
There was quite a bit of discussion about the change that required the unbinding of USB devices for the subsystem to function correctly. E.g.
https://patchwork.ozlabs.org/patch/485637/
The key issue is the usb_get_dev_index() function which is not a good API for driver model. We can drop use of this function once everything is converted to driver model. Then I believe the problems raised by Hans go away. For now we can add a deprecation warning on the function.
It is easy to convert USB keyboards to driver model. This series includes a patch for that.
This series also includes reverts for the three commits which as discussed I would like to drop. U-Boot should be able to run normally and exit without unbinding anything.
Also included are some tests for the 'usb tree' command. To make this work, console recording is implemented.
Finally, a USB keyboard driver is provided for sandbox, so that this part of the stack can be tested automatically.
Changes in v2: - Add various patches to support USB keyboards and additional tests
Simon Glass (26): sandbox: Add a way to skip time delays dm: usb: Avoid time delays in sandbox tests Move console definitions into a new console.h file Drop config.h header from display_options.c Add a circular memory buffer implementation console: Add a console buffer sandbox: Enable console recording and silent console test: Record and silence console in tests usb: Refactor USB tree output code for testing dm: core: Add safe device iteration macros sandbox: usb: Allow dynamic emulated USB device descriptors sandbox: usb: Allow up to 4 emulated devices on a hub sandbox: usb: Allow finding a USB emulator for a device Revert "dm: usb: Rename usb_find_child to usb_find_emul_child" Revert "dm: usb: Use device_unbind_children to clean up usb devs on stop" Revert "dm: Export device_remove_children / device_unbind_children" dm: usb: Deprecate usb_get_dev_index() dm: usb: Remove inactive children after a bus scan dm: test: usb: Add tests for the 'usb tree' command dm: test: usb: Add a test for device reordering usb: Drop unused code in usb_kbd.c usb: Avoid open-coded USB constants in usb_kbd.c usb: sandbox: Add support for interrupt operations usb: sandbox: Add a USB emulation driver sandbox: Enable USB keyboard dm: test: usb: sandbox: Add keyboard tests for sandbox
arch/blackfin/lib/cmd_cache_dump.c | 1 + arch/powerpc/cpu/mpc8260/ether_fcc.c | 1 + arch/powerpc/cpu/mpc8260/i2c.c | 1 + arch/powerpc/cpu/mpc8xx/i2c.c | 1 + arch/sandbox/cpu/cpu.c | 5 +- arch/sandbox/cpu/start.c | 8 + arch/sandbox/cpu/state.c | 14 ++ arch/sandbox/dts/test.dts | 19 +- arch/sandbox/include/asm/state.h | 20 ++ arch/sandbox/include/asm/test.h | 2 + arch/sh/lib/board.c | 1 + arch/sparc/lib/board.c | 1 + board/Arcturus/ucp1020/spl.c | 1 + board/astro/mcf5373l/fpga.c | 1 + board/cobra5272/flash.c | 1 + board/esd/common/cmd_loadpci.c | 1 + board/esd/cpci405/cpci405.c | 1 + board/esd/pmc405de/pmc405de.c | 1 + board/esd/pmc440/cmd_pmc440.c | 1 + board/esd/pmc440/pmc440.c | 1 + board/esd/vme8349/caddy.c | 1 + board/freescale/b4860qds/spl.c | 1 + board/freescale/c29xpcie/spl.c | 1 + board/freescale/mpc8569mds/mpc8569mds.c | 1 + board/freescale/p1010rdb/spl.c | 1 + board/freescale/p1022ds/spl.c | 1 + board/freescale/p1_p2_rdb_pc/spl.c | 1 + board/freescale/t102xqds/spl.c | 1 + board/freescale/t102xrdb/spl.c | 1 + board/freescale/t104xrdb/spl.c | 1 + board/freescale/t208xqds/spl.c | 1 + board/freescale/t208xrdb/spl.c | 1 + board/freescale/t4qds/spl.c | 1 + board/freescale/t4rdb/spl.c | 1 + board/gdsys/common/cmd_ioloop.c | 1 + board/inka4x0/inkadiag.c | 1 + board/lwmon5/kbd.c | 1 + board/mpl/common/kbd.c | 1 + board/mpl/pati/pati.c | 1 + board/renesas/sh7785lcr/selfcheck.c | 1 + board/tqc/tqm5200/cmd_stk52xx.c | 1 + board/tqc/tqm5200/tqm5200.c | 1 + board/xes/xpedite1000/xpedite1000.c | 1 + common/Kconfig | 28 +++ common/autoboot.c | 1 + common/board_f.c | 11 + common/board_r.c | 11 + common/cli.c | 1 + common/cli_hush.c | 1 + common/cli_simple.c | 1 + common/cmd_armflash.c | 1 + common/cmd_dcr.c | 1 + common/cmd_dfu.c | 1 + common/cmd_fastboot.c | 1 + common/cmd_fpgad.c | 1 + common/cmd_fuse.c | 1 + common/cmd_i2c.c | 1 + common/cmd_load.c | 1 + common/cmd_mem.c | 2 + common/cmd_misc.c | 1 + common/cmd_mmc.c | 1 + common/cmd_nand.c | 1 + common/cmd_nvedit.c | 1 + common/cmd_otp.c | 1 + common/cmd_pci.c | 1 + common/cmd_usb.c | 59 +++-- common/cmd_usb_mass_storage.c | 1 + common/command.c | 1 + common/console.c | 51 +++- common/iomux.c | 1 + common/main.c | 1 + common/usb_hub.c | 10 +- common/usb_kbd.c | 41 +-- configs/sandbox_defconfig | 5 + drivers/block/fsl_sata.c | 1 + drivers/core/device-remove.c | 22 +- drivers/fpga/ACEX1K.c | 1 + drivers/fpga/virtex2.c | 1 + drivers/fpga/zynqpl.c | 1 + drivers/i2c/adi_i2c.c | 1 + drivers/input/input.c | 1 + drivers/input/keyboard.c | 1 + drivers/misc/cbmem_console.c | 2 +- drivers/mtd/cfi_flash.c | 1 + drivers/mtd/nand/bfin_nand.c | 1 + drivers/net/e1000_spi.c | 1 + drivers/net/keystone_net.c | 1 + drivers/net/phy/phy.c | 1 + drivers/net/vsc7385.c | 1 + drivers/power/battery/bat_trats.c | 1 + drivers/spi/bfin_spi.c | 1 + drivers/spi/bfin_spi6xx.c | 1 + drivers/spi/sh_qspi.c | 1 + drivers/spi/sh_spi.c | 1 + drivers/usb/emul/Makefile | 1 + drivers/usb/emul/sandbox_flash.c | 48 ++-- drivers/usb/emul/sandbox_hub.c | 2 +- drivers/usb/emul/sandbox_keyb.c | 241 ++++++++++++++++++ drivers/usb/emul/usb-emul-uclass.c | 29 ++- drivers/usb/gadget/ether.c | 1 + drivers/usb/gadget/f_mass_storage.c | 1 + drivers/usb/gadget/f_thor.c | 1 + drivers/usb/host/r8a66597-hcd.c | 1 + drivers/usb/host/usb-sandbox.c | 19 ++ drivers/usb/host/usb-uclass.c | 54 +++- drivers/usb/musb-new/musb_uboot.c | 1 + examples/standalone/mem_to_mem_idma2intr.c | 1 + examples/standalone/smc911x_eeprom.c | 1 + include/asm-generic/global_data.h | 6 + include/common.h | 17 -- include/configs/sandbox.h | 3 +- include/console.h | 52 ++++ include/dm/device-internal.h | 26 -- include/dm/device.h | 12 + include/dm/uclass.h | 15 ++ include/linux/usb/ch9.h | 20 ++ include/membuff.h | 246 ++++++++++++++++++ include/usb.h | 29 +++ lib/Makefile | 1 + lib/display_options.c | 2 +- lib/gunzip.c | 1 + lib/membuff.c | 390 +++++++++++++++++++++++++++++ net/net.c | 1 + test/dm/test-main.c | 12 + test/dm/usb.c | 241 ++++++++++++++++++ test/ut.c | 4 + 126 files changed, 1717 insertions(+), 149 deletions(-) create mode 100644 drivers/usb/emul/sandbox_keyb.c create mode 100644 include/console.h create mode 100644 include/membuff.h create mode 100644 lib/membuff.c