mirror of
https://github.com/Mange/rtl8192eu-linux-driver
synced 2025-12-08 07:14:03 +00:00
use actual request type as parameter
At the moment, usbctrl_vendorreq's requesttype parameter must be set to
1 for reading and 0 for writing. It's then converted to the actual
bmRequestType for the USB control request. We can simplify the code and
avoid this conversion if the caller passes the actual bmRequestType.
This patch is an adaptation of commit 788fde031027 ("staging: rtl8188eu:
use actual request type as parameter") for the new r8188eu driver.
Link: https://lore.kernel.org/r/20210821164859.4351-3-martin@kaiser.cx
This commit is contained in:
@@ -34,7 +34,6 @@ int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, u16 index, void *pda
|
||||
#ifdef CONFIG_USB_VENDOR_REQ_BUFFER_DYNAMIC_ALLOCATE
|
||||
u32 tmp_buflen = 0;
|
||||
#endif
|
||||
u8 reqtype;
|
||||
u8 *pIo_buf;
|
||||
int vendorreq_times = 0;
|
||||
|
||||
@@ -94,32 +93,30 @@ int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, u16 index, void *pda
|
||||
goto release_mutex;
|
||||
}
|
||||
|
||||
if (requesttype == VENDOR_READ)
|
||||
if (requesttype == REALTEK_USB_VENQT_READ)
|
||||
pipe = usb_rcvctrlpipe(udev, 0);/* read_in */
|
||||
else
|
||||
pipe = usb_sndctrlpipe(udev, 0);/* write_out */
|
||||
|
||||
while (++vendorreq_times <= MAX_USBCTRL_VENDORREQ_TIMES) {
|
||||
|
||||
if (requesttype == VENDOR_READ) {
|
||||
if (requesttype == REALTEK_USB_VENQT_READ) {
|
||||
memset(pIo_buf, 0, len);
|
||||
reqtype = REALTEK_USB_VENQT_READ;
|
||||
} else {
|
||||
reqtype = REALTEK_USB_VENQT_WRITE;
|
||||
memcpy(pIo_buf, pdata, len);
|
||||
}
|
||||
|
||||
status = usb_control_msg(udev, pipe, REALTEK_USB_VENQT_CMD_REQ, reqtype, value, index, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT);
|
||||
status = usb_control_msg(udev, pipe, REALTEK_USB_VENQT_CMD_REQ, requesttype, value, index, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT);
|
||||
|
||||
if (status == len) { /* Success this control transfer. */
|
||||
rtw_reset_continual_io_error(pdvobjpriv);
|
||||
if (requesttype == VENDOR_READ) {
|
||||
if (requesttype == REALTEK_USB_VENQT_READ) {
|
||||
/* For Control read transfer, we have to copy the read data from pIo_buf to pdata. */
|
||||
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 == VENDOR_READ) ? "read" : "write" , len, status, *(u32 *)pdata, vendorreq_times);
|
||||
, value, (requesttype == REALTEK_USB_VENQT_READ) ? "read" : "write" , len, status, *(u32 *)pdata, vendorreq_times);
|
||||
|
||||
if (status < 0) {
|
||||
if (status == (-ESHUTDOWN) || status == -ENODEV)
|
||||
@@ -168,7 +165,6 @@ int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, u16 index, void *pda
|
||||
|
||||
if (current_reg_sec == REG_ON_SEC) {
|
||||
unsigned int t_pipe = usb_sndctrlpipe(udev, 0);/* write_out */
|
||||
u8 t_reqtype = REALTEK_USB_VENQT_WRITE;
|
||||
u8 t_len = 1;
|
||||
u8 t_req = 0x05;
|
||||
u16 t_reg = 0;
|
||||
@@ -176,7 +172,7 @@ int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, u16 index, void *pda
|
||||
|
||||
t_reg = 0x4e0;
|
||||
|
||||
status = usb_control_msg(udev, t_pipe, t_req, t_reqtype, t_reg, t_index, pIo_buf, t_len, RTW_USB_CONTROL_MSG_TIMEOUT);
|
||||
status = usb_control_msg(udev, t_pipe, t_req, REALTEK_USB_VENQT_WRITE, t_reg, t_index, pIo_buf, t_len, RTW_USB_CONTROL_MSG_TIMEOUT);
|
||||
|
||||
if (status == t_len)
|
||||
rtw_reset_continual_io_error(pdvobjpriv);
|
||||
@@ -215,18 +211,15 @@ int _usbctrl_vendorreq_async_write(struct usb_device *udev, u8 request,
|
||||
{
|
||||
int rc;
|
||||
unsigned int pipe;
|
||||
u8 reqtype;
|
||||
struct usb_ctrlrequest *dr;
|
||||
struct urb *urb;
|
||||
struct rtw_async_write_data *buf;
|
||||
|
||||
|
||||
if (requesttype == VENDOR_READ) {
|
||||
if (requesttype == REALTEK_USB_VENQT_READ) {
|
||||
pipe = usb_rcvctrlpipe(udev, 0);/* read_in */
|
||||
reqtype = REALTEK_USB_VENQT_READ;
|
||||
} else {
|
||||
pipe = usb_sndctrlpipe(udev, 0);/* write_out */
|
||||
reqtype = REALTEK_USB_VENQT_WRITE;
|
||||
}
|
||||
|
||||
buf = (struct rtl819x_async_write_data *)rtw_zmalloc(sizeof(*buf));
|
||||
@@ -244,7 +237,7 @@ int _usbctrl_vendorreq_async_write(struct usb_device *udev, u8 request,
|
||||
|
||||
dr = &buf->dr;
|
||||
|
||||
dr->bRequestType = reqtype;
|
||||
dr->bRequestType = requesttype;
|
||||
dr->bRequest = request;
|
||||
dr->wValue = cpu_to_le16(value);
|
||||
dr->wIndex = cpu_to_le16(index);
|
||||
|
||||
Reference in New Issue
Block a user