staging: r8712u: Simplify semaphores
authorLarry Finger <Larry.Finger@lwfinger.net>
Thu, 9 Feb 2012 01:42:03 +0000 (19:42 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Feb 2012 17:12:55 +0000 (09:12 -0800)
I am preparing to convert this driver from semaphore to mutex locking,
The first step has been to eliminate a number of semaphores that were
initialized but never used, and one whose only use was a single "up"
after initialization. A total of 9 semaphores were removed in this process.

One other change was to remove some inline semaphore routines that were
unused.

In addition, several cases had the following structure:

down()
if () {
   ...
}
up()

The locking overhead was reduced by moving the up/down inside the if
block.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
13 files changed:
drivers/staging/rtl8712/drv_types.h
drivers/staging/rtl8712/os_intfs.c
drivers/staging/rtl8712/osdep_service.h
drivers/staging/rtl8712/rtl8712_recv.c
drivers/staging/rtl8712/rtl871x_io.c
drivers/staging/rtl8712/rtl871x_io.h
drivers/staging/rtl8712/rtl871x_pwrctrl.c
drivers/staging/rtl8712/rtl871x_pwrctrl.h
drivers/staging/rtl8712/rtl871x_recv.c
drivers/staging/rtl8712/rtl871x_recv.h
drivers/staging/rtl8712/rtl871x_xmit.c
drivers/staging/rtl8712/rtl871x_xmit.h
drivers/staging/rtl8712/usb_intf.c

index 9b5d771e650ca240d99bd625fcd3ec33b090914f..0735de9aad92c899a63fa0fc909b60691d1785a7 100644 (file)
@@ -138,7 +138,6 @@ struct dvobj_priv {
        u8   ishighspeed;
        uint(*inirp_init)(struct _adapter *adapter);
        uint(*inirp_deinit)(struct _adapter *adapter);
-       struct semaphore usb_suspend_sema;
        struct usb_device *pusbdev;
 };
 
index 9a75c6dbe505e4b02eb7dc4d591bef31c78528e7..250cd116f0c000a0a599bc3d7a8b2d7dcdc47d38 100644 (file)
@@ -329,7 +329,6 @@ u8 r8712_init_drv_sw(struct _adapter *padapter)
        padapter->stapriv.padapter = padapter;
        r8712_init_bcmc_stainfo(padapter);
        r8712_init_pwrctrl_priv(padapter);
-       sema_init(&(padapter->pwrctrlpriv.pnp_pwr_mgnt_sema), 0);
        mp871xinit(padapter);
        if (init_default_value(padapter) != _SUCCESS)
                return _FAIL;
index 1ee943a58c4c74311377ed99c09b6b43e9f929c1..9ba603310fdc359dc793b09cfa9e74bfe86c5eff 100644 (file)
@@ -72,18 +72,6 @@ static inline struct list_head *get_list_head(struct  __queue *queue)
 #define LIST_CONTAINOR(ptr, type, member) \
        ((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member)))
 
-static inline void _enter_hwio_critical(struct semaphore *prwlock,
-                                       unsigned long *pirqL)
-{
-       down(prwlock);
-}
-
-static inline void _exit_hwio_critical(struct semaphore *prwlock,
-                                      unsigned long *pirqL)
-{
-       up(prwlock);
-}
-
 static inline void list_delete(struct list_head *plist)
 {
        list_del_init(plist);
@@ -152,11 +140,6 @@ static inline u32 _down_sema(struct semaphore *sema)
                return _SUCCESS;
 }
 
