usb: gadget: Fix interface descriptor fields for QTI functions

Currently many QTI function drivers are exposing incorrect
interface descriptor fields. Fix the same.

Change-Id: I06bd30c0374d57f7e0fe407e74f89b6e7eaf2db8
Signed-off-by: Ajay Agarwal <ajaya@codeaurora.org>
This commit is contained in:
Ajay Agarwal 2020-04-02 13:31:16 +05:30
parent 497e1f669b
commit dca661a9dd
9 changed files with 66 additions and 36 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2013-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2011, 2013-2020, The Linux Foundation. All rights reserved.
* Linux Foundation chooses to take subject only to the GPLv2 license terms,
* and distributes only under these terms.
*
@ -147,6 +147,7 @@ struct f_cdev_opts {
struct f_cdev *port;
char *func_name;
u8 port_num;
u8 proto;
};
static int major, minors;
@ -169,8 +170,8 @@ static struct usb_interface_descriptor cser_interface_desc = {
/* .bInterfaceNumber = DYNAMIC */
.bNumEndpoints = 3,
.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
.bInterfaceSubClass = 0,
.bInterfaceProtocol = 0,
.bInterfaceSubClass = USB_SUBCLASS_VENDOR_SPEC,
/* .bInterfaceProtocol = DYNAMIC */
/* .iInterface = DYNAMIC */
};
@ -786,6 +787,8 @@ static int usb_cser_bind(struct usb_configuration *c, struct usb_function *f)
struct f_cdev *port = func_to_port(f);
int status;
struct usb_ep *ep;
struct f_cdev_opts *opts =
container_of(f->fi, struct f_cdev_opts, func_inst);
if (cser_string_defs[0].id == 0) {
status = usb_string_id(c->cdev);
@ -799,6 +802,7 @@ static int usb_cser_bind(struct usb_configuration *c, struct usb_function *f)
goto fail;
port->port_usb.data_id = status;
cser_interface_desc.bInterfaceNumber = status;
cser_interface_desc.bInterfaceProtocol = opts->proto;
status = -ENODEV;
ep = usb_ep_autoconfig(cdev->gadget, &cser_fs_in_desc);
@ -2010,6 +2014,9 @@ static int cser_set_inst_name(struct usb_function_instance *f, const char *name)
port->port_usb.send_modem_ctrl_bits = dun_cser_send_ctrl_bits;
port->port_usb.disconnect = dun_cser_disconnect;
port->port_usb.send_break = dun_cser_send_break;
opts->proto = 0x40;
} else {
opts->proto = 0x60;
}
return 0;

View File

@ -2,7 +2,7 @@
* Diag Function Device - Route ARM9 and ARM11 DIAG messages
* between HOST and DEVICE.
* Copyright (C) 2007 Google, Inc.
* Copyright (c) 2008-2018, The Linux Foundation. All rights reserved.
* Copyright (c) 2008-2018, 2020, The Linux Foundation. All rights reserved.
* Author: Brian Swetland <swetland@google.com>
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
@ -68,8 +68,8 @@ static struct usb_interface_descriptor intf_desc = {
.bLength = sizeof(intf_desc),
.bDescriptorType = USB_DT_INTERFACE,
.bNumEndpoints = 2,
.bInterfaceClass = 0xFF,
.bInterfaceSubClass = 0xFF,
.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
.bInterfaceSubClass = USB_SUBCLASS_VENDOR_SPEC,
.bInterfaceProtocol = 0x30,
};

View File

