[PATCH experimental 6/6] net: usb: qmi_wwan: add support for devices sharing interface for QMI and wwan

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Bjørn Mork <bjorn@xxxxxxx>
---
 drivers/net/usb/qmi_wwan.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 739e6de..3fd1afb 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -13,6 +13,7 @@
 #include <linux/usb.h>
 #include <linux/usb/cdc.h>
 #include <linux/usb/usbnet.h>
+#include "../../usb/class/cdc-wdm.h"
 
 /* The name of the CDC Device Management driver */
 #define DM_DRIVER "cdc_wdm"
@@ -170,6 +171,31 @@ err:
 	return status;
 }
 
+static int qmi_wwan_bind_shared(struct usbnet *dev, struct usb_interface *intf)
+{
+	int rv = -1;
+	struct usb_driver *subdriver;
+
+	subdriver = wdm_register(intf, 512);
+	if (IS_ERR(subdriver)) {
+		rv = PTR_ERR(subdriver);
+		goto err;
+	}
+
+	dev->data[0] = (unsigned long)subdriver;
+	rv = usbnet_get_endpoints(dev, intf);
+	if (rv < 0)
+		wdm_deregister(intf);
+err:
+	return rv;
+}
+
+static void qmi_wwan_unbind_shared(struct usbnet *dev, struct usb_interface *intf)
+{
+	dev->data[0] = (unsigned long)NULL;
+	wdm_deregister(intf);
+}
+
 /* stolen from cdc_ether.c */
 static int qmi_wwan_manage_power(struct usbnet *dev, int on)
 {
@@ -184,6 +210,14 @@ static const struct driver_info	qmi_wwan_info = {
 	.manage_power	= qmi_wwan_manage_power,
 };
 
+static const struct driver_info	qmi_wwan_shared = {
+	.description	= "QMI speaking wwan device with combined interface",
+	.flags		= FLAG_WWAN,
+	.bind		= qmi_wwan_bind_shared,
+	.unbind		= qmi_wwan_unbind_shared,
+	.manage_power	= qmi_wwan_manage_power,
+};
+
 #define HUAWEI_VENDOR_ID	0x12D1
 
 static const struct usb_device_id products[] = {
@@ -196,6 +230,16 @@ static const struct usb_device_id products[] = {
 	.bInterfaceProtocol = 8, /* NOTE: This is the *slave* interface of the CDC Union! */
 	.driver_info        = (unsigned long)&qmi_wwan_info,
 }, {
+	/* Qmi_Wwan E392, E398, ++? "Windows mode" using a combined
+	 * control and data interface without any CDC functional
+	 * descriptors */
+	.match_flags        = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO,
+	.idVendor           = HUAWEI_VENDOR_ID,
+	.bInterfaceClass    = USB_CLASS_VENDOR_SPEC,
+	.bInterfaceSubClass = 1,
+	.bInterfaceProtocol = 17,
+	.driver_info        = (unsigned long)&qmi_wwan_shared ,
+}, {
 },	/* END */
 };
 MODULE_DEVICE_TABLE(usb, products);
-- 
1.7.8.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux