diff options
author | Roland Hieber <r.hieber@pengutronix.de> | 2018-09-03 21:32:53 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-09-07 07:40:28 +0200 |
commit | 5e176bda94c4ce0721a1ecbdc1604fc9ca6a43e1 (patch) | |
tree | 1cfdc0856b6bbb52cb04133395c994394b7242c0 /scripts | |
parent | 5e6b74924e4cf4967119e854726ab2228080d506 (diff) | |
download | barebox-5e176bda94c4ce0721a1ecbdc1604fc9ca6a43e1.tar.gz barebox-5e176bda94c4ce0721a1ecbdc1604fc9ca6a43e1.tar.xz |
scripts: imx-usb-loader: fail early if the USB device path does not match
find_imx_dev() loops through all USB devices, tries to open them, and
then compares the chosen device path (given with -p on the command line)
to the path of the currently opened device. The device path can be
checked earlier, opening the device is not neccessary.
We fail early here because in the next commit we want to enable the user
to force using a device by specifying its path. Opening every single
device available on the system then leads to unnecessary error messages
for all devices that do not match the provided path.
Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/imx/imx-usb-loader.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c index a88bca0e83..6615ce3ca8 100644 --- a/scripts/imx/imx-usb-loader.c +++ b/scripts/imx/imx-usb-loader.c @@ -307,6 +307,12 @@ static libusb_device *find_imx_dev(libusb_device **devs, const struct mach_id ** return NULL; } + if (location && !device_location_equal(dev, location)) { + libusb_close(usb_dev_handle); + usb_dev_handle = NULL; + continue; + } + p = imx_device_by_usb_id(desc.idVendor, desc.idProduct); if (!p) continue; @@ -318,12 +324,6 @@ static libusb_device *find_imx_dev(libusb_device **devs, const struct mach_id ** continue; } - if (location && !device_location_equal(dev, location)) { - libusb_close(usb_dev_handle); - usb_dev_handle = NULL; - continue; - } - *pp_id = p; return dev; } |