summaryrefslogtreecommitdiff
path: root/class/hid/usbd_hid.c
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2022-10-20 21:22:08 +0800
committersakumisu <[email protected]>2022-10-20 21:22:08 +0800
commitdca8b4cfedd94b34207cacd3f6c43e7e354d34d2 (patch)
tree3c81bb0313a1ef0b3779fb14daa468dbadcfe04e /class/hid/usbd_hid.c
parent731f206254fe25368650f3c85918b2b12f3680a6 (diff)
remove intf malloc
Diffstat (limited to 'class/hid/usbd_hid.c')
-rw-r--r--class/hid/usbd_hid.c64
1 files changed, 1 insertions, 63 deletions
diff --git a/class/hid/usbd_hid.c b/class/hid/usbd_hid.c
index 1f47bb3f..b2659bdf 100644
--- a/class/hid/usbd_hid.c
+++ b/class/hid/usbd_hid.c
@@ -6,62 +6,6 @@
#include "usbd_core.h"
#include "usbd_hid.h"
-static int hid_custom_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
-{
- USB_LOG_DBG("HID Custom request: "
- "bRequest 0x%02x\r\n",
- setup->bRequest);
-
- if (((setup->bmRequestType & USB_REQUEST_DIR_MASK) == USB_REQUEST_DIR_IN) &&
- setup->bRequest == USB_REQUEST_GET_DESCRIPTOR) {
- uint8_t value = (uint8_t)(setup->wValue >> 8);
- uint8_t intf_num = (uint8_t)setup->wIndex;
-
- usb_slist_t *i;
- struct usbd_interface *match_intf = NULL;
-
- usb_slist_for_each(i, &usbd_intf_head)
- {
- struct usbd_interface *intf = usb_slist_entry(i, struct usbd_interface, list);
-
- if (intf->intf_num == intf_num) {
- match_intf = intf;
- break;
- }
- }
-
- if (match_intf == NULL) {
- return -2;
- }
-
- switch (value) {
- case HID_DESCRIPTOR_TYPE_HID:
- USB_LOG_INFO("get HID Descriptor\r\n");
- // *data = (uint8_t *)match_intf->hid_descriptor;
- // *len = match_intf->hid_descriptor[0];
- break;
-
- case HID_DESCRIPTOR_TYPE_HID_REPORT:
- USB_LOG_INFO("get Report Descriptor\r\n");
- *data = (uint8_t *)match_intf->hid_report_descriptor;
- *len = match_intf->hid_report_descriptor_len;
- break;
-
- case HID_DESCRIPTOR_TYPE_HID_PHYSICAL:
- USB_LOG_INFO("get PHYSICAL Descriptor\r\n");
-
- break;
-
- default:
- return -2;
- }
-
- return 0;
- }
-
- return -1;
-}
-
static int hid_class_interface_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
{
USB_LOG_DBG("HID Class request: "
@@ -105,14 +49,8 @@ static int hid_class_interface_request_handler(struct usb_setup_packet *setup, u
return 0;
}
-struct usbd_interface *usbd_hid_alloc_intf(const uint8_t *desc, uint32_t desc_len)
+struct usbd_interface *usbd_hid_init_intf(struct usbd_interface *intf, const uint8_t *desc, uint32_t desc_len)
{
- struct usbd_interface *intf = usb_malloc(sizeof(struct usbd_interface));
- if (intf == NULL) {
- USB_LOG_ERR("no mem to alloc intf\r\n");
- return NULL;
- }
-
intf->class_interface_handler = hid_class_interface_request_handler;
intf->class_endpoint_handler = NULL;
intf->vendor_handler = NULL;