staging: rtl8723au: Clean up usb_{read,write}_port() usage
authorJes Sorensen <Jes.Sorensen@redhat.com>
Fri, 16 May 2014 08:05:05 +0000 (10:05 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 May 2014 18:34:35 +0000 (11:34 -0700)
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: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723au/core/rtw_io.c
drivers/staging/rtl8723au/hal/rtl8723au_xmit.c
drivers/staging/rtl8723au/hal/usb_halinit.c
drivers/staging/rtl8723au/hal/usb_ops_linux.c
drivers/staging/rtl8723au/include/rtw_io.h
drivers/staging/rtl8723au/include/rtw_recv.h
drivers/staging/rtl8723au/include/usb_ops_linux.h
drivers/staging/rtl8723au/os_dep/usb_ops_linux.c

index 0f26ea8de21660db504bc5a7c44ed519f7ab6736..532ad758372f8072f22021891af146bcad07a26b 100644 (file)
@@ -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);
index 113144c3c02fc5ca44876b049841f9fbcba5def6..45bd67e88e0e12628abd0378961e15e6997a5ebc 100644 (file)
@@ -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_,
index 9ef333c031e28ab0da56904b96f0ddc343af5606..11b33e6fd70955c1eca2079740e6ea1cfbe28a79 100644 (file)
@@ -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;
index 2eba530a1c6c27d40be6c94f46e9529bca0284e2..cb83758393b3a4f861eaff0e902a47229962738b 100644 (file)
@@ -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;
 
index f303213b42a7c65a0457e1f66241fea916172982..192e16764d9ae35f278bcc91af34350c5d7606f8 100644 (file)
@@ -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 */
 
index e22ce645667f23e656d67cf2f776d8978bc20ce2..fd381c594b14d0c0c79186bd3e07f81f9ffe1be0 100644 (file)
@@ -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;
index f46b81b7d2593987735eb84a2ebd39d50226ee3d..ed4d8a82db14551f070f3e62d0113c20991d00cc 100644 (file)
@@ -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
index 3ef38706a21dff2084b3d3c857cc76d1bdfe115d..2eb76bdba0290ba54e5af94793be129f8b0fbf74 100644 (file)
 #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 @@ check_completion:
        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 */