All of lore.kernel.org
 help / color / mirror / Atom feed
From: daniel@caiaq.de (Daniel Mack)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] otg/ulpi: bail out on read errors
Date: Tue, 15 Jun 2010 12:39:45 +0200	[thread overview]
Message-ID: <20100615103945.GD17833@buzzloop.caiaq.de> (raw)
In-Reply-To: <1276598063-3956-1-git-send-email-w.sang@pengutronix.de>

On Tue, Jun 15, 2010 at 12:34:22PM +0200, Wolfram Sang wrote:
> 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: 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
> 

      parent reply	other threads:[~2010-06-15 10:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Daniel Mack [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100615103945.GD17833@buzzloop.caiaq.de \
    --to=daniel@caiaq.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.