From 9029f8c5b19ba6af8132d1808a71ac3f8350c6c1 Mon Sep 17 00:00:00 2001 From: sakimisu <1203593632@qq.com> Date: Sun, 27 Aug 2023 13:38:13 +0800 Subject: [PATCH] fix warning --- class/hub/usbh_hub.c | 3 ++- class/vendor/air72x/usbh_air724.c | 28 +++++++++++++++++++++++----- class/wireless/usbh_rndis.c | 1 - 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/class/hub/usbh_hub.c b/class/hub/usbh_hub.c index 2a124386..dd4ec5ed 100644 --- a/class/hub/usbh_hub.c +++ b/class/hub/usbh_hub.c @@ -108,7 +108,7 @@ static int _usbh_hub_get_hub_descriptor(struct usbh_hub *hub, uint8_t *buffer) memcpy(buffer, g_hub_buf, USB_SIZEOF_HUB_DESC); return ret; } - +#if 0 static int _usbh_hub_get_status(struct usbh_hub *hub, uint8_t *buffer) { struct usb_setup_packet *setup; @@ -130,6 +130,7 @@ static int _usbh_hub_get_status(struct usbh_hub *hub, uint8_t *buffer) return ret; } #endif +#endif static int _usbh_hub_get_portstatus(struct usbh_hub *hub, uint8_t port, struct hub_port_status *port_status) { diff --git a/class/vendor/air72x/usbh_air724.c b/class/vendor/air72x/usbh_air724.c index 04de5646..8c3d7a63 100644 --- a/class/vendor/air72x/usbh_air724.c +++ b/class/vendor/air72x/usbh_air724.c @@ -16,6 +16,8 @@ struct usbh_cdc_custom_air724 { struct usbh_urb bulkout_urb; /* Bulk OUT urb */ }; +USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_air724_buf[32]; + static inline int usbh_air724_bulk_out_transfer(struct usbh_cdc_custom_air724 *cdc_custom_class, uint8_t *buffer, uint32_t buflen, uint32_t timeout) { int ret; @@ -30,12 +32,26 @@ static inline int usbh_air724_bulk_out_transfer(struct usbh_cdc_custom_air724 *c return ret; } +static inline int usbh_air724_bulk_in_transfer(struct usbh_cdc_custom_air724 *cdc_custom_class, uint8_t *buffer, uint32_t buflen, uint32_t timeout) +{ + int ret; + struct usbh_urb *urb = &cdc_custom_class->bulkin_urb; + memset(urb, 0, sizeof(struct usbh_urb)); + + usbh_bulk_urb_fill(urb, cdc_custom_class->bulkin, buffer, buflen, timeout, NULL, NULL); + ret = usbh_submit_urb(urb); + if (ret == 0) { + ret = urb->actual_length; + } + return ret; +} + int usbh_air724_connect(struct usbh_hubport *hport, uint8_t intf) { - struct usbh_endpoint_cfg ep_cfg = { 0 }; struct usb_endpoint_descriptor *ep_desc; int ret; + /* interface 3 is AT command */ if (intf != 3) { USB_LOG_WRN("ignore intf:%d\r\n", intf); return 0; @@ -65,20 +81,22 @@ int usbh_air724_connect(struct usbh_hubport *hport, uint8_t intf) USB_LOG_INFO("Register air724 Class:%s\r\n", hport->config.intf[intf].devname); - uint8_t cdc_buffer[32] = { 0x41, 0x54, 0x0d, 0x0a }; - ret = usbh_air724_bulk_out_transfer(cdc_custom_class->bulkout, cdc_buffer, 4, 3000); + const uint8_t AT[4] = { 0x41, 0x54, 0x0d, 0x0a }; + + memcpy(g_air724_buf, AT, 4); + ret = usbh_air724_bulk_out_transfer(cdc_custom_class, g_air724_buf, 4, 3000); if (ret < 0) { USB_LOG_ERR("bulk out error,ret:%d\r\n", ret); } else { USB_LOG_RAW("send over:%d\r\n", ret); } - ret = usbh_air724_bulk_out_transfer(cdc_custom_class->bulkin, cdc_buffer, 10, 3000); + ret = usbh_air724_bulk_in_transfer(cdc_custom_class, g_air724_buf, 10, 3000); if (ret < 0) { USB_LOG_ERR("bulk in error,ret:%d\r\n", ret); } else { USB_LOG_RAW("recv over:%d\r\n", ret); for (size_t i = 0; i < ret; i++) { - USB_LOG_RAW("0x%02x ", cdc_buffer[i]); + USB_LOG_RAW("0x%02x ", g_air724_buf[i]); } } diff --git a/class/wireless/usbh_rndis.c b/class/wireless/usbh_rndis.c index 4ba9e810..36c56839 100644 --- a/class/wireless/usbh_rndis.c +++ b/class/wireless/usbh_rndis.c @@ -260,7 +260,6 @@ int usbh_rndis_keepalive(struct usbh_rndis *rndis_class) static int usbh_rndis_connect(struct usbh_hubport *hport, uint8_t intf) { - struct usbh_endpoint_cfg ep_cfg = { 0 }; struct usb_endpoint_descriptor *ep_desc; int ret; uint32_t *oid_support_list;