@ -371,8 +371,8 @@ static struct usb_interface_descriptor rmnet_gsi_interface_desc = {
.bDescriptorType = USB_DT_INTERFACE,
.bNumEndpoints = 3,
.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
.bInterfaceSubClass = USB_CLASS_VENDOR_SPEC,
.bInterfaceProtocol = USB_CLASS_VENDOR_SPEC,
.bInterfaceSubClass = USB_SUBCLASS_VENDOR_SPEC,
.bInterfaceProtocol = 0x50,
/* .iInterface = DYNAMIC */
};
@ -1339,9 +1339,9 @@ static struct usb_interface_descriptor qdss_gsi_data_intf_desc = {
.bDescriptorType = USB_DT_INTERFACE,
.bAlternateSetting = 0,
.bNumEndpoints = 1,
.bInterfaceClass = 0xff,
.bInterfaceSubClass = 0xff,
.bInterfaceProtocol = 0xff,
.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
.bInterfaceSubClass = USB_SUBCLASS_VENDOR_SPEC,
.bInterfaceProtocol = 0x80,
};
static struct usb_endpoint_descriptor qdss_gsi_fs_data_desc = {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -45,9 +45,9 @@ static struct usb_interface_descriptor intf_desc = {
.bLength = sizeof(intf_desc),
.bDescriptorType = USB_DT_INTERFACE,
.bNumEndpoints = 2,
.bInterfaceClass = 0xFF,
.bInterfaceSubClass = 0xFF,
.bInterfaceProtocol = 0x30,
.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
.bInterfaceSubClass = USB_SUBCLASS_VENDOR_SPEC,
.bInterfaceProtocol = 0x90,
};
static struct usb_endpoint_descriptor hs_bulk_in_desc = {

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014, 2019, Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, 2019-2020, Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -68,18 +68,18 @@ static struct usb_interface_descriptor intf_in_only_desc = {
.bLength = sizeof(intf_in_only_desc),
.bDescriptorType = USB_DT_INTERFACE,
.bNumEndpoints = 1,
.bInterfaceClass = 0xFF,
.bInterfaceSubClass = 0xFF,
.bInterfaceProtocol = 0x30,
.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
.bInterfaceSubClass = USB_SUBCLASS_VENDOR_SPEC,
/* .bInterfaceProtocol = DYNAMIC */
};
static struct usb_interface_descriptor intf_desc = {
.bLength = sizeof(intf_desc),
.bDescriptorType = USB_DT_INTERFACE,
.bNumEndpoints = 2,
.bInterfaceClass = 0xFF,
.bInterfaceSubClass = 0xFF,
.bInterfaceProtocol = 0x30,
.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
.bInterfaceSubClass = USB_SUBCLASS_VENDOR_SPEC,
/* .bInterfaceProtocol = DYNAMIC */
};
static struct usb_endpoint_descriptor hs_bulk_in_desc = {
@ -1142,6 +1142,15 @@ static int mdm_data_bind(struct usb_configuration *c, struct usb_function *f)
}
data_desc->bInterfaceNumber = usb_interface_id(c, f);
status = bridge_id_to_protocol(id);
if (status < 0) {
pr_err("%s: Invalid port\n", __func__);
return status;
}
data_desc->bInterfaceProtocol = status;
status = usb_string_id(cdev);
if (status < 0)
return status;

View File

@ -1,7 +1,7 @@
/*
* f_qdss.c -- QDSS function Driver
*
* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
* Copyright (c) 2012-2018, 2020, The Linux Foundation. All rights reserved.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -30,9 +30,9 @@ static struct usb_interface_descriptor qdss_data_intf_desc = {
.bDescriptorType = USB_DT_INTERFACE,
.bAlternateSetting = 0,
.bNumEndpoints = 1,
.bInterfaceClass = 0xff,
.bInterfaceSubClass = 0xff,
.bInterfaceProtocol = 0xff,
.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
.bInterfaceSubClass = USB_SUBCLASS_VENDOR_SPEC,
.bInterfaceProtocol = 0x70,
};
static struct usb_endpoint_descriptor qdss_hs_data_desc = {
@ -64,9 +64,9 @@ static struct usb_interface_descriptor qdss_ctrl_intf_desc = {
.bDescriptorType = USB_DT_INTERFACE,
.bAlternateSetting = 0,
.bNumEndpoints = 2,
.bInterfaceClass = 0xff,
.bInterfaceSubClass = 0xff,
.bInterfaceProtocol = 0xff,
.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
.bInterfaceSubClass = USB_SUBCLASS_VENDOR_SPEC,
.bInterfaceProtocol = 0x70,
};
static struct usb_endpoint_descriptor qdss_hs_ctrl_in_desc = {

View File

@ -55,8 +55,8 @@ static struct usb_interface_descriptor rmnet_interface_desc = {
.bDescriptorType = USB_DT_INTERFACE,
.bNumEndpoints = 3,
.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
.bInterfaceSubClass = USB_CLASS_VENDOR_SPEC,
.bInterfaceProtocol = USB_CLASS_VENDOR_SPEC,
.bInterfaceSubClass = USB_SUBCLASS_VENDOR_SPEC,
.bInterfaceProtocol = 0x50,
/* .iInterface = DYNAMIC */
};
@ -215,9 +215,9 @@ static struct usb_interface_descriptor dpl_data_intf_desc = {
.bDescriptorType = USB_DT_INTERFACE,
.bAlternateSetting = 0,
.bNumEndpoints = 1,
.bInterfaceClass = 0xff,
.bInterfaceSubClass = 0xff,
.bInterfaceProtocol = 0xff,
.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
.bInterfaceSubClass = USB_SUBCLASS_VENDOR_SPEC,
.bInterfaceProtocol = 0x80,
};
static struct usb_endpoint_descriptor dpl_fs_data_desc = {

View File

@ -79,7 +79,7 @@ static struct usb_interface_descriptor gser_interface_desc = {
.bNumEndpoints = 3,
.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
.bInterfaceSubClass = 0,
.bInterfaceProtocol = 0,
.bInterfaceProtocol = 0x40,
/* .iInterface = DYNAMIC */
};

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2013, 2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2013, 2019-2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -42,6 +42,20 @@ fail:
return -EINVAL;
}
static int bridge_id_to_protocol(enum bridge_id id)
{
switch (id) {
case USB_BRIDGE_QDSS:
return 0x70;
case USB_BRIDGE_DPL:
return 0x80;
case USB_BRIDGE_EDL:
return 0x10;
default:
return -EINVAL;
}
}
struct bridge_ops {
int (*send_pkt)(void *, void *, size_t actual);