diff --git a/os_dep/linux/usb_ops_linux.c b/os_dep/linux/usb_ops_linux.c index b05978c..28ebd55 100644 --- a/os_dep/linux/usb_ops_linux.c +++ b/os_dep/linux/usb_ops_linux.c @@ -94,14 +94,17 @@ int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, u16 index, void *pda goto release_mutex; } - while (++vendorreq_times <= MAX_USBCTRL_VENDORREQ_TIMES) { - memset(pIo_buf, 0, len); + if (requesttype == VENDOR_READ) + pipe = usb_rcvctrlpipe(udev, 0);/* read_in */ + else + pipe = usb_sndctrlpipe(udev, 0);/* write_out */ - if (requesttype == 0x01) { - pipe = usb_rcvctrlpipe(udev, 0);/* read_in */ + while (++vendorreq_times <= MAX_USBCTRL_VENDORREQ_TIMES) { + + if (requesttype == VENDOR_READ) { + memset(pIo_buf, 0, len); reqtype = REALTEK_USB_VENQT_READ; } else { - pipe = usb_sndctrlpipe(udev, 0);/* write_out */ reqtype = REALTEK_USB_VENQT_WRITE; _rtw_memcpy(pIo_buf, pdata, len); } @@ -110,13 +113,13 @@ int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, u16 index, void *pda if (status == len) { /* Success this control transfer. */ rtw_reset_continual_io_error(pdvobjpriv); - if (requesttype == 0x01) { + if (requesttype == VENDOR_READ) { /* For Control read transfer, we have to copy the read data from pIo_buf to pdata. */ _rtw_memcpy(pdata, pIo_buf, len); } } else { /* error cases */ RTW_INFO("reg 0x%x, usb %s %u fail, status:%d value=0x%x, vendorreq_times:%d\n" - , value, (requesttype == 0x01) ? "read" : "write" , len, status, *(u32 *)pdata, vendorreq_times); + , value, (requesttype == VENDOR_READ) ? "read" : "write" , len, status, *(u32 *)pdata, vendorreq_times); if (status < 0) { if (status == (-ESHUTDOWN) || status == -ENODEV)