[PATCH 2/4] scripts: imx-usb-loader: fail early if the USB device path does not match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 scripts/imx/imx-usb-loader.c | 12 ++++++------
 1 file 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;
 	}
-- 
2.18.0


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux