Commit 7b4a0367 authored by Wolfram Sang's avatar Wolfram Sang Committed by Greg Kroah-Hartman

USB: otg/ulpi: bail out on read errors

otg_read may return errnos, so bail out correctly to prevent bogus
ID-numbers.
Signed-off-by: default avatarWolfram Sang <w.sang@pengutronix.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: default avatarDaniel Mack <daniel@caiaq.de>
Cc: stable <stable@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 2bb14cbf
...@@ -59,12 +59,17 @@ static int ulpi_set_flags(struct otg_transceiver *otg) ...@@ -59,12 +59,17 @@ static int ulpi_set_flags(struct otg_transceiver *otg)
static int ulpi_init(struct otg_transceiver *otg) static int ulpi_init(struct otg_transceiver *otg)
{ {
int i, vid, pid; int i, vid, pid, ret;
u32 ulpi_id = 0;
vid = (otg_io_read(otg, ULPI_VENDOR_ID_HIGH) << 8) |
otg_io_read(otg, ULPI_VENDOR_ID_LOW); for (i = 0; i < 4; i++) {
pid = (otg_io_read(otg, ULPI_PRODUCT_ID_HIGH) << 8) | ret = otg_io_read(otg, ULPI_PRODUCT_ID_HIGH - i);
otg_io_read(otg, ULPI_PRODUCT_ID_LOW); if (ret < 0)
return ret;
ulpi_id = (ulpi_id << 8) | ret;
}
vid = ulpi_id & 0xffff;
pid = ulpi_id >> 16;
pr_info("ULPI transceiver vendor/product ID 0x%04x/0x%04x\n", vid, pid); pr_info("ULPI transceiver vendor/product ID 0x%04x/0x%04x\n", vid, pid);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment