mwifiex: rearrange if and else blocks to avoid extra indentation
authorYogesh Ashok Powar <yogeshp@marvell.com>
Tue, 13 Mar 2012 02:35:12 +0000 (19:35 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 13 Mar 2012 18:54:18 +0000 (14:54 -0400)
This adds better readability.

Signed-off-by: Yogesh Ashok Powar <yogeshp@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/mwifiex/11n_rxreorder.c
drivers/net/wireless/mwifiex/sta_cmdresp.c
drivers/net/wireless/mwifiex/wmm.c

index ad41fab..491cd85 100644 (file)
@@ -205,14 +205,17 @@ mwifiex_flush_data(unsigned long context)
        int start_win;
 
        start_win = mwifiex_11n_find_last_seq_num(reorder_cnxt->ptr);
-       if (start_win >= 0) {
-               dev_dbg(reorder_cnxt->priv->adapter->dev,
-                               "info: flush data %d\n", start_win);
+
+       if (start_win < 0)
+               return;
+
+       dev_dbg(reorder_cnxt->priv->adapter->dev, "info: flush data %d\n",
+               start_win);
                mwifiex_11n_dispatch_pkt_until_start_win(reorder_cnxt->priv,
                                reorder_cnxt->ptr,
-                               ((reorder_cnxt->ptr->start_win +
-                                 start_win + 1) & (MAX_TID_VALUE - 1)));
-       }
+                                                ((reorder_cnxt->ptr->start_win
+                                                  + start_win + 1) &
+                                                 (MAX_TID_VALUE - 1)));
 }
 
 /*
index 3f13ff0..a2a9c51 100644 (file)
@@ -327,31 +327,26 @@ static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
                                          HostCmd_CMD_802_11_TX_RATE_QUERY,
                                          HostCmd_ACT_GEN_GET, 0, NULL);
 
-       if (ds_rate) {
-               if (le16_to_cpu(rate_cfg->action) == HostCmd_ACT_GEN_GET) {
-                       if (priv->is_data_rate_auto) {
-                               ds_rate->is_rate_auto = 1;
-                       } else {
-                               ds_rate->rate = mwifiex_get_rate_index(priv->
-                                                              bitmap_rates,
-                                                              sizeof(priv->
-                                                              bitmap_rates));
-                               if (ds_rate->rate >=
-                                   MWIFIEX_RATE_BITMAP_OFDM0
-                                   && ds_rate->rate <=
-                                   MWIFIEX_RATE_BITMAP_OFDM7)
-                                       ds_rate->rate -=
-                                               (MWIFIEX_RATE_BITMAP_OFDM0 -
-                                                MWIFIEX_RATE_INDEX_OFDM0);
-                               if (ds_rate->rate >=
-                                   MWIFIEX_RATE_BITMAP_MCS0
-                                   && ds_rate->rate <=
-                                   MWIFIEX_RATE_BITMAP_MCS127)
-                                       ds_rate->rate -=
-                                               (MWIFIEX_RATE_BITMAP_MCS0 -
-                                                MWIFIEX_RATE_INDEX_MCS0);
-                       }
-               }
+       if (!ds_rate)
+               return ret;
+
+       if (le16_to_cpu(rate_cfg->action) == HostCmd_ACT_GEN_GET) {
+               if (priv->is_data_rate_auto) {
+                       ds_rate->is_rate_auto = 1;
+               return ret;
+       }
+       ds_rate->rate = mwifiex_get_rate_index(priv->bitmap_rates,
+                                              sizeof(priv->bitmap_rates));
+
+       if (ds_rate->rate >= MWIFIEX_RATE_BITMAP_OFDM0 &&
+           ds_rate->rate <= MWIFIEX_RATE_BITMAP_OFDM7)
+               ds_rate->rate -= (MWIFIEX_RATE_BITMAP_OFDM0 -
+                                 MWIFIEX_RATE_INDEX_OFDM0);
+
+       if (ds_rate->rate >= MWIFIEX_RATE_BITMAP_MCS0 &&
+           ds_rate->rate <= MWIFIEX_RATE_BITMAP_MCS127)
+               ds_rate->rate -= (MWIFIEX_RATE_BITMAP_MCS0 -
+                                 MWIFIEX_RATE_INDEX_MCS0);
        }
 
        return ret;
@@ -369,34 +364,32 @@ static int mwifiex_get_power_level(struct mwifiex_private *priv, void *data_buf)
        struct mwifiex_types_power_group *pg_tlv_hdr;
        struct mwifiex_power_group *pg;
 
-       if (data_buf) {
-               pg_tlv_hdr =
-                       (struct mwifiex_types_power_group *) ((u8 *) data_buf
-                                       + sizeof(struct host_cmd_ds_txpwr_cfg));
-               pg = (struct mwifiex_power_group *) ((u8 *) pg_tlv_hdr +
-                               sizeof(struct mwifiex_types_power_group));
-               length = pg_tlv_hdr->length;
-               if (length > 0) {
+       if (!data_buf)
+               return -1;
+
+       pg_tlv_hdr = (struct mwifiex_types_power_group *)
+               ((u8 *) data_buf + sizeof(struct host_cmd_ds_txpwr_cfg));
+       pg = (struct mwifiex_power_group *)
+               ((u8 *) pg_tlv_hdr + sizeof(struct mwifiex_types_power_group));
+       length = pg_tlv_hdr->length;
+       if (length > 0) {
+               max_power = pg->power_max;
+               min_power = pg->power_min;
+               length -= sizeof(struct mwifiex_power_group);
+       }
+       while (length) {
+               pg++;
+               if (max_power < pg->power_max)
                        max_power = pg->power_max;
-                       min_power = pg->power_min;
-                       length -= sizeof(struct mwifiex_power_group);
-               }
-               while (length) {
-                       pg++;
-                       if (max_power < pg->power_max)
-                               max_power = pg->power_max;
 
-                       if (min_power > pg->power_min)
-                               min_power = pg->power_min;
+               if (min_power > pg->power_min)
+                       min_power = pg->power_min;
 
-                       length -= sizeof(struct mwifiex_power_group);
-               }
-               if (pg_tlv_hdr->length > 0) {
-                       priv->min_tx_power_level = (u8) min_power;
-                       priv->max_tx_power_level = (u8) max_power;
-               }
-       } else {
-               return -1;
+               length -= sizeof(struct mwifiex_power_group);
+       }
+       if (pg_tlv_hdr->length > 0) {
+               priv->min_tx_power_level = (u8) min_power;
+               priv->max_tx_power_level = (u8) max_power;
        }
 
        return 0;
index 5757ebd..6f0cc21 100644 (file)
@@ -850,6 +850,7 @@ mwifiex_wmm_get_highest_priolist_ptr(struct mwifiex_adapter *adapter,
        struct mwifiex_ra_list_tbl *ptr, *head;
        struct mwifiex_bss_prio_node *bssprio_node, *bssprio_head;
        struct mwifiex_tid_tbl *tid_ptr;
+       atomic_t *hqp;
        int is_list_empty;
        unsigned long flags;
        int i, j;
@@ -879,12 +880,8 @@ mwifiex_wmm_get_highest_priolist_ptr(struct mwifiex_adapter *adapter,
                }
 
                do {
-                       atomic_t *hqp;
-                       spinlock_t *lock;
-
                        priv_tmp = bssprio_node->priv;
                        hqp = &priv_tmp->wmm.highest_queued_prio;
-                       lock = &priv_tmp->wmm.ra_list_spinlock;
 
                        for (i = atomic_read(hqp); i >= LOW_PRIO_TID; --i) {
 
@@ -923,16 +920,10 @@ mwifiex_wmm_get_highest_priolist_ptr(struct mwifiex_adapter *adapter,
                                do {
                                        is_list_empty =
                                                skb_queue_empty(&ptr->skb_head);
-                                       if (!is_list_empty) {
-                                               spin_lock_irqsave(lock, flags);
-                                               if (atomic_read(hqp) > i)
-                                                       atomic_set(hqp, i);
-                                               spin_unlock_irqrestore(lock,
-                                                                       flags);
-                                               *priv = priv_tmp;
-                                               *tid = tos_to_tid[i];
-                                               return ptr;
-                                       }
+
+                                       if (!is_list_empty)
+                                               goto found;
+
                                        /* Get next ra */
                                        ptr = list_first_entry(&ptr->list,
                                                 struct mwifiex_ra_list_tbl,
@@ -969,6 +960,17 @@ mwifiex_wmm_get_highest_priolist_ptr(struct mwifiex_adapter *adapter,
                } while (bssprio_node != bssprio_head);
        }
        return NULL;
+
+found:
+       spin_lock_irqsave(&priv_tmp->wmm.ra_list_spinlock, flags);
+       if (atomic_read(hqp) > i)
+               atomic_set(hqp, i);
+       spin_unlock_irqrestore(&priv_tmp->wmm.ra_list_spinlock, flags);
+
+       *priv = priv_tmp;
+       *tid = tos_to_tid[i];
+
+       return ptr;
 }
 
 /*