summaryrefslogtreecommitdiffstats
path: root/drivers/usb/otg/ulpi.c
diff options
context:
space:
mode:
authorWolfram Sang <w.sang@pengutronix.de>2010-06-15 12:34:22 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2010-06-30 08:16:06 -0700
commit7b4a036722cfab2b3922685ad473fac35a55c3fa (patch)
tree0f3bb015fce2f925c9fb4107dad82c3f6d0380ce /drivers/usb/otg/ulpi.c
parent2bb14cbf04ded4b9e394a6ba9e4f06b82fbac8b2 (diff)
downloadlinux-7b4a036722cfab2b3922685ad473fac35a55c3fa.tar.bz2
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/usb/otg/ulpi.c')
-rw-r--r--drivers/usb/otg/ulpi.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/usb/otg/ulpi.c b/drivers/usb/otg/ulpi.c
index b1b346932946..d331b222ad21 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)
static int ulpi_init(struct otg_transceiver *otg)
{
- int i, vid, pid;
-
- vid = (otg_io_read(otg, ULPI_VENDOR_ID_HIGH) << 8) |
- otg_io_read(otg, ULPI_VENDOR_ID_LOW);
- pid = (otg_io_read(otg, ULPI_PRODUCT_ID_HIGH) << 8) |
- otg_io_read(otg, ULPI_PRODUCT_ID_LOW);
+ int i, vid, pid, ret;
+ u32 ulpi_id = 0;
+
+ for (i = 0; i < 4; i++) {
+ ret = otg_io_read(otg, ULPI_PRODUCT_ID_HIGH - i);
+ 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);