From: Roland Hieber <r.hieber@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Roland Hieber <r.hieber@pengutronix.de>
Subject: [PATCH 2/4] scripts: imx-usb-loader: fail early if the USB device path does not match
Date: Mon, 3 Sep 2018 21:32:53 +0200 [thread overview]
Message-ID: <20180903193255.27031-3-r.hieber@pengutronix.de> (raw)
In-Reply-To: <20180903193255.27031-1-r.hieber@pengutronix.de>
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>
---
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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-09-03 19:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-03 19:32 [PATCH 0/4] make imx-usb-loader usable for unknown device IDs Roland Hieber
2018-09-03 19:32 ` [PATCH 1/4] scripts: imx-usb-loader: rename imx_device() to imx_device_by_usb_id() Roland Hieber
2018-09-03 19:32 ` Roland Hieber [this message]
2018-09-03 19:32 ` [PATCH 3/4] scripts: imx-usb-loader: allow use of unknown USB IDs Roland Hieber
2018-09-03 19:32 ` [PATCH 4/4] scripts: imx-usb-loader: make i.MX6SoloX better to type Roland Hieber
2018-09-04 8:21 ` [PATCH 0/4] make imx-usb-loader usable for unknown device IDs Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180903193255.27031-3-r.hieber@pengutronix.de \
--to=r.hieber@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox