--- zzzz-none-000/linux-3.10.107/drivers/usb/serial/option.c 2017-06-27 09:49:32.000000000 +0000 +++ vr9-7490-729/linux-3.10.107/drivers/usb/serial/option.c 2021-11-10 11:53:55.000000000 +0000 @@ -43,6 +43,22 @@ #include #include "usb-wwan.h" + +/*== AVM/WK 20150420 Patch ported from AVM Kernel 2.6.32 == +**== 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); @@ -519,6 +535,16 @@ #define VIATELECOM_VENDOR_ID 0x15eb #define VIATELECOM_PRODUCT_CDS7 0x0001 +/*== AVM/WK 20150420 Patch ported from AVM Kernel 2.6.32 == +**== Use params instead of default tables ==*/ +#ifdef OPTION_USE_ID_PARAMS +static struct usb_device_id option_ids[] = { + { }, /* Optional parameter entry */ + { } /* Terminating entry */ +}; + +#else + /* some devices interfaces need special handling due to a number of reasons */ enum option_blacklist_reason { OPTION_BLACKLIST_NONE = 0, @@ -1844,6 +1870,8 @@ { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) }, { } /* Terminating entry */ }; +#endif + MODULE_DEVICE_TABLE(usb, option_ids); /* The card has three separate interfaces, which the serial driver @@ -1888,8 +1916,38 @@ u8 bInterfaceNumber; }; +/*== AVM/WK 20150420 Patch ported from AVM Kernel 2.6.32 == +**== 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 + +/*== AVM/WK 20150420 AVM Patch == */ +#ifdef OPTION_USE_ID_PARAMS +#define is_blacklisted(a,b,c) 0 +#else static bool is_blacklisted(const u8 ifnum, enum option_blacklist_reason reason, const struct option_blacklist_info *blacklist) { @@ -1913,6 +1971,7 @@ } return false; } +#endif static int option_probe(struct usb_serial *serial, const struct usb_device_id *id) @@ -1935,6 +1994,36 @@ OPTION_BLACKLIST_RESERVED_IF, (const struct option_blacklist_info *) id->driver_info)) return -ENODEV; + +/*== AVM/WK 20150420 Patch ported from AVM Kernel 2.6.32 +**== 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.