All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1]linux-usb: fix the product IDs to be little endian in initializers.c
@ 2013-02-06  9:24 fangxiaozhi 00110321
  2013-02-06 17:46 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: fangxiaozhi 00110321 @ 2013-02-06  9:24 UTC (permalink / raw)
  To: linux-usb
  Cc: linux-kernel, zihan, Lin.Lei, greg, neil.yi, wangyuhua, huqiao36,
	balbi, mdharm-usb, sebastian

From: fangxiaozhi <huananhu@huawei.com>

1. The idProduct is little endian, so make the product ID's value to be little endian. Make no break on big endian processors.

Signed-off-by: fangxiaozhi <huananhu@huawei.com>
--------------------------------------------------------------------

diff -uprN linux-3.8-rc6_orig/drivers/usb/storage/initializers.c linux-3.8-rc6/drivers/usb/storage/initializers.c
--- linux-3.8-rc6_orig/drivers/usb/storage/initializers.c	2013-02-06 14:48:51.564355283 +0800
+++ linux-3.8-rc6/drivers/usb/storage/initializers.c	2013-02-06 15:11:40.925434289 +0800
@@ -152,12 +152,15 @@ static int usb_stor_huawei_dongles_pid(s
 	 * means the dongle in the single port mode,
 	 * and a switch command is required to be sent. */
 	if (idesc && idesc->bInterfaceNumber == 0) {
-		if ((idProduct == 0x1001)
-			|| (idProduct == 0x1003)
-			|| (idProduct == 0x1004)
-			|| (idProduct >= 0x1401 && idProduct <= 0x1500)
-			|| (idProduct >= 0x1505 && idProduct <= 0x1600)
-			|| (idProduct >= 0x1c02 && idProduct <= 0x2202)) {
+		if ((idProduct == cpu_to_le16(0x1001))
+			|| (idProduct == cpu_to_le16(0x1003))
+			|| (idProduct == cpu_to_le16(0x1004))
+			|| (idProduct >= cpu_to_le16(0x1401)
+				&& idProduct <= cpu_to_le16(0x1500))
+			|| (idProduct >= cpu_to_le16(0x1505)
+				&& idProduct <= cpu_to_le16(0x1600))
+			|| (idProduct >= cpu_to_le16(0x1c02)
+				&& idProduct <= cpu_to_le16(0x2202))) {
 			return 1;
 		}
 	}
@@ -169,7 +172,7 @@ int usb_stor_huawei_init(struct us_data
 	int result = 0;
 
 	if (usb_stor_huawei_dongles_pid(us)) {
-		if (us->pusb_dev->descriptor.idProduct >= 0x1446)
+		if (us->pusb_dev->descriptor.idProduct >= cpu_to_le16(0x1446))
 			result = usb_stor_huawei_scsi_init(us);
 		else
 			result = usb_stor_huawei_feature_init(us);
 


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

* Re: [PATCH 1/1]linux-usb: fix the product IDs to be little endian in initializers.c
  2013-02-06  9:24 [PATCH 1/1]linux-usb: fix the product IDs to be little endian in initializers.c fangxiaozhi 00110321
@ 2013-02-06 17:46 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2013-02-06 17:46 UTC (permalink / raw)
  To: fangxiaozhi 00110321
  Cc: linux-usb, linux-kernel, zihan, Lin.Lei, neil.yi, wangyuhua,
	huqiao36, balbi, mdharm-usb, sebastian

On Wed, Feb 06, 2013 at 05:24:12PM +0800, fangxiaozhi 00110321 wrote:
> From: fangxiaozhi <huananhu@huawei.com>
> 
> 1. The idProduct is little endian, so make the product ID's value to be little endian. Make no break on big endian processors.
> 
> Signed-off-by: fangxiaozhi <huananhu@huawei.com>
> --------------------------------------------------------------------
> 
> diff -uprN linux-3.8-rc6_orig/drivers/usb/storage/initializers.c linux-3.8-rc6/drivers/usb/storage/initializers.c
> --- linux-3.8-rc6_orig/drivers/usb/storage/initializers.c	2013-02-06 14:48:51.564355283 +0800
> +++ linux-3.8-rc6/drivers/usb/storage/initializers.c	2013-02-06 15:11:40.925434289 +0800
> @@ -152,12 +152,15 @@ static int usb_stor_huawei_dongles_pid(s
>  	 * means the dongle in the single port mode,
>  	 * and a switch command is required to be sent. */
>  	if (idesc && idesc->bInterfaceNumber == 0) {
> -		if ((idProduct == 0x1001)
> -			|| (idProduct == 0x1003)
> -			|| (idProduct == 0x1004)
> -			|| (idProduct >= 0x1401 && idProduct <= 0x1500)
> -			|| (idProduct >= 0x1505 && idProduct <= 0x1600)
> -			|| (idProduct >= 0x1c02 && idProduct <= 0x2202)) {
> +		if ((idProduct == cpu_to_le16(0x1001))

No, this doesn't fix the sparse warning, and is way too complex (and
doesn't really work well either.)

Please do the conversion on the value when you assign it to idProduct
and then you will be fine.

Please run sparse on your patch to ensure you got it right, if you would
have done so here, it would have been pretty obvious.

thanks,

greg k-h

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

end of thread, other threads:[~2013-02-06 17:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-06  9:24 [PATCH 1/1]linux-usb: fix the product IDs to be little endian in initializers.c fangxiaozhi 00110321
2013-02-06 17:46 ` Greg KH

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.