]> git.baikalelectronics.ru Git - uboot.git/commit
usb: sandbox: Fix emulator device select logic in usb_emul_find_devnum()
authorBin Meng <bmeng.cn@gmail.com>
Sun, 1 Oct 2017 13:19:39 +0000 (06:19 -0700)
committerMarek Vasut <marex@denx.de>
Sun, 1 Oct 2017 14:32:50 +0000 (16:32 +0200)
commit04612aad3a8d15e198223acc292eac1562bea881
treeb9268f5d73b8ed6b0ff5ab58cb24b9bb48b036d7
parent21b7c9984d9ae879046d1e5dbd7a8a5e31f39cc8
usb: sandbox: Fix emulator device select logic in usb_emul_find_devnum()

Current emulator select logic in usb_emul_find_devnum() is to test
the USB address. The USB address of the device being enumerated is
initialized to zero at the beginning of the enumeration process in
usb_setup_device(). At this point, the saved USB address in the
platform data has not been assigned to any valid USB address either.
This means: the logic will select an emulator device according to
its sequence of declaring order in the device tree. Take test.dts
for example, flash-stick@0 will be selected before flash-stick@1.
But unfortunately such logic is wrong.

In fact USB devices show up in a random order during the enumeration
which means usb_emul_find_devnum() may be called on port 3 for keyb@3
before on port 0 for flash-stick@0.

To fix this, we introduce a new emulator uclass specific platdata
to store the USB device's port number on its parent hub, and update
the logic to test the port number instead.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
drivers/usb/emul/sandbox_hub.c
drivers/usb/emul/usb-emul-uclass.c
drivers/usb/host/usb-sandbox.c
include/usb.h