Skip to content

Commit 8b37c62

Browse files
jfischer-nocfriedt
authored andcommitted
usb: remove useless len argument from usb_data_to_host()
The len argument always has the same value as usb_dev.setup.wLength, which is also the last received USB device request. Signed-off-by: Johann Fischer <[email protected]>
1 parent 378a1e0 commit 8b37c62

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

subsys/usb/usb_device.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ static bool usb_handle_request(struct usb_setup_packet *setup,
239239
*
240240
* @return N/A
241241
*/
242-
static void usb_data_to_host(uint16_t len)
242+
static void usb_data_to_host(void)
243243
{
244244
if (usb_dev.zlp_flag == false) {
245245
uint32_t chunk = usb_dev.data_buf_residue;
@@ -255,12 +255,14 @@ static void usb_data_to_host(uint16_t len)
255255
* last chunk is wMaxPacketSize long, to indicate the last
256256
* packet.
257257
*/
258-
if (!usb_dev.data_buf_residue && len > usb_dev.data_buf_len) {
258+
if (!usb_dev.data_buf_residue &&
259+
usb_dev.setup.wLength > usb_dev.data_buf_len) {
259260
/* Send less data as requested during the Setup stage */
260261
if (!(usb_dev.data_buf_len % USB_MAX_CTRL_MPS)) {
261262
/* Transfers a zero-length packet */
262263
LOG_DBG("ZLP, requested %u , length %u ",
263-
len, usb_dev.data_buf_len);
264+
usb_dev.setup.wLength,
265+
usb_dev.data_buf_len);
264266
usb_dev.zlp_flag = true;
265267
}
266268
}
@@ -341,7 +343,7 @@ static void usb_handle_control_transfer(uint8_t ep,
341343
usb_dev.data_buf_residue = MIN(usb_dev.data_buf_len,
342344
setup->wLength);
343345
/* Send first part (possibly a zero-length status message) */
344-
usb_data_to_host(setup->wLength);
346+
usb_data_to_host();
345347
} else if (ep == USB_CONTROL_OUT_EP0) {
346348
/* OUT transfer, data or status packets */
347349
if (usb_dev.data_buf_residue <= 0) {
@@ -378,12 +380,12 @@ static void usb_handle_control_transfer(uint8_t ep,
378380

379381
/*Send status to host*/
380382
LOG_DBG(">> usb_data_to_host(2)");
381-
usb_data_to_host(setup->wLength);
383+
usb_data_to_host();
382384
}
383385
} else if (ep == USB_CONTROL_IN_EP0) {
384386
/* Send more data if available */
385387
if (usb_dev.data_buf_residue != 0 || usb_dev.zlp_flag == true) {
386-
usb_data_to_host(setup->wLength);
388+
usb_data_to_host();
387389
}
388390
} else {
389391
__ASSERT_NO_MSG(false);

0 commit comments

Comments
 (0)