ar9170: use bitop macros for tx filter flags
authorChristian Lamparter <chunkeey@web.de>
Sat, 23 May 2009 18:28:21 +0000 (20:28 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 3 Jun 2009 18:05:13 +0000 (14:05 -0400)
This patch fixes a bug in configure_filter's (sub-)routines.
We never really cleared the flags once we updated the hardware state,
so we wasted our resources by applying already active settings.

Signed-off-by: Christian Lamparter <chunkeey@web.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ar9170/ar9170.h
drivers/net/wireless/ath/ar9170/main.c

index 77dc6471027316acdf861488725f70edf64676b9..1247dcb9081afe06b616cd44ea113f05ce79b5ee 100644 (file)
@@ -140,7 +140,7 @@ struct ar9170 {
        struct work_struct filter_config_work;
        u64 cur_mc_hash, want_mc_hash;
        u32 cur_filter, want_filter;
-       unsigned int filter_changed;
+       unsigned long filter_changed;
        unsigned int filter_state;
        bool sniffer_enabled;
 
@@ -195,7 +195,7 @@ struct ar9170_sta_info {
 #define IS_STARTED(a)          (a->state >= AR9170_STARTED)
 #define IS_ACCEPTING_CMD(a)    (a->state >= AR9170_IDLE)
 
-#define AR9170_FILTER_CHANGED_PROMISC          BIT(0)
+#define AR9170_FILTER_CHANGED_MODE             BIT(0)
 #define AR9170_FILTER_CHANGED_MULTICAST                BIT(1)
 #define AR9170_FILTER_CHANGED_FRAMEFILTER      BIT(2)
 
index c54c42e5391f6bfe2d09f0c2095628c1f135ae6d..201989ad0e2505c1e486ac1ef7a42a2d160fc8f8 100644 (file)
@@ -957,6 +957,8 @@ static int ar9170_op_start(struct ieee80211_hw *hw)
 
        mutex_lock(&ar->mutex);
 
+       ar->filter_changed = 0;
+
        /* reinitialize queues statistics */
        memset(&ar->tx_stats, 0, sizeof(ar->tx_stats));
        for (i = 0; i < ARRAY_SIZE(ar->tx_stats); i++)
@@ -1376,20 +1378,26 @@ static void ar9170_set_filters(struct work_struct *work)
                return ;
 
        mutex_lock(&ar->mutex);
-       if (ar->filter_changed & AR9170_FILTER_CHANGED_PROMISC) {
+       if (test_and_clear_bit(AR9170_FILTER_CHANGED_MODE,
+                              &ar->filter_changed)) {
                err = ar9170_set_operating_mode(ar);
                if (err)
                        goto unlock;
        }
 
-       if (ar->filter_changed & AR9170_FILTER_CHANGED_MULTICAST) {
+       if (test_and_clear_bit(AR9170_FILTER_CHANGED_MULTICAST,
+                              &ar->filter_changed)) {
                err = ar9170_update_multicast(ar);
                if (err)
                        goto unlock;
        }
 
-       if (ar->filter_changed & AR9170_FILTER_CHANGED_FRAMEFILTER)
+       if (test_and_clear_bit(AR9170_FILTER_CHANGED_FRAMEFILTER,
+                              &ar->filter_changed)) {
                err = ar9170_update_frame_filter(ar);
+               if (err)
+                       goto unlock;
+       }
 
 unlock:
        mutex_unlock(&ar->mutex);
@@ -1419,7 +1427,7 @@ static void ar9170_op_configure_filter(struct ieee80211_hw *hw,
                        int i;
 
                        /* always get broadcast frames */
-                       mchash = 1ULL << (0xff>>2);
+                       mchash = 1ULL << (0xff >> 2);
 
                        for (i = 0; i < mc_count; i++) {
                                if (WARN_ON(!mclist))
@@ -1429,7 +1437,7 @@ static void ar9170_op_configure_filter(struct ieee80211_hw *hw,
                        }
                ar->want_mc_hash = mchash;
                }
-               ar->filter_changed |= AR9170_FILTER_CHANGED_MULTICAST;
+               set_bit(AR9170_FILTER_CHANGED_MULTICAST, &ar->filter_changed);
        }
 
        if (changed_flags & FIF_CONTROL) {
@@ -1445,12 +1453,14 @@ static void ar9170_op_configure_filter(struct ieee80211_hw *hw,
                else
                        ar->want_filter = ar->cur_filter & ~filter;
 
-               ar->filter_changed |= AR9170_FILTER_CHANGED_FRAMEFILTER;
+               set_bit(AR9170_FILTER_CHANGED_FRAMEFILTER,
+                       &ar->filter_changed);
        }
 
        if (changed_flags & FIF_PROMISC_IN_BSS) {
                ar->sniffer_enabled = ((*new_flags) & FIF_PROMISC_IN_BSS) != 0;
-               ar->filter_changed |= AR9170_FILTER_CHANGED_PROMISC;
+               set_bit(AR9170_FILTER_CHANGED_MODE,
+                       &ar->filter_changed);
        }
 
        if (likely(IS_STARTED(ar)))