rtl8188eu: Cleanup read/write routines

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
This commit is contained in:
Larry Finger 2015-01-26 20:52:43 -06:00
parent b2de21036e
commit cc84eb336a

View file

@ -46,12 +46,6 @@ jackson@realtek.com.tw
#include <osdep_intf.h> #include <osdep_intf.h>
#include <usb_ops.h> #include <usb_ops.h>
#define rtw_le16_to_cpu(val) le16_to_cpu(val)
#define rtw_le32_to_cpu(val) le32_to_cpu(val)
#define rtw_cpu_to_le16(val) cpu_to_le16(val)
#define rtw_cpu_to_le32(val) cpu_to_le32(val)
u8 _rtw_read8(struct adapter *adapter, u32 addr) u8 _rtw_read8(struct adapter *adapter, u32 addr)
{ {
u8 r_val; u8 r_val;
@ -59,43 +53,34 @@ u8 _rtw_read8(struct adapter *adapter, u32 addr)
struct io_priv *pio_priv = &adapter->iopriv; struct io_priv *pio_priv = &adapter->iopriv;
struct intf_hdl *pintfhdl = &(pio_priv->intf); struct intf_hdl *pintfhdl = &(pio_priv->intf);
u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr); u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr);
;
_read8 = pintfhdl->io_ops._read8; _read8 = pintfhdl->io_ops._read8;
r_val = _read8(pintfhdl, addr); r_val = _read8(pintfhdl, addr);
;
return r_val; return r_val;
} }
u16 _rtw_read16(struct adapter *adapter, u32 addr) u16 _rtw_read16(struct adapter *adapter, u32 addr)
{ {
u16 r_val; u16 r_val;
//struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
struct io_priv *pio_priv = &adapter->iopriv; struct io_priv *pio_priv = &adapter->iopriv;
struct intf_hdl *pintfhdl = &(pio_priv->intf); struct intf_hdl *pintfhdl = &(pio_priv->intf);
u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr); u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr);
;
_read16 = pintfhdl->io_ops._read16; _read16 = pintfhdl->io_ops._read16;
r_val = _read16(pintfhdl, addr); r_val = _read16(pintfhdl, addr);
; return le16_to_cpu(r_val);
return rtw_le16_to_cpu(r_val);
} }
u32 _rtw_read32(struct adapter *adapter, u32 addr) u32 _rtw_read32(struct adapter *adapter, u32 addr)
{ {
u32 r_val; u32 r_val;
//struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
struct io_priv *pio_priv = &adapter->iopriv; struct io_priv *pio_priv = &adapter->iopriv;
struct intf_hdl *pintfhdl = &(pio_priv->intf); struct intf_hdl *pintfhdl = &(pio_priv->intf);
u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr); u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr);
;
_read32 = pintfhdl->io_ops._read32; _read32 = pintfhdl->io_ops._read32;
r_val = _read32(pintfhdl, addr); r_val = _read32(pintfhdl, addr);
; return le32_to_cpu(r_val);
return rtw_le32_to_cpu(r_val);
} }
int _rtw_write8(struct adapter *adapter, u32 addr, u8 val) int _rtw_write8(struct adapter *adapter, u32 addr, u8 val)
@ -105,27 +90,24 @@ int _rtw_write8(struct adapter *adapter, u32 addr, u8 val)
struct intf_hdl *pintfhdl = &(pio_priv->intf); struct intf_hdl *pintfhdl = &(pio_priv->intf);
int (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val); int (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val);
int ret; int ret;
;
_write8 = pintfhdl->io_ops._write8; _write8 = pintfhdl->io_ops._write8;
ret = _write8(pintfhdl, addr, val); ret = _write8(pintfhdl, addr, val);
;
return RTW_STATUS_CODE(ret); return RTW_STATUS_CODE(ret);
} }
int _rtw_write16(struct adapter *adapter, u32 addr, u16 val) int _rtw_write16(struct adapter *adapter, u32 addr, u16 val)
{ {
//struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
struct io_priv *pio_priv = &adapter->iopriv; struct io_priv *pio_priv = &adapter->iopriv;
struct intf_hdl *pintfhdl = &(pio_priv->intf); struct intf_hdl *pintfhdl = &(pio_priv->intf);
int (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val); int (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val);
int ret; int ret;
;
_write16 = pintfhdl->io_ops._write16; _write16 = pintfhdl->io_ops._write16;
val = rtw_cpu_to_le16(val); val = cpu_to_le16(val);
ret = _write16(pintfhdl, addr, val); ret = _write16(pintfhdl, addr, val);
;
return RTW_STATUS_CODE(ret); return RTW_STATUS_CODE(ret);
} }
@ -136,12 +118,10 @@ int _rtw_write32(struct adapter *adapter, u32 addr, u32 val)
struct intf_hdl *pintfhdl = &(pio_priv->intf); struct intf_hdl *pintfhdl = &(pio_priv->intf);
int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val); int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
int ret; int ret;
;
_write32 = pintfhdl->io_ops._write32; _write32 = pintfhdl->io_ops._write32;
val = rtw_cpu_to_le32(val); val = cpu_to_le32(val);
ret = _write32(pintfhdl, addr, val); ret = _write32(pintfhdl, addr, val);
;
return RTW_STATUS_CODE(ret); return RTW_STATUS_CODE(ret);
} }
@ -153,56 +133,50 @@ int _rtw_writeN(struct adapter *adapter, u32 addr ,u32 length , u8 *pdata)
struct intf_hdl *pintfhdl = (struct intf_hdl*)(&(pio_priv->intf)); struct intf_hdl *pintfhdl = (struct intf_hdl*)(&(pio_priv->intf));
int (*_writeN)(struct intf_hdl *pintfhdl, u32 addr,u32 length, u8 *pdata); int (*_writeN)(struct intf_hdl *pintfhdl, u32 addr,u32 length, u8 *pdata);
int ret; int ret;
;
_writeN = pintfhdl->io_ops._writeN; _writeN = pintfhdl->io_ops._writeN;
ret = _writeN(pintfhdl, addr,length,pdata); ret = _writeN(pintfhdl, addr,length,pdata);
;
return RTW_STATUS_CODE(ret); return RTW_STATUS_CODE(ret);
} }
int _rtw_write8_async(struct adapter *adapter, u32 addr, u8 val) int _rtw_write8_async(struct adapter *adapter, u32 addr, u8 val)
{ {
//struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
struct io_priv *pio_priv = &adapter->iopriv; struct io_priv *pio_priv = &adapter->iopriv;
struct intf_hdl *pintfhdl = &(pio_priv->intf); struct intf_hdl *pintfhdl = &(pio_priv->intf);
int (*_write8_async)(struct intf_hdl *pintfhdl, u32 addr, u8 val); int (*_write8_async)(struct intf_hdl *pintfhdl, u32 addr, u8 val);
int ret; int ret;
;
_write8_async = pintfhdl->io_ops._write8_async; _write8_async = pintfhdl->io_ops._write8_async;
ret = _write8_async(pintfhdl, addr, val); ret = _write8_async(pintfhdl, addr, val);
;
return RTW_STATUS_CODE(ret); return RTW_STATUS_CODE(ret);
} }
int _rtw_write16_async(struct adapter *adapter, u32 addr, u16 val) int _rtw_write16_async(struct adapter *adapter, u32 addr, u16 val)
{ {
//struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
struct io_priv *pio_priv = &adapter->iopriv; struct io_priv *pio_priv = &adapter->iopriv;
struct intf_hdl *pintfhdl = &(pio_priv->intf); struct intf_hdl *pintfhdl = &(pio_priv->intf);
int (*_write16_async)(struct intf_hdl *pintfhdl, u32 addr, u16 val); int (*_write16_async)(struct intf_hdl *pintfhdl, u32 addr, u16 val);
int ret; int ret;
;
_write16_async = pintfhdl->io_ops._write16_async; _write16_async = pintfhdl->io_ops._write16_async;
val = rtw_cpu_to_le16(val); val = cpu_to_le16(val);
ret = _write16_async(pintfhdl, addr, val); ret = _write16_async(pintfhdl, addr, val);
;
return RTW_STATUS_CODE(ret); return RTW_STATUS_CODE(ret);
} }
int _rtw_write32_async(struct adapter *adapter, u32 addr, u32 val) int _rtw_write32_async(struct adapter *adapter, u32 addr, u32 val)
{ {
//struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
struct io_priv *pio_priv = &adapter->iopriv; struct io_priv *pio_priv = &adapter->iopriv;
struct intf_hdl *pintfhdl = &(pio_priv->intf); struct intf_hdl *pintfhdl = &(pio_priv->intf);
int (*_write32_async)(struct intf_hdl *pintfhdl, u32 addr, u32 val); int (*_write32_async)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
int ret; int ret;
;
_write32_async = pintfhdl->io_ops._write32_async; _write32_async = pintfhdl->io_ops._write32_async;
val = rtw_cpu_to_le32(val); val = cpu_to_le32(val);
ret = _write32_async(pintfhdl, addr, val); ret = _write32_async(pintfhdl, addr, val);
;
return RTW_STATUS_CODE(ret); return RTW_STATUS_CODE(ret);
} }
@ -210,64 +184,49 @@ int _rtw_write32_async(struct adapter *adapter, u32 addr, u32 val)
void _rtw_read_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) void _rtw_read_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
{ {
void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
//struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
struct io_priv *pio_priv = &adapter->iopriv; struct io_priv *pio_priv = &adapter->iopriv;
struct intf_hdl *pintfhdl = &(pio_priv->intf); struct intf_hdl *pintfhdl = &(pio_priv->intf);
;
if( (adapter->bDriverStopped ==true) || (adapter->bSurpriseRemoved == true)) if (adapter->bDriverStopped || adapter->bSurpriseRemoved) {
{ RT_TRACE(_module_rtl871x_io_c_, _drv_info_,
RT_TRACE(_module_rtl871x_io_c_, _drv_info_, ("rtw_read_mem:bDriverStopped(%d) OR bSurpriseRemoved(%d)", adapter->bDriverStopped, adapter->bSurpriseRemoved)); ("rtw_read_mem:bDriverStopped(%d) OR bSurpriseRemoved(%d)",
adapter->bDriverStopped, adapter->bSurpriseRemoved));
return; return;
} }
_read_mem = pintfhdl->io_ops._read_mem; _read_mem = pintfhdl->io_ops._read_mem;
_read_mem(pintfhdl, addr, cnt, pmem); _read_mem(pintfhdl, addr, cnt, pmem);
;
} }
void _rtw_write_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) void _rtw_write_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
{ {
void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
//struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
struct io_priv *pio_priv = &adapter->iopriv; struct io_priv *pio_priv = &adapter->iopriv;
struct intf_hdl *pintfhdl = &(pio_priv->intf); struct intf_hdl *pintfhdl = &(pio_priv->intf);
;
_write_mem = pintfhdl->io_ops._write_mem; _write_mem = pintfhdl->io_ops._write_mem;
_write_mem(pintfhdl, addr, cnt, pmem); _write_mem(pintfhdl, addr, cnt, pmem);
;
} }
void _rtw_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) void _rtw_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
{ {
u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
//struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
struct io_priv *pio_priv = &adapter->iopriv; struct io_priv *pio_priv = &adapter->iopriv;
struct intf_hdl *pintfhdl = &(pio_priv->intf); struct intf_hdl *pintfhdl = &(pio_priv->intf);
; if( (adapter->bDriverStopped) || (adapter->bSurpriseRemoved)) {
RT_TRACE(_module_rtl871x_io_c_, _drv_info_,
if( (adapter->bDriverStopped ==true) || (adapter->bSurpriseRemoved == true)) ("rtw_read_port:bDriverStopped(%d) OR bSurpriseRemoved(%d)",
{ adapter->bDriverStopped, adapter->bSurpriseRemoved));
RT_TRACE(_module_rtl871x_io_c_, _drv_info_, ("rtw_read_port:bDriverStopped(%d) OR bSurpriseRemoved(%d)", adapter->bDriverStopped, adapter->bSurpriseRemoved)); return;
return;
} }
_read_port = pintfhdl->io_ops._read_port; _read_port = pintfhdl->io_ops._read_port;
_read_port(pintfhdl, addr, cnt, pmem); _read_port(pintfhdl, addr, cnt, pmem);
;
} }
void _rtw_read_port_cancel(struct adapter *adapter) void _rtw_read_port_cancel(struct adapter *adapter)
@ -286,20 +245,12 @@ void _rtw_read_port_cancel(struct adapter *adapter)
u32 _rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) u32 _rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
{ {
u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
//struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
struct io_priv *pio_priv = &adapter->iopriv; struct io_priv *pio_priv = &adapter->iopriv;
struct intf_hdl *pintfhdl = &(pio_priv->intf); struct intf_hdl *pintfhdl = &(pio_priv->intf);
u32 ret = _SUCCESS;
;
_write_port = pintfhdl->io_ops._write_port; _write_port = pintfhdl->io_ops._write_port;
ret = _write_port(pintfhdl, addr, cnt, pmem); return _write_port(pintfhdl, addr, cnt, pmem);
;
return ret;
} }
u32 _rtw_write_port_and_wait(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem, int timeout_ms) u32 _rtw_write_port_and_wait(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem, int timeout_ms)