Commit 0fd43d0c authored by David S. Miller's avatar David S. Miller

Merge branch 'r8152-NCM-firmwares'

Bjørn Mork says:

====================
r8152: allow firmwares with NCM support

Some device and firmware combinations with NCM support will
end up using the cdc_ncm driver by default.  This is sub-
optimal for the same reasons we've previously accepted the
blacklist hack in cdc_ether.

The recent support for subclassing the generic USB device
driver allows us to create a very slim driver with the same
functionality.  This patch set uses that to implement a
device specific configuration default which is independent
of any USB interface drivers.  This means that it works
equally whether the device initially ends up in NCM or ECM
mode, without depending on any code in the respective class
drivers.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 762405e3 69649ef8
......@@ -747,13 +747,6 @@ static const struct usb_device_id products[] = {
.driver_info = 0,
},
/* Realtek RTL8152 Based USB 2.0 Ethernet Adapters */
{
USB_DEVICE_AND_INTERFACE_INFO(REALTEK_VENDOR_ID, 0x8152, USB_CLASS_COMM,
USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
.driver_info = 0,
},
/* Realtek RTL8153 Based USB 3.0 Ethernet Adapters */
{
USB_DEVICE_AND_INTERFACE_INFO(REALTEK_VENDOR_ID, 0x8153, USB_CLASS_COMM,
......@@ -761,71 +754,6 @@ static const struct usb_device_id products[] = {
.driver_info = 0,
},
/* Samsung USB Ethernet Adapters */
{
USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, 0xa101, USB_CLASS_COMM,
USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
.driver_info = 0,
},
#if IS_ENABLED(CONFIG_USB_RTL8152)
/* Linksys USB3GIGV1 Ethernet Adapter */
{
USB_DEVICE_AND_INTERFACE_INFO(LINKSYS_VENDOR_ID, 0x0041, USB_CLASS_COMM,
USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
.driver_info = 0,
},
#endif
/* Lenovo ThinkPad OneLink+ Dock (based on Realtek RTL8153) */
{
USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x3054, USB_CLASS_COMM,
USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
.driver_info = 0,
},
/* ThinkPad USB-C Dock (based on Realtek RTL8153) */
{
USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x3062, USB_CLASS_COMM,
USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
.driver_info = 0,
},
/* ThinkPad Thunderbolt 3 Dock (based on Realtek RTL8153) */
{
USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x3069, USB_CLASS_COMM,
USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
.driver_info = 0,
},
/* ThinkPad Thunderbolt 3 Dock Gen 2 (based on Realtek RTL8153) */
{
USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x3082, USB_CLASS_COMM,
USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
.driver_info = 0,
},
/* Lenovo Thinkpad USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */
{
USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x7205, USB_CLASS_COMM,
USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
.driver_info = 0,
},
/* Lenovo USB C to Ethernet Adapter (based on Realtek RTL8153) */
{
USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x720c, USB_CLASS_COMM,
USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
.driver_info = 0,
},
/* Lenovo USB-C Travel Hub (based on Realtek RTL8153) */
{
USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x7214, USB_CLASS_COMM,
USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
.driver_info = 0,
},
/* Lenovo Powered USB-C Travel Hub (4X90S92381, based on Realtek RTL8153) */
{
USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x721e, USB_CLASS_COMM,
......@@ -833,48 +761,6 @@ static const struct usb_device_id products[] = {
.driver_info = 0,
},
/* ThinkPad USB-C Dock Gen 2 (based on Realtek RTL8153) */
{
USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0xa387, USB_CLASS_COMM,
USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
.driver_info = 0,
},
/* NVIDIA Tegra USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */
{
USB_DEVICE_AND_INTERFACE_INFO(NVIDIA_VENDOR_ID, 0x09ff, USB_CLASS_COMM,
USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
.driver_info = 0,
},
/* Microsoft Surface 2 dock (based on Realtek RTL8152) */
{
USB_DEVICE_AND_INTERFACE_INFO(MICROSOFT_VENDOR_ID, 0x07ab, USB_CLASS_COMM,
USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
.driver_info = 0,
},
/* Microsoft Surface Ethernet Adapter (based on Realtek RTL8153) */
{
USB_DEVICE_AND_INTERFACE_INFO(MICROSOFT_VENDOR_ID, 0x07c6, USB_CLASS_COMM,
USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
.driver_info = 0,
},
/* Microsoft Surface Ethernet Adapter (based on Realtek RTL8153B) */
{
USB_DEVICE_AND_INTERFACE_INFO(MICROSOFT_VENDOR_ID, 0x0927, USB_CLASS_COMM,
USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
.driver_info = 0,
},
/* TP-LINK UE300 USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */
{
USB_DEVICE_AND_INTERFACE_INFO(TPLINK_VENDOR_ID, 0x0601, USB_CLASS_COMM,
USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
.driver_info = 0,
},
/* Aquantia AQtion USB to 5GbE Controller (based on AQC111U) */
{
USB_DEVICE_AND_INTERFACE_INFO(AQUANTIA_VENDOR_ID, 0xc101,
......
......@@ -9618,6 +9618,9 @@ static int rtl8152_probe(struct usb_interface *intf,
if (version == RTL_VER_UNKNOWN)
return -ENODEV;
if (intf->cur_altsetting->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC)
return -ENODEV;
if (!rtl_vendor_mode(intf))
return -ENODEV;
......@@ -9814,42 +9817,34 @@ static void rtl8152_disconnect(struct usb_interface *intf)
}
}
#define REALTEK_USB_DEVICE(vend, prod) { \
USB_DEVICE_INTERFACE_CLASS(vend, prod, USB_CLASS_VENDOR_SPEC), \
}, \
{ \
USB_DEVICE_AND_INTERFACE_INFO(vend, prod, USB_CLASS_COMM, \
USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), \
}
/* table of devices that work with this driver */
static const struct usb_device_id rtl8152_table[] = {
/* Realtek */
REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8050),
REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8053),
REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8152),
REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8153),
REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8155),
REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8156),
{ USB_DEVICE(VENDOR_ID_REALTEK, 0x8050) },
{ USB_DEVICE(VENDOR_ID_REALTEK, 0x8053) },
{ USB_DEVICE(VENDOR_ID_REALTEK, 0x8152) },
{ USB_DEVICE(VENDOR_ID_REALTEK, 0x8153) },
{ USB_DEVICE(VENDOR_ID_REALTEK, 0x8155) },
{ USB_DEVICE(VENDOR_ID_REALTEK, 0x8156) },
/* Microsoft */
REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07ab),
REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07c6),
REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x0927),
REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101),
REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f),
REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3054),
REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3062),
REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3069),
REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3082),
REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7205),
REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x720c),
REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7214),
REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x721e),
REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0xa387),
REALTEK_USB_DEVICE(VENDOR_ID_LINKSYS, 0x0041),
REALTEK_USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff),
REALTEK_USB_DEVICE(VENDOR_ID_TPLINK, 0x0601),
{ USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07ab) },
{ USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07c6) },
{ USB_DEVICE(VENDOR_ID_MICROSOFT, 0x0927) },
{ USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101) },
{ USB_DEVICE(VENDOR_ID_LENOVO, 0x304f) },
{ USB_DEVICE(VENDOR_ID_LENOVO, 0x3054) },
{ USB_DEVICE(VENDOR_ID_LENOVO, 0x3062) },
{ USB_DEVICE(VENDOR_ID_LENOVO, 0x3069) },
{ USB_DEVICE(VENDOR_ID_LENOVO, 0x3082) },
{ USB_DEVICE(VENDOR_ID_LENOVO, 0x7205) },
{ USB_DEVICE(VENDOR_ID_LENOVO, 0x720c) },
{ USB_DEVICE(VENDOR_ID_LENOVO, 0x7214) },
{ USB_DEVICE(VENDOR_ID_LENOVO, 0x721e) },
{ USB_DEVICE(VENDOR_ID_LENOVO, 0xa387) },
{ USB_DEVICE(VENDOR_ID_LINKSYS, 0x0041) },
{ USB_DEVICE(VENDOR_ID_NVIDIA, 0x09ff) },
{ USB_DEVICE(VENDOR_ID_TPLINK, 0x0601) },
{}
};
......@@ -9869,7 +9864,61 @@ static struct usb_driver rtl8152_driver = {
.disable_hub_initiated_lpm = 1,
};
module_usb_driver(rtl8152_driver);
static int rtl8152_cfgselector_probe(struct usb_device *udev)
{
struct usb_host_config *c;
int i, num_configs;
/* The vendor mode is not always config #1, so to find it out. */
c = udev->config;
num_configs = udev->descriptor.bNumConfigurations;
for (i = 0; i < num_configs; (i++, c++)) {
struct usb_interface_descriptor *desc = NULL;
if (!c->desc.bNumInterfaces)
continue;
desc = &c->intf_cache[0]->altsetting->desc;
if (desc->bInterfaceClass == USB_CLASS_VENDOR_SPEC)
break;
}
if (i == num_configs)
return -ENODEV;
if (usb_set_configuration(udev, c->desc.bConfigurationValue)) {
dev_err(&udev->dev, "Failed to set configuration %d\n",
c->desc.bConfigurationValue);
return -ENODEV;
}
return 0;
}
static struct usb_device_driver rtl8152_cfgselector_driver = {
.name = MODULENAME "-cfgselector",
.probe = rtl8152_cfgselector_probe,
.id_table = rtl8152_table,
.generic_subclass = 1,
};
static int __init rtl8152_driver_init(void)
{
int ret;
ret = usb_register_device_driver(&rtl8152_cfgselector_driver, THIS_MODULE);
if (ret)
return ret;
return usb_register(&rtl8152_driver);
}
static void __exit rtl8152_driver_exit(void)
{
usb_deregister(&rtl8152_driver);
usb_deregister_device_driver(&rtl8152_cfgselector_driver);
}
module_init(rtl8152_driver_init);
module_exit(rtl8152_driver_exit);
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment