Skip to contentSkip to conversation

linux-usb:optimize the matching rules and support new switch command for Huawei USB storage devices

PATCH In review fangxiaozhi 00110321 4 participants 12 messages Jan 14, 2013 – Jan 23, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-usb:optimize the matching rules and support new switch command for Huawei USB storage devices

From: fangxiaozhi <[email protected]>

1. Optimize the matching rules with new macro for Huawei USB storage devices, to avoid to load USB storage driver for the modem interface with Huawei devices.
2. Add to support new switch command for new Huawei USB dongles.

--------------------------------------------------------------------

drivers/usb/storage/initializers.c +74 -2
diff -uprN linux-3.8-rc3_orig/drivers/usb/storage/initializers.c linux-3.8-rc3/drivers/usb/storage/initializers.c
@@ -92,8 +92,8 @@ int usb_stor_ucr61s2b_init(struct us_dat
 	return 0;
 }
 
-/* This places the HUAWEI E220 devices in multi-port mode */
-int usb_stor_huawei_e220_init(struct us_data *us)
+/* This places the HUAWEI usb dongles in multi-port mode */
+static int usb_stor_huawei_feature_init(struct us_data *us)
 {
 	int result;
 
@@ -104,3 +104,75 @@ int usb_stor_huawei_e220_init(struct us_
 	US_DEBUGP("Huawei mode set result is %d\n", result);
 	return 0;
 }
+
+/* 
+ * It will send a scsi switch command called rewind' to huawei dongle.
+ * When the dongle receives this command at the first time,
+ * it will reboot immediately. After rebooted, it will ignore this command.
+ * So it is  unnecessary to read its response.
+ */
+static int usb_stor_huawei_scsi_init(struct us_data *us)
+{
+	int result = 0;
+	int act_len = 0;
+	struct bulk_cb_wrap *bcbw = (struct bulk_cb_wrap *) us->iobuf;
+	char rewind_cmd[] = {0x11, 0x06, 0x20, 0x00, 0x00, 0x01, 0x01, 0x00,
+			0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+	
+	bcbw->Signature = cpu_to_le32(US_BULK_CB_SIGN);
+	bcbw->Tag = 0;
+	bcbw->DataTransferLength = 0;
+	bcbw->Flags = bcbw->Lun = 0;
+	bcbw->Length = sizeof(rewind_cmd);
+	memset(bcbw->CDB, 0, sizeof(bcbw->CDB));
+	memcpy(bcbw->CDB, rewind_cmd, sizeof(rewind_cmd));
+
+	result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, bcbw,
+					US_BULK_CB_WRAP_LEN, &act_len);
+	US_DEBUGP("transfer actual length=%d, result=%d\n", act_len, result);
+	return result;
+}
+
+/* 
+ * It tries to find the supported Huawei USB dongles.
+ * In Huawei, they assign the following product IDs
+ * for all of their mobile broadband dongles,
+ * including the new dongles in the future.
+ * So if the product ID is not included in this list,
+ * it means it is not Huawei's mobile broadband dongles.
+ */
+static int usb_stor_huawei_dongles_pid(struct us_data *us)
+{
+	struct usb_interface_descriptor *idesc;
+	int idProduct;
+	
+	idesc = &us->pusb_intf->cur_altsetting->desc;
+	idProduct = us->pusb_dev->descriptor.idProduct;
+	/* The first port is CDROM,
+	 * 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)) {
+			return 1;
+		}
+	}
+	return 0;
+}
+
+int usb_stor_huawei_init(struct us_data *us)
+{
+	int result = 0;
+	
+	if (usb_stor_huawei_dongles_pid(us)) {
+		if (us->pusb_dev->descriptor.idProduct >= 0x1446)
+			result = usb_stor_huawei_scsi_init(us);
+		else
+			result = usb_stor_huawei_feature_init(us);
+	}
+	return result;
+}
drivers/usb/storage/initializers.h +2 -2
diff -uprN linux-3.8-rc3_orig/drivers/usb/storage/initializers.h linux-3.8-rc3/drivers/usb/storage/initializers.h
@@ -46,5 +46,5 @@ int usb_stor_euscsi_init(struct us_data
  * flash reader */
 int usb_stor_ucr61s2b_init(struct us_data *us);
 
-/* This places the HUAWEI E220 devices in multi-port mode */
-int usb_stor_huawei_e220_init(struct us_data *us);
+/* This places the HUAWEI usb dongles in multi-port mode */
+int usb_stor_huawei_init(struct us_data *us);

Binary files linux-3.8-rc3_orig/drivers/usb/storage/initializers.o and linux-3.8-rc3/drivers/usb/storage/initializers.o differ

drivers/usb/storage/unusual_devs.h +2 -327

337 lines not on this page · raw message

maintainer
#1 lore raw

Re: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

Quoted 9 lines · On Mon, Jan 14, 2013 at 10:55:48AM +0800, fangxiaozhi 00110321 wrote:

From: fangxiaozhi <[email protected]>

1. Optimize the matching rules with new macro for Huawei USB storage devices, to avoid to load USB storage driver for the modem interface with Huawei devices.
2. Add to support new switch command for new Huawei USB dongles.

Next time, please always use the scripts/checkpatch.pl tool to find any problems you might have made in your patch (you had trailing whitespace in this one, which I have fixed.)

Also, you might want to use git, it makes creating the patches easier, that way you don't end up with lines in the patch like this one:

Quoted 1 line

Binary files linux-3.8-rc3_orig/drivers/usb/storage/initializers.o and linux-3.8-rc3/drivers/usb/storage/initializers.o differ

thanks,

greg k-h

#2 lore raw

RE: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

Dear Greg:

Quoted 19 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Saturday, January 19, 2013 7:42 AM
To: Fangxiaozhi (Franko)
Cc: [email protected]; [email protected]; Xueguiying (Zihan); Linlei (Lei Lin); Yili (Neil); Wangyuhua (Roger, Credit); Huqiao (C); [email protected]; [email protected]; [email protected]
Subject: Re: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

Quoted 8 lines · On Mon, Jan 14, 2013 at 10:55:48AM +0800, fangxiaozhi 00110321 wrote:

From: fangxiaozhi <[email protected]>

1. Optimize the matching rules with new macro for Huawei USB storage devices, to avoid to load USB storage driver for the modem interface with Huawei devices.
2. Add to support new switch command for new Huawei USB dongles.

Quoted 6 lines
Quoted 1 line

Next time, please always use the scripts/checkpatch.pl tool to find any problems you might have made in your patch (you had trailing whitespace in this one, which I have fixed.)

-----Yes, I have checked my patch with scripts/checkpatch.pl tool before submitting.
-----For this trailing whitespace error, I think that it is better readable to leave whitespace in our patch code. Isn't it?

Quoted 9 lines

Also, you might want to use git, it makes creating the patches easier, that way you don't end up with lines in the patch like this one:

Quoted 2 lines

Binary files linux-3.8-rc3_orig/drivers/usb/storage/initializers.o and linux-3.8-rc3/drivers/usb/storage/initializers.o differ

thanks,

greg k-h

Best Regards,
Franko Fang ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

maintainer
#3 lore raw

Re: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

Quoted 21 lines · Fangxiaozhi (Franko)

Dear Greg:

Quoted 19 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Saturday, January 19, 2013 7:42 AM
To: Fangxiaozhi (Franko)
Cc: [email protected]; [email protected]; Xueguiying (Zihan); Linlei (Lei Lin); Yili (Neil); Wangyuhua (Roger, Credit); Huqiao (C); [email protected]; [email protected]; [email protected]
Subject: Re: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

Quoted 8 lines · On Mon, Jan 14, 2013 at 10:55:48AM +0800, fangxiaozhi 00110321 wrote:

From: fangxiaozhi <[email protected]>

1. Optimize the matching rules with new macro for Huawei USB storage devices, to avoid to load USB storage driver for the modem interface with Huawei devices.
2. Add to support new switch command for new Huawei USB dongles.

Quoted 7 lines
Quoted 6 lines
Quoted 1 line

Next time, please always use the scripts/checkpatch.pl tool to find any problems you might have made in your patch (you had trailing whitespace in this one, which I have fixed.)

-----Yes, I have checked my patch with scripts/checkpatch.pl tool before submitting.

Then where did the trailing whitespace come from?

Quoted 2 lines

-----For this trailing whitespace error, I think that it is better readable to leave whitespace in our patch code. Isn't it?

Not at the end of lines for no reason, right?

Please fix up and resend.

thanks,

greg k-h

#4 lore raw

Re: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

In reply to fangxiaozhi 00110321
Quoted 9 lines · On Mon, Jan 14, 2013 at 10:55:48AM +0800, fangxiaozhi 00110321 wrote:

From: fangxiaozhi <[email protected]>

1. Optimize the matching rules with new macro for Huawei USB storage devices, to avoid to load USB storage driver for the modem interface with Huawei devices.
2. Add to support new switch command for new Huawei USB dongles.

This patch breaks the build, did you test it out?

I get the following errors:

drivers/usb/storage/unusual_devs.h:1530:1: error: implicit declaration of function ‘UNUSUAL_VENDOR_INTF’ [-Werror=implicit-function-declaration] drivers/usb/storage/unusual_devs.h:1534:3: warning: missing braces around initializer [-Wmissing-braces] drivers/usb/storage/unusual_devs.h:1534:3: warning: (near initialization for ‘us_unusual_dev_list[186]’) [-Wmissing-braces] drivers/usb/storage/unusual_devs.h:1534:3: error: initializer element is not constant drivers/usb/storage/unusual_devs.h:1534:3: error: (near initialization for ‘us_unusual_dev_list[186].vendorName’) drivers/usb/storage/unusual_devs.h:1537:1: warning: braces around scalar initializer [enabled by default]

And it goes on and on...

Care to fix this up and resend it?

thanks,

greg k-h

#5 lore raw

Re: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

Hi,

Quoted 22 lines · Greg KH
Quoted 9 lines · On Mon, Jan 14, 2013 at 10:55:48AM +0800, fangxiaozhi 00110321 wrote:

From: fangxiaozhi <[email protected]>

1. Optimize the matching rules with new macro for Huawei USB storage devices, to avoid to load USB storage driver for the modem interface with Huawei devices.
2. Add to support new switch command for new Huawei USB dongles.

This patch breaks the build, did you test it out?

I get the following errors:

drivers/usb/storage/unusual_devs.h:1530:1: error: implicit declaration of function ‘UNUSUAL_VENDOR_INTF’ [-Werror=implicit-function-declaration] drivers/usb/storage/unusual_devs.h:1534:3: warning: missing braces around initializer [-Wmissing-braces] drivers/usb/storage/unusual_devs.h:1534:3: warning: (near initialization for ‘us_unusual_dev_list[186]’) [-Wmissing-braces] drivers/usb/storage/unusual_devs.h:1534:3: error: initializer element is not constant drivers/usb/storage/unusual_devs.h:1534:3: error: (near initialization for ‘us_unusual_dev_list[186].vendorName’) drivers/usb/storage/unusual_devs.h:1537:1: warning: braces around scalar initializer [enabled by default]

Quoted 3 lines

And it goes on and on...

Care to fix this up and resend it?

Before resending make sure to scripts/checkpatch.pl and compile with make C=1 for your ARM platform and x86 with allyesconfig, allnoconfig and allmodconfig. In summary, follow Documentation/SubmitChecklist.

Signature · 1 line
balbi
#6 lore raw

RE: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

In reply to Greg KH

Dear Greg:

Quoted 38 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Saturday, January 19, 2013 7:44 AM
To: Fangxiaozhi (Franko)
Cc: [email protected]; [email protected]; Xueguiying (Zihan); Linlei (Lei Lin); Yili (Neil); Wangyuhua (Roger, Credit); Huqiao (C); [email protected]; [email protected]; [email protected]
Subject: Re: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

Quoted 9 lines · On Mon, Jan 14, 2013 at 10:55:48AM +0800, fangxiaozhi 00110321 wrote:

From: fangxiaozhi <[email protected]>

1. Optimize the matching rules with new macro for Huawei USB storage devices, to avoid to load USB storage driver for the modem interface with Huawei devices.
2. Add to support new switch command for new Huawei USB dongles.

This patch breaks the build, did you test it out?

I get the following errors:

drivers/usb/storage/unusual_devs.h:1530:1: error: implicit declaration of function ‘UNUSUAL_VENDOR_INTF’ [-Werror=implicit-function-declaration] drivers/usb/storage/unusual_devs.h:1534:3: warning: missing braces around initializer [-Wmissing-braces] drivers/usb/storage/unusual_devs.h:1534:3: warning: (near initialization for ‘us_unusual_dev_list[186]’) [-Wmissing-braces] drivers/usb/storage/unusual_devs.h:1534:3: error: initializer element is not constant
drivers/usb/storage/unusual_devs.h:1534:3: error: (near initialization for ‘us_unusual_dev_list[186].vendorName’) drivers/usb/storage/unusual_devs.h:1537:1: warning: braces around scalar initializer [enabled by default]

Quoted 1 line

And it goes on and on...

----------The macro define, please see another patch:

	[PATCH 1/1]linux-usb:Define a new macro for USB storage match rules
	http://www.spinics.net/lists/linux-usb/msg76629.html
Quoted 5 lines

Care to fix this up and resend it?

thanks,

greg k-h

Best Regards,
Franko Fang ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#7 lore raw

Re: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

Quoted 17 lines · Fangxiaozhi (Franko)

Dear Greg:

Quoted 15 lines

I get the following errors:

drivers/usb/storage/unusual_devs.h:1530:1: error: implicit declaration of function ‘UNUSUAL_VENDOR_INTF’ [-Werror=implicit-function-declaration] drivers/usb/storage/unusual_devs.h:1534:3: warning: missing braces around initializer [-Wmissing-braces] drivers/usb/storage/unusual_devs.h:1534:3: warning: (near initialization for ‘us_unusual_dev_list[186]’) [-Wmissing-braces] drivers/usb/storage/unusual_devs.h:1534:3: error: initializer element is not constant
drivers/usb/storage/unusual_devs.h:1534:3: error: (near initialization for ‘us_unusual_dev_list[186].vendorName’) drivers/usb/storage/unusual_devs.h:1537:1: warning: braces around scalar initializer [enabled by default]

Quoted 4 lines
Quoted 1 line

And it goes on and on...

----------The macro define, please see another patch:

	[PATCH 1/1]linux-usb:Define a new macro for USB storage match rules
	http://www.spinics.net/lists/linux-usb/msg76629.html

Please resend it, I do not have this patch anymore in my queue. Remember, I asked you to resend everything that was needed, with the proper ordering.

Please resend all patches, properly fixed up, that you wish to see applied.

thanks,

greg k-h

#8 lore raw

RE: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

Dear Greg:

OK, I have fixed up and resend the patches based on linux-3.8-rc4 today.

Email subjects:
1. [PATCH 1/2]linux-usb:define new macro and add new match rules for Huawei USB storage devices
2. [PATCH 2/2]linux-usb:define new macro and add new match rules for Huawei USB storage devices

Please apply them, thank you very much.

Best Regards,
Franko Fang

Quoted 40 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Tuesday, January 22, 2013 1:12 AM
To: Fangxiaozhi (Franko)
Cc: [email protected]; [email protected]; Xueguiying (Zihan); Linlei (Lei Lin); Yili (Neil); Wangyuhua (Roger, Credit); Huqiao (C); [email protected]; [email protected]; [email protected]
Subject: Re: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

Quoted 20 lines · Fangxiaozhi (Franko)

Dear Greg:

Quoted 18 lines

I get the following errors:

drivers/usb/storage/unusual_devs.h:1530:1: error: implicit declaration of function ‘UNUSUAL_VENDOR_INTF’ [-Werror=implicit-function-declaration] drivers/usb/storage/unusual_devs.h:1534:3: warning: missing braces around initializer [-Wmissing-braces] drivers/usb/storage/unusual_devs.h:1534:3: warning: (near initialization for
‘us_unusual_dev_list[186]’) [-Wmissing-braces] drivers/usb/storage/unusual_devs.h:1534:3: error: initializer element is not constant drivers/usb/storage/unusual_devs.h:1534:3: error: (near initialization for ‘us_unusual_dev_list[186].vendorName’) drivers/usb/storage/unusual_devs.h:1537:1: warning: braces around scalar initializer [enabled by default]

Quoted 4 lines
Quoted 1 line

And it goes on and on...

----------The macro define, please see another patch:

	[PATCH 1/1]linux-usb:Define a new macro for USB storage match rules
	http://www.spinics.net/lists/linux-usb/msg76629.html

Please resend it, I do not have this patch anymore in my queue. Remember, I asked you to resend everything that was needed, with the proper ordering.

Quoted 5 lines

Please resend all patches, properly fixed up, that you wish to see applied.

thanks,

greg k-h

���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#9 lore raw

Re: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

Quoted 7 lines · Fangxiaozhi (Franko)

Dear Greg:

OK, I have fixed up and resend the patches based on linux-3.8-rc4 today.

Email subjects:
1. [PATCH 1/2]linux-usb:define new macro and add new match rules for Huawei USB storage devices
2. [PATCH 2/2]linux-usb:define new macro and add new match rules for Huawei USB storage devices

You sent me two patches, both with the same exact Subject: line. That's not ok, please be descriptive in the subject lines as to what each individual patch does, as obviously they both don't do the same thing, right?

Please fix that up and resend the two patches.

thanks,

greg k-h

#10 lore raw

RE: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

Dear Greg:

Quoted 17 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Tuesday, January 22, 2013 11:04 PM
To: Fangxiaozhi (Franko)
Cc: [email protected]; [email protected]; Xueguiying (Zihan); Linlei (Lei Lin); Yili (Neil); Wangyuhua (Roger, Credit); Huqiao (C); [email protected]; [email protected]; [email protected]
Subject: Re: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

Quoted 6 lines · Fangxiaozhi (Franko)

Dear Greg:

OK, I have fixed up and resend the patches based on linux-3.8-rc4 today.

Email subjects:
1. [PATCH 1/2]linux-usb:define new macro and add new match rules

Quoted 8 lines

for Huawei USB storage devices

Quoted 1 line

2. [PATCH 2/2]linux-usb:define new macro and add new match rules

for

Quoted 1 line

Huawei USB storage devices

You sent me two patches, both with the same exact Subject: line. That's not ok, please be descriptive in the subject lines as to what each individual patch does, as obviously they both don't do the same thing, right?

----No, they do the same thing, so can I submit them in only one patch?
----(Last time, Sebastian thought that the one patch is too long, so he advised me to separate it into two patches).

Quoted 6 lines

Please fix that up and resend the two patches.

thanks,

greg k-h

Best Regards,
Franko Fang ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#11 lore raw

Re: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

Quoted 21 lines · Fangxiaozhi (Franko)

Dear Greg:

Quoted 19 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Tuesday, January 22, 2013 11:04 PM
To: Fangxiaozhi (Franko)
Cc: [email protected]; [email protected]; Xueguiying (Zihan); Linlei (Lei Lin); Yili (Neil); Wangyuhua (Roger, Credit); Huqiao (C); [email protected]; [email protected]; [email protected]
Subject: Re: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

Quoted 6 lines · Fangxiaozhi (Franko)

Dear Greg:

OK, I have fixed up and resend the patches based on linux-3.8-rc4 today.

Email subjects:
1. [PATCH 1/2]linux-usb:define new macro and add new match rules

for Huawei USB storage devices

Quoted 1 line

2. [PATCH 2/2]linux-usb:define new macro and add new match rules

Quoted 8 lines
Quoted 6 lines

for

Quoted 1 line

Huawei USB storage devices

You sent me two patches, both with the same exact Subject: line. That's not ok, please be descriptive in the subject lines as to what each individual patch does, as obviously they both don't do the same thing, right?

----No, they do the same thing, so can I submit them in only one patch?

No they do not do the same thing, they both do different things. Together, they do one thing, but you have to show the steps involved to achieve that goal.

Quoted 2 lines

----(Last time, Sebastian thought that the one patch is too long, so he advised me to separate it into two patches).

He is correct, they need to be in two patches, but again, you can't call them the same thing.

Please read the file, Documentation/SubmittingPatches for how to do this properly.

thanks,

greg k-h