diff options
author | Wolfram Sang <w.sang@pengutronix.de> | 2010-06-15 06:34:22 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-06-30 11:16:06 -0400 |
commit | 7b4a036722cfab2b3922685ad473fac35a55c3fa (patch) | |
tree | 0f3bb015fce2f925c9fb4107dad82c3f6d0380ce /drivers | |
parent | 2bb14cbf04ded4b9e394a6ba9e4f06b82fbac8b2 (diff) |
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: Wolfram Sang <w.sang@pengutronix.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Daniel Mack <daniel@caiaq.de>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/otg/ulpi.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/usb/otg/ulpi.c b/drivers/usb/otg/ulpi.c index b1b34693294..d331b222ad2 100644 --- a/drivers/usb/otg/ulpi.c +++ b/drivers/usb/otg/ulpi.c | |||
@@ -59,12 +59,17 @@ static int ulpi_set_flags(struct otg_transceiver *otg) | |||
59 | 59 | ||
60 | static int ulpi_init(struct otg_transceiver *otg) | 60 | static int ulpi_init(struct otg_transceiver *otg) |
61 | { | 61 | { |
62 | int i, vid, pid; | 62 | int i, vid, pid, ret; |
63 | 63 | u32 ulpi_id = 0; | |
64 | vid = (otg_io_read(otg, ULPI_VENDOR_ID_HIGH) << 8) | | 64 | |
65 | otg_io_read(otg, ULPI_VENDOR_ID_LOW); | 65 | for (i = 0; i < 4; i++) { |
66 | pid = (otg_io_read(otg, ULPI_PRODUCT_ID_HIGH) << 8) | | 66 | ret = otg_io_read(otg, ULPI_PRODUCT_ID_HIGH - i); |
67 | otg_io_read(otg, ULPI_PRODUCT_ID_LOW); | 67 | if (ret < 0) |
68 | return ret; | ||
69 | ulpi_id = (ulpi_id << 8) | ret; | ||
70 | } | ||
71 | vid = ulpi_id & 0xffff; | ||
72 | pid = ulpi_id >> 16; | ||
68 | 73 | ||
69 | pr_info("ULPI transceiver vendor/product ID 0x%04x/0x%04x\n", vid, pid); | 74 | pr_info("ULPI transceiver vendor/product ID 0x%04x/0x%04x\n", vid, pid); |
70 | 75 | ||