-static inline void _rtl_rwlock_init(struct semaphore *prwlock)
-{
-       sema_init(prwlock, 1);
-}
-
 static inline void _init_listhead(struct list_head *list)
 {
        INIT_LIST_HEAD(list);
index 6d692657e78403d695f5529dff86782bde7ecbbc..fa6dc9c09b3fbee0b4451f24f0ac9c3afb3bc5dc 100644 (file)
@@ -55,8 +55,6 @@ int r8712_init_recv_priv(struct recv_priv *precvpriv, struct _adapter *padapter)
        int alignment = 0;
        struct sk_buff *pskb = NULL;
 
-       sema_init(&precvpriv->recv_sema, 0);
-       sema_init(&precvpriv->terminate_recvthread_sema, 0);
        /*init recv_buf*/
        _init_queue(&precvpriv->free_recv_buf_queue);
        precvpriv->pallocated_recv_buf = _malloc(NR_RECVBUFF *
index ca84ee02eacc1cb7288ca268ac4cad8945c07c09..abc1c97378f710fdee1b8dbd55cb3782a3a54a6a 100644 (file)
@@ -131,7 +131,6 @@ uint r8712_alloc_io_queue(struct _adapter *adapter)
        pio_req = (struct io_req *)(pio_queue->free_ioreqs_buf);
        for (i = 0; i < NUM_IOREQ; i++) {
                _init_listhead(&pio_req->list);
-               sema_init(&pio_req->sema, 0);
                list_insert_tail(&pio_req->list, &pio_queue->free_ioreqs);
                pio_req++;
        }
index 86308a0093ed9aa4ffd5130c42ae9e3b09961d78..d3d8727c2ec55674841ef35dcee0c3d5d71df823 100644 (file)
@@ -117,7 +117,6 @@ struct io_req {
        u32     command;
        u32     status;
        u8      *pbuf;
-       struct semaphore sema;
        void (*_async_io_callback)(struct _adapter *padater,
                                   struct io_req *pio_req, u8 *cnxt);
        u8 *cnxt;
index 23e72a0401a8e0e945e35e61a695097f0b1b0a89..9fd2ec7596cc8cfc4228addfbeb718613f539681 100644 (file)
@@ -100,7 +100,6 @@ void r8712_cpwm_int_hdl(struct _adapter *padapter,
 {
        struct pwrctrl_priv *pwrpriv = &(padapter->pwrctrlpriv);
        struct cmd_priv *pcmdpriv = &(padapter->cmdpriv);
-       struct xmit_priv *pxmitpriv = &(padapter->xmitpriv);
 
        if (pwrpriv->cpwm_tog == ((preportpwrstate->state) & 0x80))
                return;
@@ -110,8 +109,6 @@ void r8712_cpwm_int_hdl(struct _adapter *padapter,
        if (pwrpriv->cpwm >= PS_STATE_S2) {
                if (pwrpriv->alives & CMD_ALIVE)
                        up(&(pcmdpriv->cmd_queue_sema));
-               if (pwrpriv->alives & XMIT_ALIVE)
-                       up(&(pxmitpriv->xmit_sema));
        }
        pwrpriv->cpwm_tog = (preportpwrstate->state) & 0x80;
        up(&pwrpriv->lock);
@@ -145,12 +142,12 @@ static void SetPSModeWorkItemCallback(struct work_struct *work)
                                       struct pwrctrl_priv, SetPSModeWorkItem);
        struct _adapter *padapter = container_of(pwrpriv,
                                    struct _adapter, pwrctrlpriv);
-       _enter_pwrlock(&pwrpriv->lock);
        if (!pwrpriv->bSleep) {
+               _enter_pwrlock(&pwrpriv->lock);
                if (pwrpriv->pwr_mode == PS_MODE_ACTIVE)
                        r8712_set_rpwm(padapter, PS_STATE_S4);
+               up(&pwrpriv->lock);
        }
-       up(&pwrpriv->lock);
 }
 
 static void rpwm_workitem_callback(struct work_struct *work)
@@ -160,13 +157,13 @@ static void rpwm_workitem_callback(struct work_struct *work)
        struct _adapter *padapter = container_of(pwrpriv,
                                    struct _adapter, pwrctrlpriv);
        u8 cpwm = pwrpriv->cpwm;
-       _enter_pwrlock(&pwrpriv->lock);
        if (pwrpriv->cpwm != pwrpriv->rpwm) {
+               _enter_pwrlock(&pwrpriv->lock);
                cpwm = r8712_read8(padapter, SDIO_HCPWM);
                pwrpriv->rpwm_retry = 1;
                r8712_set_rpwm(padapter, pwrpriv->rpwm);
+               up(&pwrpriv->lock);
        }
-       up(&pwrpriv->lock);
 }
 
 static void rpwm_check_handler (void *FunctionContext)
index b41ca2892be5ef307bfbbe5cb887b8100e0e5753..6024c4f63d5bd64179afab9a81da69801c3fa51b 100644 (file)
@@ -133,7 +133,6 @@ struct      pwrctrl_priv {
        u8      rpwm_retry;
        uint    bSetPSModeWorkItemInProgress;
 
-       struct semaphore pnp_pwr_mgnt_sema;
        spinlock_t pnp_pwr_mgnt_lock;
        s32     pnp_current_pwr_state;
        u8      pnp_bstop_trx;
index 7069f06d9b5d62af8550a53b7f2dbf56180b8ef0..5b03b405883e4832aeaa4633346de646d26072cf 100644 (file)
@@ -93,7 +93,6 @@ sint _r8712_init_recv_priv(struct recv_priv *precvpriv,
                precvframe++;
        }
        precvpriv->rx_pending_cnt = 1;
-       sema_init(&precvpriv->allrxreturnevt, 0);
        return r8712_init_recv_priv(precvpriv, padapter);
 }
 
index cc7a72fee1c2601360b9c43423c098ffc14cb9d1..e42e6f0a15e674963df05a53170d6d9246a00e91 100644 (file)
@@ -85,8 +85,6 @@ using enter_critical section to protect
 */
 struct recv_priv {
        spinlock_t lock;
-       struct semaphore recv_sema;
-       struct semaphore terminate_recvthread_sema;
        struct  __queue free_recv_queue;
        struct  __queue recv_pending_queue;
        u8 *pallocated_frame_buf;
@@ -100,7 +98,6 @@ struct recv_priv {
        uint  rx_largepacket_crcerr;
        uint  rx_smallpacket_crcerr;
        uint  rx_middlepacket_crcerr;
-       struct semaphore allrxreturnevt;
        u8  rx_pending_cnt;
        uint    ff_hwaddr;
        struct tasklet_struct recv_tasklet;
index 8bbdee70f8670d2c4e2d98ab1515f223535dffcf..aa57e7754f042789c004f01d4ce20539b31b4d82 100644 (file)
@@ -71,8 +71,6 @@ sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv,
 
        memset((unsigned char *)pxmitpriv, 0, sizeof(struct xmit_priv));
        spin_lock_init(&pxmitpriv->lock);
-       sema_init(&pxmitpriv->xmit_sema, 0);
-       sema_init(&pxmitpriv->terminate_xmitthread_sema, 0);
        /*
        Please insert all the queue initializaiton using _init_queue below
        */
@@ -121,7 +119,6 @@ sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv,
        _r8712_init_hw_txqueue(&pxmitpriv->bmc_txqueue, BMC_QUEUE_INX);
        pxmitpriv->frag_len = MAX_FRAG_THRESHOLD;
        pxmitpriv->txirp_cnt = 1;
-       sema_init(&(pxmitpriv->tx_retevt), 0);
        /*per AC pending irp*/
        pxmitpriv->beq_cnt = 0;
        pxmitpriv->bkq_cnt = 0;
index a034c0fec718c36d96b97e5ea880676b03335914..638b79b4c5a8414759e7962679f08582c6fe9ba1 100644 (file)
@@ -202,8 +202,6 @@ struct      hw_txqueue {
 
 struct xmit_priv {
        spinlock_t lock;
-       struct semaphore xmit_sema;
-       struct semaphore terminate_xmitthread_sema;
        struct  __queue be_pending;
        struct  __queue bk_pending;
        struct  __queue vi_pending;
@@ -233,7 +231,6 @@ struct      xmit_priv {
        uint    tx_drop;
        struct hw_xmit *hwxmits;
        u8      hwxmit_entry;
-       struct semaphore tx_retevt;/*all tx return event;*/
        u8      txirp_cnt;
        struct tasklet_struct xmit_tasklet;
        _workitem xmit_pipe4_reset_wi;
index 5385da2e9cdbcdf23186738a787a7b8dba2e553a..01378eaa79b4845ad0857843ecbcb488a2f87be3 100644 (file)
@@ -280,7 +280,6 @@ static uint r8712_usb_dvobj_init(struct _adapter *padapter)
        }
        if ((r8712_alloc_io_queue(padapter)) == _FAIL)
                status = _FAIL;
-       sema_init(&(padapter->dvobjpriv.usb_suspend_sema), 0);
        return status;
 }