--- zzzz-none-000/linux-4.4.60/drivers/usb/serial/option.c 2017-04-08 07:53:53.000000000 +0000 +++ scorpion-7490-727/linux-4.4.60/drivers/usb/serial/option.c 2021-02-04 17:41:59.000000000 +0000 @@ -43,6 +43,21 @@ #include #include "usb-wwan.h" + +/*== 20170316 AVM/VGJ CHANGESET: Specific GSM Device ID == +**== Use params instead of default tables ==*/ +#define OPTION_USE_ID_PARAMS +#ifdef OPTION_USE_ID_PARAMS +static __u16 vendor = 0; +static __u16 product = 0; + +module_param(vendor, ushort, 0); +MODULE_PARM_DESC(vendor, "User specified USB idVendor"); + +module_param(product, ushort, 0); +MODULE_PARM_DESC(product, "User specified USB idProduct"); +#endif + /* Function prototypes */ static int option_probe(struct usb_serial *serial, const struct usb_device_id *id); @@ -541,6 +556,16 @@ #define WETELECOM_PRODUCT_6802 0x6802 #define WETELECOM_PRODUCT_WMD300 0x6803 +/*== 20170316 AVM/VGJ CHANGESET: Specific GSM Device ID == +**== Use params instead of default tables ==*/ +#ifdef OPTION_USE_ID_PARAMS +static struct usb_device_id option_ids[] = { + { }, /* Optional parameter entry */ + { } /* Terminating entry */ +}; + +#else + struct option_blacklist_info { /* bitmask of interface numbers blacklisted for send_setup */ const unsigned long sendsetup; @@ -2025,6 +2050,8 @@ { USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x421d, 0xff, 0xff, 0xff) }, /* HP lt2523 (Novatel E371) */ { } /* Terminating entry */ }; +#endif + MODULE_DEVICE_TABLE(usb, option_ids); /* The card has three separate interfaces, which the serial driver @@ -2064,8 +2091,33 @@ &option_1port_device, NULL }; +/*== 20170316 AVM/VGJ CHANGESET: Specific GSM Device ID == +**== Use params instead of default tables ==*/ +#ifdef OPTION_USE_ID_PARAMS +static int __init option_init(void) +{ + /* == 20180201 AVM/WKR FIX: only check VID, PID==0 is allowed ==*/ + if (vendor > 0 ) { + /* Add user specified VID/PID to reserved element of table. */ + option_ids[0].match_flags = USB_DEVICE_ID_MATCH_DEVICE; + option_ids[0].idVendor = vendor; + option_ids[0].idProduct = product; + } + return usb_serial_register_drivers(serial_drivers, KBUILD_MODNAME, option_ids); +} + +static void __exit option_exit(void) +{ + usb_serial_deregister_drivers(serial_drivers); +} + +module_init(option_init); +module_exit(option_exit); + +#else module_usb_serial_driver(serial_drivers, option_ids); +#endif static int option_probe(struct usb_serial *serial, const struct usb_device_id *id) { @@ -2084,9 +2136,43 @@ * the Windows driver .INF files for reserved interface numbers. */ blacklist = (void *)id->driver_info; +/*== 20170316 AVM/VGJ CHANGESET: Specific GSM Device ID == +**== Use params instead of default tables ==*/ +#ifndef OPTION_USE_ID_PARAMS if (blacklist && test_bit(iface_desc->bInterfaceNumber, &blacklist->reserved)) return -ENODEV; +#endif + +/*== 20170316 AVM/VGJ CHANGESET: Specific GSM Device ID == +**== Use params instead of default tables ==*/ +#ifdef OPTION_USE_ID_PARAMS + { + + struct usb_host_interface *host_iface = serial->interface->cur_altsetting; + struct usb_endpoint_descriptor *endpoint; + int num_bulk_out=0; + int num_bulk_in=0; + int i; + + for (i = 0; i < iface_desc->bNumEndpoints; i++) { + endpoint = &host_iface->endpoint[i].desc; + if ((endpoint->bmAttributes & 0x03) == 0x02) { + if (endpoint->bEndpointAddress & 0x80) { + ++num_bulk_in; + } else { + ++num_bulk_out; + } + } + } + + /* we need both directions */ + if (num_bulk_out == 0 || num_bulk_in == 0) { + return -ENODEV; + } + } +#endif + /* * Don't bind network interface on Samsung GT-B3730, it is handled by * a separate module. @@ -2117,8 +2203,13 @@ iface_desc = &serial->interface->cur_altsetting->desc; +/*== 20170316 AVM/VGJ CHANGESET: Specific GSM Device ID == +**== Use params instead of default tables ==*/ +#ifndef OPTION_USE_ID_PARAMS if (!blacklist || !test_bit(iface_desc->bInterfaceNumber, - &blacklist->sendsetup)) { + &blacklist->sendsetup)) +#endif + { data->use_send_setup = 1; } spin_lock_init(&data->susp_lock);