clean up the usb_writeXY functions

Remove unnecessary variables, summarize declarations and assignments.

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

View File

@ -372,20 +372,7 @@ u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr)
int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val)
{ {
u8 requesttype; u16 wvalue = (u16)(addr & 0x0000ffff);
u16 wvalue;
u16 index;
u16 len;
u8 data;
int ret;
requesttype = 0x00;/* write_out */
index = 0;/* n/a */
wvalue = (u16)(addr & 0x0000ffff);
len = 1;
data = val;
/* WLANON PAGE0_REG needs to add an offset 0x8000 */ /* WLANON PAGE0_REG needs to add an offset 0x8000 */
#if defined(CONFIG_RTL8710B) #if defined(CONFIG_RTL8710B)
@ -393,28 +380,13 @@ int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val)
wvalue |= 0x8000; wvalue |= 0x8000;
#endif #endif
ret = usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); return usbctrl_vendorreq(pintfhdl, wvalue, 0, &val, 1, VENDOR_WRITE);
return ret;
} }
int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val)
{ {
u8 requesttype; u16 wvalue = (u16)(addr & 0x0000ffff);
u16 wvalue;
u16 index;
u16 len;
u16 data;
int ret;
requesttype = 0x00;/* write_out */
index = 0;/* n/a */
wvalue = (u16)(addr & 0x0000ffff);
len = 2;
data = val;
/* WLANON PAGE0_REG needs to add an offset 0x8000 */ /* WLANON PAGE0_REG needs to add an offset 0x8000 */
#if defined(CONFIG_RTL8710B) #if defined(CONFIG_RTL8710B)
@ -422,29 +394,13 @@ int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val)
wvalue |= 0x8000; wvalue |= 0x8000;
#endif #endif
ret = usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); return usbctrl_vendorreq(pintfhdl, wvalue, 0, &val, 2, VENDOR_WRITE);
return ret;
} }
int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val)
{ {
u8 requesttype; u16 wvalue = (u16)(addr & 0x0000ffff);
u16 wvalue;
u16 index;
u16 len;
u32 data;
int ret;
requesttype = 0x00;/* write_out */
index = 0;/* n/a */
wvalue = (u16)(addr & 0x0000ffff);
len = 4;
data = val;
/* WLANON PAGE0_REG needs to add an offset 0x8000 */ /* WLANON PAGE0_REG needs to add an offset 0x8000 */
#if defined(CONFIG_RTL8710B) #if defined(CONFIG_RTL8710B)
@ -452,10 +408,7 @@ int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val)
wvalue |= 0x8000; wvalue |= 0x8000;
#endif #endif
ret = usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); return usbctrl_vendorreq(pintfhdl, wvalue, 0, &val, 4, VENDOR_WRITE);
return ret;
} }