Skip to content

Commit

Permalink
USB: otg/ulpi: bail out on read errors
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Wolfram Sang authored and Greg Kroah-Hartman committed Jun 30, 2010
1 parent 2bb14cb commit 7b4a036
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions drivers/usb/otg/ulpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 7b4a036

Please sign in to comment.