linux-usb: optimize to match the Huawei USB storage devices
Subsystems (2)
PATCH 1/1 linux-usb: optimize to match the Huawei USB storage devices
From: fangxiaozhi <[email protected]>
To optimize the match rules for the Huawei USB storage devices. Avoid to load USB storage driver for modem interface with Huawei devices.
---------------------------------------------------------------------------------
drivers/usb/storage/initializers.c +12 -6
@@ -93,14 +93,20 @@ int usb_stor_ucr61s2b_init(struct us_dat }/* This places the HUAWEI E220 devices in multi-port mode */ -int usb_stor_huawei_e220_init (struct us_data *us) +int usb_stor_huawei_init (struct us_data *us) {int result; +struct usb_interface_descriptor *idesc =NULL ; - result =usb_stor_control_msg (us, us->send_ctrl_pipe, -USB_REQ_SET_FEATURE , -USB_TYPE_STANDARD |USB_RECIP_DEVICE , -0x01 ,0x0 ,NULL ,0x0 ,1000 ); -US_DEBUGP ("Huawei mode set result is %d\n" , result); + idesc = &us->pusb_intf->cur_altsetting->desc; +if (NULL != idesc ) { +if ( (0x0000 == idesc->bInterfaceNumber)) { + result =usb_stor_control_msg (us, us->send_ctrl_pipe, +USB_REQ_SET_FEATURE , +USB_TYPE_STANDARD |USB_RECIP_DEVICE , +0x01 ,0x0 ,NULL ,0x0 ,1000 ); +US_DEBUGP ("Huawei mode set result is %d\n" , result); + } + }return 0 ; }
drivers/usb/storage/initializers.h +1 -1
@@ -47,4 +47,4 @@ int usb_stor_euscsi_init(struct us_dataint 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); +int usb_stor_huawei_init (struct us_data *us);
drivers/usb/storage/unusual_devs.h +132 -132
467 lines not on this page · raw message
drivers/usb/storage/usb.c +11 -1
@@ -100,7 +100,16 @@ MODULE_PARM_DESC(quirks, "supplemental l* restriction. However, if the flag is not present, then you * are free to use as many characters as you like. */ - +#define HW_UNUSUAL_DEV (idVendor, idProduct, cl, sc, pr, \ + vendor_name, product_name, use_protocol, use_transport, \ + init_function, Flags) \ +{ \ + .vendorName = vendor_name, \ + .productName = product_name, \ + .useProtocol = use_protocol, \ + .useTransport = use_transport, \ + .initFunction = init_function, \ +}#define UNUSUAL_DEV (idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \ vendor_name, product_name, use_protocol, use_transport, \ init_function, Flags) \
@@ -128,6 +137,7 @@ static struct us_unusual_dev us_unusual_static struct us_unusual_dev for_dynamic_ids =USUAL_DEV (USB_SC_SCSI ,USB_PR_BULK ); +#undef HW_USUAL_DEV#undef UNUSUAL_DEV#undef COMPLIANT_DEV#undef USUAL_DEV
drivers/usb/storage/usual-tables.c +13 -0
@@ -41,6 +41,18 @@#define USUAL_DEV (useProto, useTrans) \ { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans) } +#define HW_UNUSUAL_DEV (id_vendor, id_product, cl, sc, pr, \ + vendorName, productName,useProtocol, useTransport, \ + initFunction, flags) \ +{ \ + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO | USB_DEVICE_ID_MATCH_DEVICE, \ + .idVendor = (id_vendor), \ + .idProduct = (id_product), \ + .bInterfaceClass = (cl), \ + .bInterfaceSubClass = (sc), \ + .bInterfaceProtocol = (pr), \ + .driver_info = (flags) } +struct usb_device_id usb_storage_usb_ids[] = { # include "unusual_devs.h" { }/* Terminating entry */
@@ -50,6 +62,7 @@ MODULE_DEVICE_TABLE(usb, usb_storage_usb#undef UNUSUAL_DEV#undef COMPLIANT_DEV#undef USUAL_DEV +#undef HW_UNUSUAL_DEV/* * The table of devices to ignore
******************************************************************************************
This email and its attachments contain confidential information from HUAWEI, which is intended only for the person or entity whose address is listed above. Any use of the information contained here in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this email in error, please notify the sender by phone or email immediately and delete it!
*****************************************************************************************
Alan Stern
maintainerQuoted 11 lines · On Tue, 11 Dec 2012, fangxiaozhi 00110321 wrote:
From: fangxiaozhi <[email protected]>
To optimize the match rules for the Huawei USB storage devices. Avoid to load USB storage driver for modem interface with Huawei devices.
Signed-off-by fangxiaozhi <[email protected]>---------------------------------------------------------------------------------
diff -uprNlinux-3.7_bak/drivers/usb/storage/initializers.clinux-3.7/drivers/usb/storage/initializers.c
drivers/usb/storage/initializers.c int usb_stor_ucr61s2b_init(struct us_dat · line 96
Quoted 5 lines
drivers/usb/storage/initializers.c +1
-1@@ -93,14 +93,20 @@ int usb_stor_ucr61s2b_init(struct us_dat }/* This places the HUAWEI E220 devices in multi-port mode */ -int usb_stor_huawei_e220_init (struct us_data *us) +int usb_stor_huawei_init (struct us_data *us)
If this routine is no longer meant for E220 devices, shouldn't the comment be changed?
drivers/usb/storage/initializers.c int usb_stor_ucr61s2b_init(struct us_dat · line 103
Quoted 12 lines
drivers/usb/storage/initializers.c +4
-5{int result; +struct usb_interface_descriptor *idesc =NULL ; - result =usb_stor_control_msg (us, us->send_ctrl_pipe, -USB_REQ_SET_FEATURE , -USB_TYPE_STANDARD |USB_RECIP_DEVICE , -0x01 ,0x0 ,NULL ,0x0 ,1000 ); -US_DEBUGP ("Huawei mode set result is %d\n" , result); + idesc = &us->pusb_intf->cur_altsetting->desc; +if (NULL != idesc ) { +if ( (0x0000 == idesc->bInterfaceNumber)) {
You could write:
if (idesc != NULL && idesc->bInterfaceNumber == 0) {Quoted 13 lines
drivers/usb/storage/initializers.c +7
-0+ result =usb_stor_control_msg (us, us->send_ctrl_pipe, +USB_REQ_SET_FEATURE , +USB_TYPE_STANDARD |USB_RECIP_DEVICE , +0x01 ,0x0 ,NULL ,0x0 ,1000 ); +US_DEBUGP ("Huawei mode set result is %d\n" , result); + } + }return 0 ; }
drivers/usb/storage/unusual_devs.h UNUSUAL_DEV( 0x1210, 0x0003, 0x0100, 0x · line 1530
Quoted 5 lines
drivers/usb/storage/unusual_devs.h +1
-1@@ -1527,335 +1527,335 @@ UNUSUAL_DEV( 0x1210, 0x0003, 0x0100, 0x/* Reported by fangxiaozhi <[email protected]> * This brings the HUAWEI data card devices into multi-port mode */ -UNUSUAL_DEV( 0x12d1, 0x1001, 0x0000, 0x0000, +HW_UNUSUAL_DEV( 0x12d1, 0x1001, 0x08, 0x06, 0x50,
Where does the name "HW_UNUSUAL_DEV" come from? You should use a better name, something that indicates what it is for. And bear in mind that this new macro could be used for other devices, not just Huawei's. Maybe something like UNUSUAL_DEV_INTF.
Alan Stern