mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
android computer: usb-gadget: support rndis ctrl_request command
This commit is contained in:
8
drivers/usb/gadget/android.c
Normal file → Executable file
8
drivers/usb/gadget/android.c
Normal file → Executable file
@@ -612,6 +612,12 @@ static struct device_attribute *rndis_function_attributes[] = {
|
||||
&dev_attr_vendorID,
|
||||
NULL
|
||||
};
|
||||
static int rndis_function_ctrlrequest(struct android_usb_function *f,
|
||||
struct usb_composite_dev *cdev,
|
||||
const struct usb_ctrlrequest *c)
|
||||
{
|
||||
return rndis_setup(cdev, c);
|
||||
}
|
||||
|
||||
static struct android_usb_function rndis_function = {
|
||||
.name = "rndis",
|
||||
@@ -619,6 +625,7 @@ static struct android_usb_function rndis_function = {
|
||||
.cleanup = rndis_function_cleanup,
|
||||
.bind_config = rndis_function_bind_config,
|
||||
.unbind_config = rndis_function_unbind_config,
|
||||
.ctrlrequest = rndis_function_ctrlrequest,
|
||||
.attributes = rndis_function_attributes,
|
||||
};
|
||||
|
||||
@@ -1320,7 +1327,6 @@ android_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *c)
|
||||
struct android_usb_function *f;
|
||||
int value = -EOPNOTSUPP;
|
||||
unsigned long flags;
|
||||
|
||||
req->zero = 0;
|
||||
req->complete = composite_setup_complete;
|
||||
req->length = 0;
|
||||
|
||||
@@ -794,11 +794,11 @@ static int hidg_ctrlrequest(struct usb_composite_dev *cdev,
|
||||
case ((USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
|
||||
| HID_REQ_GET_REPORT):
|
||||
VDBG(cdev, "get_report\n");
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
/* send an empty report */
|
||||
length = min_t(unsigned, length, hidg->report_length);
|
||||
memset(req->buf, 0x0, length);
|
||||
|
||||
goto respond;
|
||||
break;
|
||||
|
||||
|
||||
17
drivers/usb/gadget/f_rndis.c
Normal file → Executable file
17
drivers/usb/gadget/f_rndis.c
Normal file → Executable file
@@ -100,6 +100,8 @@ struct f_rndis {
|
||||
atomic_t notify_count;
|
||||
};
|
||||
|
||||
struct f_rndis *g_rndis;
|
||||
|
||||
static inline struct f_rndis *func_to_rndis(struct usb_function *f)
|
||||
{
|
||||
return container_of(f, struct f_rndis, port.func);
|
||||
@@ -402,16 +404,16 @@ static void rndis_command_complete(struct usb_ep *ep, struct usb_request *req)
|
||||
}
|
||||
|
||||
static int
|
||||
rndis_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
|
||||
rndis_setup(struct usb_composite_dev *cdev, const struct usb_ctrlrequest *ctrl)
|
||||
{
|
||||
struct f_rndis *rndis = func_to_rndis(f);
|
||||
struct usb_composite_dev *cdev = f->config->cdev;
|
||||
//struct f_rndis *rndis = func_to_rndis(f);
|
||||
//struct usb_composite_dev *cdev = f->config->cdev;
|
||||
struct f_rndis *rndis = g_rndis;
|
||||
struct usb_request *req = cdev->req;
|
||||
int value = -EOPNOTSUPP;
|
||||
u16 w_index = le16_to_cpu(ctrl->wIndex);
|
||||
u16 w_value = le16_to_cpu(ctrl->wValue);
|
||||
u16 w_length = le16_to_cpu(ctrl->wLength);
|
||||
|
||||
/* composite driver infrastructure handles everything except
|
||||
* CDC class messages; interface activation uses set_alt().
|
||||
*/
|
||||
@@ -452,12 +454,13 @@ rndis_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
invalid:
|
||||
VDBG(cdev, "invalid control req%02x.%02x v%04x i%04x l%d\n",
|
||||
ctrl->bRequestType, ctrl->bRequest,
|
||||
w_value, w_index, w_length);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
/* respond with data transfer or status phase? */
|
||||
if (value >= 0) {
|
||||
DBG(cdev, "rndis req%02x.%02x v%04x i%04x l%d\n",
|
||||
@@ -848,9 +851,9 @@ rndis_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
|
||||
rndis->port.func.bind = rndis_bind;
|
||||
rndis->port.func.unbind = rndis_unbind;
|
||||
rndis->port.func.set_alt = rndis_set_alt;
|
||||
rndis->port.func.setup = rndis_setup;
|
||||
//rndis->port.func.setup = rndis_setup;
|
||||
rndis->port.func.disable = rndis_disable;
|
||||
|
||||
g_rndis = rndis;
|
||||
status = usb_add_function(c, &rndis->port.func);
|
||||
if (status) {
|
||||
kfree(rndis);
|
||||
|
||||
Reference in New Issue
Block a user