Re: [PATCH 1/2] otg/ulpi: bail out on read errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
> Cc: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>

Acked-by: Daniel Mack <daniel@xxxxxxxx>

> Cc: Greg KH <gregkh@xxxxxxx>
> ---
>  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
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux