From 28e0bba7940a6c4f06163d14214c5389129324c4 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Wed, 18 Aug 2021 22:00:40 +0200 Subject: [PATCH] ctrl vendor req value is always 0x05 The bRequest value for the vendor specific control requests sent by this driver is always 0x05. Replace the function parameter with the define from usb_ops.h. This patch is an adaptation of commit eeb4661560ff ("staging: rtl8188eu: ctrl vendor req value is always 0x05") for the new r8188eu driver. Link: https://lore.kernel.org/r/20210818200041.10870-1-martin@kaiser.cx --- hal/hal_hci/hal_usb.c | 35 +++++++---------------------------- include/usb_ops_linux.h | 2 +- os_dep/linux/usb_ops_linux.c | 4 ++-- 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/hal/hal_hci/hal_usb.c b/hal/hal_hci/hal_usb.c index f802a3f..7961a82 100644 --- a/hal/hal_hci/hal_usb.c +++ b/hal/hal_hci/hal_usb.c @@ -319,7 +319,6 @@ int usb_async_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) { - u8 request; u8 requesttype; u16 wvalue; u16 index; @@ -327,7 +326,6 @@ u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) u8 data = 0; - request = 0x05; requesttype = 0x01;/* read_in */ index = 0;/* n/a */ @@ -340,8 +338,7 @@ u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) wvalue |= 0x8000; #endif - usbctrl_vendorreq(pintfhdl, request, wvalue, index, - &data, len, requesttype); + usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); return data; @@ -349,7 +346,6 @@ u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) { - u8 request; u8 requesttype; u16 wvalue; u16 index; @@ -357,7 +353,6 @@ u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) u16 data = 0; - request = 0x05; requesttype = 0x01;/* read_in */ index = 0;/* n/a */ @@ -370,8 +365,7 @@ u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) wvalue |= 0x8000; #endif - usbctrl_vendorreq(pintfhdl, request, wvalue, index, - &data, len, requesttype); + usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); return data; @@ -380,7 +374,6 @@ u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) { - u8 request; u8 requesttype; u16 wvalue; u16 index; @@ -388,7 +381,6 @@ u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) u32 data = 0; - request = 0x05; requesttype = 0x01;/* read_in */ index = 0;/* n/a */ @@ -401,8 +393,7 @@ u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) wvalue |= 0x8000; #endif - usbctrl_vendorreq(pintfhdl, request, wvalue, index, - &data, len, requesttype); + usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); return data; @@ -410,7 +401,6 @@ u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) { - u8 request; u8 requesttype; u16 wvalue; u16 index; @@ -419,7 +409,6 @@ int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) int ret; - request = 0x05; requesttype = 0x00;/* write_out */ index = 0;/* n/a */ @@ -433,8 +422,7 @@ int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) wvalue |= 0x8000; #endif - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, - &data, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); return ret; @@ -442,7 +430,6 @@ int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) { - u8 request; u8 requesttype; u16 wvalue; u16 index; @@ -451,7 +438,6 @@ int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) int ret; - request = 0x05; requesttype = 0x00;/* write_out */ index = 0;/* n/a */ @@ -465,8 +451,7 @@ int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) wvalue |= 0x8000; #endif - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, - &data, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); return ret; @@ -475,7 +460,6 @@ int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) { - u8 request; u8 requesttype; u16 wvalue; u16 index; @@ -484,7 +468,6 @@ int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) int ret; - request = 0x05; requesttype = 0x00;/* write_out */ index = 0;/* n/a */ @@ -498,8 +481,7 @@ int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) wvalue |= 0x8000; #endif - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, - &data, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); return ret; @@ -508,7 +490,6 @@ int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata) { - u8 request; u8 requesttype; u16 wvalue; u16 index; @@ -517,15 +498,13 @@ int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata) int ret; - request = 0x05; requesttype = 0x00;/* write_out */ index = 0;/* n/a */ wvalue = (u16)(addr & 0x0000ffff); len = length; _rtw_memcpy(buf, pdata, len); - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, - buf, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, index, buf, len, requesttype); return ret; diff --git a/include/usb_ops_linux.h b/include/usb_ops_linux.h index 3ec6ac4..41c634d 100644 --- a/include/usb_ops_linux.h +++ b/include/usb_ops_linux.h @@ -60,7 +60,7 @@ void usb_read_port_cancel(struct intf_hdl *pintfhdl); u32 usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem); void usb_write_port_cancel(struct intf_hdl *pintfhdl); -int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype); +int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, u16 index, void *pdata, u16 len, u8 requesttype); #ifdef CONFIG_USB_SUPPORT_ASYNC_VDN_REQ int _usbctrl_vendorreq_async_write(struct usb_device *udev, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype); diff --git a/os_dep/linux/usb_ops_linux.c b/os_dep/linux/usb_ops_linux.c index 62b6f22..a126472 100644 --- a/os_dep/linux/usb_ops_linux.c +++ b/os_dep/linux/usb_ops_linux.c @@ -23,7 +23,7 @@ struct rtw_async_write_data { struct usb_ctrlrequest dr; }; -int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype) +int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, u16 index, void *pdata, u16 len, u8 requesttype) { _adapter *padapter = pintfhdl->padapter; struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); @@ -106,7 +106,7 @@ int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u16 inde _rtw_memcpy(pIo_buf, pdata, len); } - status = usb_control_msg(udev, pipe, request, reqtype, value, index, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT); + status = usb_control_msg(udev, pipe, REALTEK_USB_VENQT_CMD_REQ, reqtype, value, index, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT); if (status == len) { /* Success this control transfer. */ rtw_reset_continual_io_error(pdvobjpriv);