Commit 97ccc3a6 authored by Jes Sorensen's avatar Jes Sorensen Committed by Greg Kroah-Hartman

staging: rtl8723au: Clean up usb_{read,write}_port() usage

Get rid of silly HAL convolution for calling usb_{read,write}_port()
functions.

Benefit from fact we just have one input address for read_port, so no
point storing this and carrying it around.

Pick pipe in the local function instead of based on dst/src address.
Signed-off-by: default avatarJes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4810ce07
......@@ -115,23 +115,6 @@ int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr , u32 length , u8 *pdat
return _SUCCESS;
}
int _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt,
struct recv_buf *rbuf)
{
struct _io_ops *io_ops = &adapter->io_ops;
if ((adapter->bDriverStopped == true) ||
(adapter->bSurpriseRemoved == true)) {
RT_TRACE(_module_rtl871x_io_c_, _drv_info_,
("rtw_read_port:bDriverStopped(%d) OR "
"bSurpriseRemoved(%d)", adapter->bDriverStopped,
adapter->bSurpriseRemoved));
return _FAIL;
}
return io_ops->_read_port(adapter, addr, cnt, rbuf);
}
void _rtw_read_port23a_cancel(struct rtw_adapter *adapter)
{
void (*_read_port_cancel)(struct rtw_adapter *adapter);
......@@ -143,17 +126,6 @@ void _rtw_read_port23a_cancel(struct rtw_adapter *adapter)
_read_port_cancel(adapter);
}
int _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt,
struct xmit_buf *xbuf)
{
struct _io_ops *io_ops = &adapter->io_ops;
int ret = _SUCCESS;
ret = io_ops->_write_port(adapter, addr, cnt, xbuf);
return ret;
}
void _rtw_write_port23a_cancel(struct rtw_adapter *adapter)
{
void (*_write_port_cancel)(struct rtw_adapter *adapter);
......
......@@ -345,7 +345,8 @@ static int rtw_dump_xframe(struct rtw_adapter *padapter,
}
ff_hwaddr = rtw_get_ff_hwaddr23a(pxmitframe);
inner_ret = rtw_write_port(padapter, ff_hwaddr, w_sz, pxmitbuf);
inner_ret = rtl8723a_usb_write_port(padapter, ff_hwaddr,
w_sz, pxmitbuf);
rtw_count_tx_stats23a(padapter, pxmitframe, sz);
RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
......
......@@ -1220,24 +1220,18 @@ int rtl8723au_inirp_init(struct rtw_adapter *Adapter)
int status;
struct _io_ops *io_ops = &Adapter->io_ops;
struct recv_priv *precvpriv = &Adapter->recvpriv;
int (*_read_port)(struct rtw_adapter *padapter, u32 addr, u32 cnt,
struct recv_buf *rbuf);
int (*_read_interrupt)(struct rtw_adapter *padapter, u32 addr);
struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
_read_port = io_ops->_read_port;
status = _SUCCESS;
RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("===> usb_inirp_init\n"));
precvpriv->ff_hwaddr = RECV_BULK_IN_ADDR;
/* issue Rx irp to receive data */
precvbuf = (struct recv_buf *)precvpriv->precv_buf;
for (i = 0; i < NR_RECVBUFF; i++) {
if (_read_port(Adapter, precvpriv->ff_hwaddr, 0, precvbuf) ==
_FAIL) {
if (rtl8723a_usb_read_port(Adapter, RECV_BULK_IN_ADDR, 0,
precvbuf) == _FAIL) {
RT_TRACE(_module_hci_hal_init_c_, _drv_err_,
("usb_rx_init: usb_read_port error\n"));
status = _FAIL;
......
......@@ -457,7 +457,7 @@ static int usb_read_interrupt(struct rtw_adapter *adapter, u32 addr)
struct usb_device *pusbd = pdvobj->pusbdev;
/* translate DMA FIFO addr to pipehandle */
pipe = ffaddr2pipehdl23a(pdvobj, addr);
pipe = usb_rcvintpipe(pusbd, pdvobj->RtInPipe[1]);
usb_fill_int_urb(precvpriv->int_in_urb, pusbd, pipe,
precvpriv->int_in_buf, USB_INTR_CONTENT_LENGTH,
......@@ -676,8 +676,8 @@ static void usb_read_port_complete(struct urb *purb)
("usb_read_port_complete: (purb->actual_"
"length > MAX_RECVBUF_SZ) || (purb->actual_"
"length < RXDESC_SIZE)\n"));
rtw_read_port(padapter, precvpriv->ff_hwaddr, 0,
precvbuf);
rtl8723a_usb_read_port(padapter, RECV_BULK_IN_ADDR, 0,
precvbuf);
DBG_8723A("%s()-%d: RX Warning!\n",
__FUNCTION__, __LINE__);
} else {
......@@ -692,8 +692,8 @@ static void usb_read_port_complete(struct urb *purb)
tasklet_schedule(&precvpriv->recv_tasklet);
precvbuf->pskb = NULL;
rtw_read_port(padapter, precvpriv->ff_hwaddr, 0,
precvbuf);
rtl8723a_usb_read_port(padapter, RECV_BULK_IN_ADDR, 0,
precvbuf);
}
} else {
RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
......@@ -730,8 +730,8 @@ static void usb_read_port_complete(struct urb *purb)
pHalData = GET_HAL_DATA(padapter);
pHalData->srestpriv.Wifi_Error_Status =
USB_READ_PORT_FAIL;
rtw_read_port(padapter, precvpriv->ff_hwaddr,
0, precvbuf);
rtl8723a_usb_read_port(padapter, RECV_BULK_IN_ADDR, 0,
precvbuf);
break;
case -EINPROGRESS:
DBG_8723A("ERROR: URB IS IN PROGRESS!/n");
......@@ -742,8 +742,8 @@ static void usb_read_port_complete(struct urb *purb)
}
}
static int usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt,
struct recv_buf *precvbuf)
int rtl8723a_usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt,
struct recv_buf *precvbuf)
{
int err;
unsigned int pipe;
......@@ -791,7 +791,7 @@ static int usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt,
purb = precvbuf->purb;
/* translate DMA FIFO addr to pipehandle */
pipe = ffaddr2pipehdl23a(pdvobj, addr);
pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe[0]);
usb_fill_bulk_urb(purb, pusbd, pipe, precvbuf->pskb->data,
MAX_RECVBUF_SZ, usb_read_port_complete,
......@@ -842,15 +842,12 @@ void rtl8723au_set_intf_ops(struct rtw_adapter *padapter)
pops->_read8 = &usb_read8;
pops->_read16 = &usb_read16;
pops->_read32 = &usb_read32;
pops->_read_port = &usb_read_port;
pops->_write8 = &usb_write8;
pops->_write16 = &usb_write16;
pops->_write32 = &usb_write32;
pops->_writeN = &usb_writeN;
pops->_write_port = &usb_write_port23a;
pops->_read_port_cancel = &usb_read_port_cancel23a;
pops->_write_port_cancel = &usb_write_port23a_cancel;
......
......@@ -112,11 +112,6 @@ struct _io_ops
int (*_read_interrupt)(struct rtw_adapter *adapter, u32 addr);
int (*_read_port)(struct rtw_adapter *adapter, u32 addr, u32 cnt,
struct recv_buf *rbuf);
int (*_write_port)(struct rtw_adapter *adapter, u32 addr, u32 cnt,
struct xmit_buf *pmem);
void (*_read_port_cancel)(struct rtw_adapter *adapter);
void (*_write_port_cancel)(struct rtw_adapter *adapter);
};
......@@ -253,7 +248,6 @@ void _rtw_attrib_write(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
u8 _rtw_read823a(struct rtw_adapter *adapter, u32 addr);
u16 _rtw_read1623a(struct rtw_adapter *adapter, u32 addr);
u32 _rtw_read3223a(struct rtw_adapter *adapter, u32 addr);
int _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct recv_buf *rbuf);
void _rtw_read_port23a_cancel(struct rtw_adapter *adapter);
int _rtw_write823a(struct rtw_adapter *adapter, u32 addr, u8 val);
......@@ -261,7 +255,6 @@ int _rtw_write1623a(struct rtw_adapter *adapter, u32 addr, u16 val);
int _rtw_write3223a(struct rtw_adapter *adapter, u32 addr, u32 val);
int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr, u32 length, u8 *pdata);
int _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *pmem);
void _rtw_write_port23a_cancel(struct rtw_adapter *adapter);
#ifdef DBG_IO
......@@ -280,7 +273,6 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da
#define rtw_read8(adapter, addr) dbg_rtw_read823a((adapter), (addr), __FUNCTION__, __LINE__)
#define rtw_read16(adapter, addr) dbg_rtw_read1623a((adapter), (addr), __FUNCTION__, __LINE__)
#define rtw_read32(adapter, addr) dbg_rtw_read3223a((adapter), (addr), __FUNCTION__, __LINE__)
#define rtw_read_port(adapter, addr, cnt, mem) _rtw_read_port23a((adapter), (addr), (cnt), (mem))
#define rtw_read_port_cancel(adapter) _rtw_read_port23a_cancel((adapter))
#define rtw_write8(adapter, addr, val) dbg_rtw_write823a((adapter), (addr), (val), __FUNCTION__, __LINE__)
......@@ -288,13 +280,11 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da
#define rtw_write32(adapter, addr, val) dbg_rtw_write3223a((adapter), (addr), (val), __FUNCTION__, __LINE__)
#define rtw_writeN(adapter, addr, length, data) dbg_rtw_writeN23a((adapter), (addr), (length), (data), __FUNCTION__, __LINE__)
#define rtw_write_port(adapter, addr, cnt, mem) _rtw_write_port23a(adapter, addr, cnt, mem)
#define rtw_write_port_cancel(adapter) _rtw_write_port23a_cancel(adapter)
#else /* DBG_IO */
#define rtw_read8(adapter, addr) _rtw_read823a((adapter), (addr))
#define rtw_read16(adapter, addr) _rtw_read1623a((adapter), (addr))
#define rtw_read32(adapter, addr) _rtw_read3223a((adapter), (addr))
#define rtw_read_port(adapter, addr, cnt, mem) _rtw_read_port23a((adapter), (addr), (cnt), (mem))
#define rtw_read_port_cancel(adapter) _rtw_read_port23a_cancel((adapter))
#define rtw_write8(adapter, addr, val) _rtw_write823a((adapter), (addr), (val))
......@@ -302,7 +292,6 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da
#define rtw_write32(adapter, addr, val) _rtw_write3223a((adapter), (addr), (val))
#define rtw_writeN(adapter, addr, length, data) _rtw_writeN23a((adapter), (addr), (length), (data))
#define rtw_write_port(adapter, addr, cnt, mem) _rtw_write_port23a((adapter), (addr), (cnt), (mem))
#define rtw_write_port_cancel(adapter) _rtw_write_port23a_cancel((adapter))
#endif /* DBG_IO */
......
......@@ -187,7 +187,6 @@ struct recv_priv {
uint rx_middlepacket_crcerr;
/* u8 *pallocated_urb_buf; */
uint ff_hwaddr;
u8 rx_pending_cnt;
struct urb *int_in_urb;
......
......@@ -28,5 +28,9 @@ void usb_read_port_cancel23a(struct rtw_adapter *adapter);
int usb_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt,
struct xmit_buf *wmem);
void usb_write_port23a_cancel(struct rtw_adapter *adapter);
int rtl8723a_usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt,
struct recv_buf *precvbuf);
int rtl8723a_usb_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt,
struct xmit_buf *pxmitbuf);
#endif
......@@ -18,22 +18,6 @@
#include <usb_ops_linux.h>
#include <rtw_sreset.h>
unsigned int ffaddr2pipehdl23a(struct dvobj_priv *pdvobj, u32 addr)
{
struct usb_device *pusbd = pdvobj->pusbdev;
unsigned int pipe = 0, ep_num = 0;
if (addr == RECV_BULK_IN_ADDR) {
pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe[0]);
} else if (addr == RECV_INT_IN_ADDR) {
pipe = usb_rcvintpipe(pusbd, pdvobj->RtInPipe[1]);
} else if (addr < HW_QUEUE_ENTRY) {
ep_num = pdvobj->Queue2Pipe[addr];
pipe = usb_sndbulkpipe(pusbd, ep_num);
}
return pipe;
}
struct zero_bulkout_context {
void *pbuf;
void *purb;
......@@ -156,8 +140,8 @@ static void usb_write_port23a_complete(struct urb *purb)
tasklet_hi_schedule(&pxmitpriv->xmit_tasklet);
}
int usb_write_port23a(struct rtw_adapter *padapter, u32 addr, u32 cnt,
struct xmit_buf *pxmitbuf)
int rtl8723a_usb_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt,
struct xmit_buf *pxmitbuf)
{
struct urb *purb = NULL;
struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter);
......@@ -165,7 +149,7 @@ int usb_write_port23a(struct rtw_adapter *padapter, u32 addr, u32 cnt,
struct xmit_frame *pxmitframe;
struct usb_device *pusbd = pdvobj->pusbdev;
unsigned long irqL;
unsigned int pipe;
unsigned int pipe, ep_num;
int status;
int ret = _FAIL;
......@@ -214,7 +198,8 @@ int usb_write_port23a(struct rtw_adapter *padapter, u32 addr, u32 cnt,
purb = pxmitbuf->pxmit_urb[0];
/* translate DMA FIFO addr to pipehandle */
pipe = ffaddr2pipehdl23a(pdvobj, addr);
ep_num = pdvobj->Queue2Pipe[addr];
pipe = usb_sndbulkpipe(pusbd, ep_num);
usb_fill_bulk_urb(purb, pusbd, pipe,
pxmitframe->buf_addr, /* pxmitbuf->pbuf */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment