set pipe only once

Set the pipe for reading or writing in usbctrl_vendorreq only once.
There's no need to set it again for every retry.

This patch is an adaptation of commit 889ed8b5e374 ("staging: rtl8188eu:
set pipe only once") for the new r8188eu driver.

Link: https://lore.kernel.org/r/20210821164859.4351-10-martin@kaiser.cx
This commit is contained in:
Martin Kaiser 2021-08-21 18:48:59 +02:00 committed by Carlos Garces
parent 972b1c23e2
commit cd6cb41e0f

View File

@ -94,14 +94,17 @@ int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, u16 index, void *pda
goto release_mutex; goto release_mutex;
} }
while (++vendorreq_times <= MAX_USBCTRL_VENDORREQ_TIMES) { if (requesttype == VENDOR_READ)
memset(pIo_buf, 0, len); pipe = usb_rcvctrlpipe(udev, 0);/* read_in */
else
pipe = usb_sndctrlpipe(udev, 0);/* write_out */
if (requesttype == 0x01) { while (++vendorreq_times <= MAX_USBCTRL_VENDORREQ_TIMES) {
pipe = usb_rcvctrlpipe(udev, 0);/* read_in */
if (requesttype == VENDOR_READ) {
memset(pIo_buf, 0, len);
reqtype = REALTEK_USB_VENQT_READ; reqtype = REALTEK_USB_VENQT_READ;
} else { } else {
pipe = usb_sndctrlpipe(udev, 0);/* write_out */
reqtype = REALTEK_USB_VENQT_WRITE; reqtype = REALTEK_USB_VENQT_WRITE;
_rtw_memcpy(pIo_buf, pdata, len); _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. */ if (status == len) { /* Success this control transfer. */
rtw_reset_continual_io_error(pdvobjpriv); 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. */ /* For Control read transfer, we have to copy the read data from pIo_buf to pdata. */
_rtw_memcpy(pdata, pIo_buf, len); _rtw_memcpy(pdata, pIo_buf, len);
} }
} else { /* error cases */ } else { /* error cases */
RTW_INFO("reg 0x%x, usb %s %u fail, status:%d value=0x%x, vendorreq_times:%d\n" 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 < 0) {
if (status == (-ESHUTDOWN) || status == -ENODEV) if (status == (-ESHUTDOWN) || status == -ENODEV)