staging: rtl8723au: hal/usb_ops_linux.c: Various cleanups
authorJes Sorensen <Jes.Sorensen@redhat.com>
Fri, 16 May 2014 08:04:52 +0000 (10:04 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 May 2014 18:34:32 +0000 (11:34 -0700)
Reduce excessive parenthesis usage, remove unnecessary null
initialization of variables, and some bad formatting.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723au/hal/usb_ops_linux.c

index c7df5212fc5744f42e140a6097ddc7f9cfbb50c6..be43863d1c2d7bf59e81ce20681eb245865cac36 100644 (file)
@@ -35,15 +35,17 @@ static int usbctrl_vendorreq(struct rtw_adapter *padapter, u8 request,
        u8 *pIo_buf;
        int vendorreq_times = 0;
 
-       if ((padapter->bSurpriseRemoved) || (padapter->pwrctrlpriv.pnp_bstop_trx)) {
+       if (padapter->bSurpriseRemoved || padapter->pwrctrlpriv.pnp_bstop_trx) {
                RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                        ("usbctrl_vendorreq:(padapter->bSurpriseRemoved||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n"));
+                        ("usbctrl_vendorreq:(padapter->bSurpriseRemoved||"
+                         "adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n"));
                status = -EPERM;
                goto exit;
        }
 
        if (len > MAX_VENDOR_REQ_CMD_SIZE) {
-               DBG_8723A("[%s] Buffer len error , vendor request failed\n", __FUNCTION__);
+               DBG_8723A("[%s] Buffer len error , vendor request failed\n",
+                         __FUNCTION__);
                status = -EINVAL;
                goto exit;
        }
@@ -86,21 +88,26 @@ static int usbctrl_vendorreq(struct rtw_adapter *padapter, u8 request,
                } else { /*  error cases */
                        DBG_8723A("reg 0x%x, usb %s %u fail, status:%d value ="
                                  " 0x%x, vendorreq_times:%d\n",
-                                 value, (requesttype == 0x01) ? "read" : "write",
+                                 value, (requesttype == 0x01) ?
+                                 "read" : "write",
                                  len, status, *(u32 *)pdata, vendorreq_times);
 
                        if (status < 0) {
-                               if (status == (-ESHUTDOWN) || status == -ENODEV) {
+                               if (status == -ESHUTDOWN || status == -ENODEV)
                                        padapter->bSurpriseRemoved = true;
-                               } else {
-                                       struct hal_data_8723a   *pHalData = GET_HAL_DATA(padapter);
-                                       pHalData->srestpriv.Wifi_Error_Status = USB_VEN_REQ_CMD_FAIL;
+                               else {
+                                       struct hal_data_8723a *pHalData;
+                                       pHalData = GET_HAL_DATA(padapter);
+                                       pHalData->srestpriv.Wifi_Error_Status =
+                                               USB_VEN_REQ_CMD_FAIL;
                                }
                        } else { /*  status != len && status >= 0 */
                                if (status > 0) {
                                        if (requesttype == 0x01) {
-                                               /*  For Control read transfer, we have to copy
-                                                * the read data from pIo_buf to pdata.
+                                               /*
+                                                * For Control read transfer,
+                                                * we have to copy the read
+                                                * data from pIo_buf to pdata.
                                                 */
                                                memcpy(pdata, pIo_buf,  len);
                                        }
@@ -111,11 +118,11 @@ static int usbctrl_vendorreq(struct rtw_adapter *padapter, u8 request,
                                padapter->bSurpriseRemoved = true;
                                break;
                        }
-
                }
 
                /*  firmware download is checksumed, don't retry */
-               if ((value >= FW_8723A_START_ADDRESS && value <= FW_8723A_END_ADDRESS) || status == len)
+               if ((value >= FW_8723A_START_ADDRESS &&
+                    value <= FW_8723A_END_ADDRESS) || status == len)
                        break;
        }
 
@@ -332,8 +339,8 @@ InterruptRecognized8723AU(struct rtw_adapter *Adapter, void *pContent,
 
        memcpy(&report.state, &buffer[USB_INTR_CPWM_OFFSET], 1);
 
-       return ((pHalData->IntArray[0])&pHalData->IntrMask[0]) != 0 ||
-               ((pHalData->IntArray[1])&pHalData->IntrMask[1]) != 0;
+       return (pHalData->IntArray[0] & pHalData->IntrMask[0]) != 0 ||
+               (pHalData->IntArray[1] & pHalData->IntrMask[1]) != 0;
 }
 
 static void usb_read_interrupt_complete(struct urb *purb, struct pt_regs *regs)
@@ -368,7 +375,8 @@ static void usb_read_interrupt_complete(struct urb *purb, struct pt_regs *regs)
                if (c2h_evt_exist(c2h_evt)) {
                        if (c2h_id_filter_ccx_8723a(c2h_evt->id)) {
                                /* Handle CCX report here */
-                               handle_txrpt_ccx_8723a(padapter, (void *)(c2h_evt->payload));
+                               handle_txrpt_ccx_8723a(padapter, (void *)
+                                                      c2h_evt->payload);
                                schedule_work(&padapter->evtpriv.irq_wk);
                        } else {
                                struct evt_work *c2w;
@@ -472,16 +480,16 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb)
        u8      shift_sz = 0;
        u16     pkt_cnt;
        u32     pkt_offset, skb_len, alloc_sz;
-       s32     transfer_len;
-       struct recv_stat        *prxstat;
-       struct phy_stat *pphy_info = NULL;
-       struct sk_buff          *pkt_copy = NULL;
-       struct recv_frame       *precvframe = NULL;
-       struct rx_pkt_attrib    *pattrib = NULL;
-       struct recv_priv        *precvpriv = &padapter->recvpriv;
-       struct rtw_queue        *pfree_recv_queue = &precvpriv->free_recv_queue;
-
-       transfer_len = (s32)pskb->len;
+       int     transfer_len;
+       struct recv_stat *prxstat;
+       struct phy_stat *pphy_info;
+       struct sk_buff *pkt_copy;
+       struct recv_frame *precvframe;
+       struct rx_pkt_attrib *pattrib;
+       struct recv_priv *precvpriv = &padapter->recvpriv;
+       struct rtw_queue *pfree_recv_queue = &precvpriv->free_recv_queue;
+
+       transfer_len = (int)pskb->len;
        pbuf = pskb->data;
 
        prxstat = (struct recv_stat *)pbuf;
@@ -520,7 +528,7 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb)
                pkt_offset = RXDESC_SIZE + pattrib->drvinfo_sz +
                        pattrib->shift_sz + pattrib->pkt_len;
 
-               if ((pattrib->pkt_len <= 0) || (pkt_offset > transfer_len)) {
+               if (pattrib->pkt_len <= 0 || pkt_offset > transfer_len) {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
                                 ("recvbuf2recvframe: pkt_len<= 0\n"));
                        DBG_8723A("%s()-%d: RX Warning!\n",
@@ -532,11 +540,10 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb)
                /*      Modified by Albert 20101213 */
                /*      For 8 bytes IP header alignment. */
                /*      Qos data, wireless lan header length is 26 */
-               if (pattrib->qos) {
+               if (pattrib->qos)
                        shift_sz = 6;
-               } else {
+               else
                        shift_sz = 0;
-               }
 
                skb_len = pattrib->pkt_len;
 
@@ -544,7 +551,7 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb)
                 * 1536+drvinfo_sz+RXDESC_SIZE to defrag packet.
                 * modify alloc_sz for recvive crc error packet
                 * by thomas 2011-06-02 */
-               if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) {
+               if (pattrib->mfrag == 1 && pattrib->frag_num == 0) {
                        /* alloc_sz = 1664;     1664 is 128 alignment. */
                        if (skb_len <= 1650)
                                alloc_sz = 1664;
@@ -561,13 +568,17 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb)
                if (pkt_copy) {
                        pkt_copy->dev = padapter->pnetdev;
                        precvframe->pkt = pkt_copy;
-                       skb_reserve(pkt_copy, 8 - ((unsigned long)(pkt_copy->data) & 7));/* force pkt_copy->data at 8-byte alignment address */
-       /*force ip_hdr at 8-byte alignment address according to shift_sz. */
+                       /* force pkt_copy->data at 8-byte alignment address */
+                       skb_reserve(pkt_copy, 8 -
+                                   ((unsigned long)(pkt_copy->data) & 7));
+                       /*force ip_hdr at 8-byte alignment address
+                         according to shift_sz. */
                        skb_reserve(pkt_copy, shift_sz);
-                       memcpy(pkt_copy->data, (pbuf + pattrib->shift_sz + pattrib->drvinfo_sz + RXDESC_SIZE), skb_len);
+                       memcpy(pkt_copy->data, pbuf + pattrib->shift_sz +
+                              pattrib->drvinfo_sz + RXDESC_SIZE, skb_len);
                        skb_put(pkt_copy, skb_len);
                } else {
-                       if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) {
+                       if (pattrib->mfrag == 1 && pattrib->frag_num == 0) {
                                DBG_8723A("recvbuf2recvframe: alloc_skb fail, "
                                          "drop frag frame \n");
                                rtw_free_recvframe23a(precvframe);
@@ -602,7 +613,7 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb)
                if (transfer_len > 0 && pkt_cnt == 0)
                        pkt_cnt = (le32_to_cpu(prxstat->rxdw2)>>16) & 0xff;
 
-       } while ((transfer_len > 0) && (pkt_cnt > 0));
+       } while (transfer_len > 0 && pkt_cnt > 0);
 
 _exit_recvbuf2recvframe:
 
@@ -616,8 +627,7 @@ void rtl8723au_recv_tasklet(void *priv)
        struct recv_priv *precvpriv = &padapter->recvpriv;
 
        while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue))) {
-               if ((padapter->bDriverStopped) ||
-                   (padapter->bSurpriseRemoved)) {
+               if (padapter->bDriverStopped || padapter->bSurpriseRemoved) {
                        DBG_8723A("recv_tasklet => bDriverStopped or "
                                  "bSurpriseRemoved \n");
                        dev_kfree_skb_any(pskb);
@@ -660,8 +670,8 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs)
        }
 
        if (purb->status == 0) {
-               if ((purb->actual_length > MAX_RECVBUF_SZ) ||
-                   (purb->actual_length < RXDESC_SIZE)) {
+               if (purb->actual_length > MAX_RECVBUF_SZ ||
+                   purb->actual_length < RXDESC_SIZE) {
                        RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
                                 ("usb_read_port_complete: (purb->actual_"
                                  "length > MAX_RECVBUF_SZ) || (purb->actual_"
@@ -729,7 +739,6 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs)
                default:
                        break;
                }
-
        }
 }
 
@@ -738,13 +747,13 @@ static int usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt,
 {
        int err;
        unsigned int pipe;
-       unsigned long tmpaddr = 0;
-       unsigned long alignment = 0;
+       unsigned long tmpaddr;
+       unsigned long alignment;
        int ret = _SUCCESS;
-       struct urb *purb = NULL;
-       struct dvobj_priv       *pdvobj = adapter_to_dvobj(adapter);
-       struct recv_priv        *precvpriv = &adapter->recvpriv;
-       struct usb_device       *pusbd = pdvobj->pusbdev;
+       struct urb *purb;
+       struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter);
+       struct recv_priv *precvpriv = &adapter->recvpriv;
+       struct usb_device *pusbd = pdvobj->pusbdev;
 
        if (adapter->bDriverStopped || adapter->bSurpriseRemoved ||
            adapter->pwrctrlpriv.pnp_bstop_trx) {
@@ -810,9 +819,8 @@ void rtl8723au_xmit_tasklet(void *priv)
                return;
 
        while (1) {
-               if ((padapter->bDriverStopped) ||
-                   (padapter->bSurpriseRemoved) ||
-                   (padapter->bWritePortCancel)) {
+               if (padapter->bDriverStopped || padapter->bSurpriseRemoved ||
+                   padapter->bWritePortCancel) {
                        DBG_8723A("xmit_tasklet => bDriverStopped or "
                                  "bSurpriseRemoved or bWritePortCancel\n");
                        break;