public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 1/2] otg/ulpi: bail out on read errors
@ 2010-06-15 10:34 Wolfram Sang
  2010-06-15 10:34 ` [PATCH 2/2] ehci-mxc: bail out on transceiver problems Wolfram Sang
  2010-06-15 10:39 ` [PATCH 1/2] otg/ulpi: bail out on read errors Daniel Mack
  0 siblings, 2 replies; 10+ messages in thread
From: Wolfram Sang @ 2010-06-15 10:34 UTC (permalink / raw)
  To: linux-arm-kernel

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>
Cc: Daniel Mack <daniel@caiaq.de>
Cc: Greg KH <gregkh@suse.de>
---
 drivers/usb/otg/ulpi.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/otg/ulpi.c b/drivers/usb/otg/ulpi.c
index b1b3469..d331b22 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);
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-06-16  5:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-15 10:34 [PATCH 1/2] otg/ulpi: bail out on read errors Wolfram Sang
2010-06-15 10:34 ` [PATCH 2/2] ehci-mxc: bail out on transceiver problems Wolfram Sang
2010-06-15 10:43   ` Daniel Mack
2010-06-15 11:03     ` Wolfram Sang
2010-06-15 11:12       ` Daniel Mack
2010-06-15 11:47     ` Philippe Rétornaz
2010-06-15 11:53       ` Daniel Mack
2010-06-16  1:44     ` Wolfram Sang
2010-06-16  5:35       ` Daniel Mack
2010-06-15 10:39 ` [PATCH 1/2] otg/ulpi: bail out on read errors Daniel Mack

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox