clean up the usb_readXY functions

Remove unnecessary variables, summarize declarations and assignments.

Link: https://lore.kernel.org/r/20210821164859.4351-6-martin@kaiser.cx
This commit is contained in:
Martin Kaiser 2021-08-21 18:48:55 +02:00 committed by Carlos Garcés
parent 28e0bba794
commit ba036a3e14

View File

@ -319,26 +319,17 @@ int usb_async_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val)
u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr)
{
u8 requesttype;
u16 wvalue;
u16 index;
u16 len;
u16 wvalue = (u16)(addr & 0x0000ffff);
u8 data = 0;
requesttype = 0x01;/* read_in */
index = 0;/* n/a */
wvalue = (u16)(addr & 0x0000ffff);
len = 1;
/* WLANON PAGE0_REG needs to add an offset 0x8000 */
#if defined(CONFIG_RTL8710B)
if(wvalue >= 0x0000 && wvalue < 0x0100)
wvalue |= 0x8000;
#endif
usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype);
usbctrl_vendorreq(pintfhdl, wvalue, 0, &data, 1, VENDOR_READ);
return data;
@ -346,18 +337,8 @@ u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr)
u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr)
{
u8 requesttype;
u16 wvalue;
u16 index;
u16 len;
u16 data = 0;
requesttype = 0x01;/* read_in */
index = 0;/* n/a */
wvalue = (u16)(addr & 0x0000ffff);
len = 2;
u16 wvalue = (u16)(addr & 0x0000ffff);
u16 data;
/* WLANON PAGE0_REG needs to add an offset 0x8000 */
#if defined(CONFIG_RTL8710B)
@ -365,7 +346,7 @@ u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr)
wvalue |= 0x8000;
#endif
usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype);
usbctrl_vendorreq(pintfhdl, wvalue, 0, &data, 2, VENDOR_READ);
return data;
@ -374,18 +355,8 @@ u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr)
u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr)
{
u8 requesttype;
u16 wvalue;
u16 index;
u16 len;
u32 data = 0;
requesttype = 0x01;/* read_in */
index = 0;/* n/a */
wvalue = (u16)(addr & 0x0000ffff);
len = 4;
u16 wvalue = (u16)(addr & 0x0000ffff);
u32 data;
/* WLANON PAGE0_REG needs to add an offset 0x8000 */
#if defined(CONFIG_RTL8710B)
@ -393,7 +364,7 @@ u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr)
wvalue |= 0x8000;
#endif
usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype);
usbctrl_vendorreq(pintfhdl, wvalue, 0, &data, 4, VENDOR_READ);
return data;