Loading drivers/staging/greybus/usb.c +32 −12 Original line number Original line Diff line number Diff line Loading @@ -110,21 +110,41 @@ static int hub_status_data(struct usb_hcd *hcd, char *buf) static int hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, static int hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, char *buf, u16 wLength) char *buf, u16 wLength) { { struct gb_usb_hub_control_request request; struct gb_usb_device *dev = to_gb_usb_device(hcd); struct gb_usb_device *dev = to_gb_usb_device(hcd); struct gb_operation *operation; struct gb_usb_hub_control_request *request; struct gb_usb_hub_control_response *response; size_t response_size; int ret; int ret; request.typeReq = cpu_to_le16(typeReq); /* FIXME: handle unspecified lengths */ request.wValue = cpu_to_le16(wValue); response_size = sizeof(*response) + wLength; request.wIndex = cpu_to_le16(wIndex); request.wLength = cpu_to_le16(wLength); operation = gb_operation_create(dev->connection, GB_USB_TYPE_HUB_CONTROL, // FIXME - buf needs to come back in struct gb_usb_hub_control_response sizeof(*request), // for some types of requests, depending on typeReq. Do we do this in a response_size, // "generic" way, or only ask for a response for the ones we "know" need GFP_KERNEL); // a response (a small subset of all valid typeReq, thankfully.) if (!operation) ret = gb_operation_sync(dev->connection, GB_USB_TYPE_HUB_CONTROL, return -ENOMEM; &request, sizeof(request), NULL, 0); request = operation->request->payload; request->typeReq = cpu_to_le16(typeReq); request->wValue = cpu_to_le16(wValue); request->wIndex = cpu_to_le16(wIndex); request->wLength = cpu_to_le16(wLength); ret = gb_operation_request_send_sync(operation); if (ret) goto out; if (wLength) { /* Greybus core has verified response size */ response = operation->response->payload; memcpy(buf, response->buf, wLength); } out: gb_operation_put(operation); return ret; return ret; } } Loading Loading
drivers/staging/greybus/usb.c +32 −12 Original line number Original line Diff line number Diff line Loading @@ -110,21 +110,41 @@ static int hub_status_data(struct usb_hcd *hcd, char *buf) static int hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, static int hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, char *buf, u16 wLength) char *buf, u16 wLength) { { struct gb_usb_hub_control_request request; struct gb_usb_device *dev = to_gb_usb_device(hcd); struct gb_usb_device *dev = to_gb_usb_device(hcd); struct gb_operation *operation; struct gb_usb_hub_control_request *request; struct gb_usb_hub_control_response *response; size_t response_size; int ret; int ret; request.typeReq = cpu_to_le16(typeReq); /* FIXME: handle unspecified lengths */ request.wValue = cpu_to_le16(wValue); response_size = sizeof(*response) + wLength; request.wIndex = cpu_to_le16(wIndex); request.wLength = cpu_to_le16(wLength); operation = gb_operation_create(dev->connection, GB_USB_TYPE_HUB_CONTROL, // FIXME - buf needs to come back in struct gb_usb_hub_control_response sizeof(*request), // for some types of requests, depending on typeReq. Do we do this in a response_size, // "generic" way, or only ask for a response for the ones we "know" need GFP_KERNEL); // a response (a small subset of all valid typeReq, thankfully.) if (!operation) ret = gb_operation_sync(dev->connection, GB_USB_TYPE_HUB_CONTROL, return -ENOMEM; &request, sizeof(request), NULL, 0); request = operation->request->payload; request->typeReq = cpu_to_le16(typeReq); request->wValue = cpu_to_le16(wValue); request->wIndex = cpu_to_le16(wIndex); request->wLength = cpu_to_le16(wLength); ret = gb_operation_request_send_sync(operation); if (ret) goto out; if (wLength) { /* Greybus core has verified response size */ response = operation->response->payload; memcpy(buf, response->buf, wLength); } out: gb_operation_put(operation); return ret; return ret; } } Loading