diff options
author | Lennert Buytenhek <buytenh@wantstofly.org> | 2009-07-16 06:14:58 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-08-20 11:38:04 -0400 |
commit | c46563b714b09d44eec4d1fd8a0f53e79ddaa3aa (patch) | |
tree | 0edb88b4171a896120cce633357ecb62f52a13e3 /drivers/net/wireless/mwl8k.c | |
parent | ce9e2e1b8433c8795459a259ee87bc4e424e7c50 (diff) |
mwl8k: remove MWL8K_RADIO_* defines
Instead of passing a flag bitmask to mwl8k_cmd_802_11_radio_control,
pass the 'enable' and 'force' arguments as separate parameters, and
introduce wrappers for the common cases of enabling and disabling
without forcing.
Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/mwl8k.c')
-rw-r--r-- | drivers/net/wireless/mwl8k.c | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c index a2eeba17d37d..78183c8b5f0d 100644 --- a/drivers/net/wireless/mwl8k.c +++ b/drivers/net/wireless/mwl8k.c | |||
@@ -186,9 +186,10 @@ struct mwl8k_priv { | |||
186 | struct ieee80211_channel channels[14]; | 186 | struct ieee80211_channel channels[14]; |
187 | struct ieee80211_rate rates[12]; | 187 | struct ieee80211_rate rates[12]; |
188 | 188 | ||
189 | bool radio_on; | ||
190 | |||
189 | /* RF preamble: Short, Long or Auto */ | 191 | /* RF preamble: Short, Long or Auto */ |
190 | u8 radio_preamble; | 192 | u8 radio_preamble; |
191 | u8 radio_state; | ||
192 | 193 | ||
193 | /* WMM MODE 1 for enabled; 0 for disabled */ | 194 | /* WMM MODE 1 for enabled; 0 for disabled */ |
194 | bool wmm_mode; | 195 | bool wmm_mode; |
@@ -278,9 +279,6 @@ static const struct ieee80211_rate mwl8k_rates[] = { | |||
278 | }; | 279 | }; |
279 | 280 | ||
280 | /* Radio settings */ | 281 | /* Radio settings */ |
281 | #define MWL8K_RADIO_FORCE 0x2 | ||
282 | #define MWL8K_RADIO_ENABLE 0x1 | ||
283 | #define MWL8K_RADIO_DISABLE 0x0 | ||
284 | #define MWL8K_RADIO_AUTO_PREAMBLE 0x0005 | 282 | #define MWL8K_RADIO_AUTO_PREAMBLE 0x0005 |
285 | #define MWL8K_RADIO_SHORT_PREAMBLE 0x0003 | 283 | #define MWL8K_RADIO_SHORT_PREAMBLE 0x0003 |
286 | #define MWL8K_RADIO_LONG_PREAMBLE 0x0001 | 284 | #define MWL8K_RADIO_LONG_PREAMBLE 0x0001 |
@@ -1195,7 +1193,7 @@ static int mwl8k_tx_wait_empty(struct ieee80211_hw *hw, u32 delay_ms) | |||
1195 | count = mwl8k_txq_busy(priv); | 1193 | count = mwl8k_txq_busy(priv); |
1196 | if (count) { | 1194 | if (count) { |
1197 | priv->tx_wait = &cmd_wait; | 1195 | priv->tx_wait = &cmd_wait; |
1198 | if (priv->radio_state) | 1196 | if (priv->radio_on) |
1199 | mwl8k_tx_start(priv); | 1197 | mwl8k_tx_start(priv); |
1200 | } | 1198 | } |
1201 | spin_unlock_bh(&priv->tx_lock); | 1199 | spin_unlock_bh(&priv->tx_lock); |
@@ -1318,7 +1316,7 @@ static void mwl8k_txq_reclaim(struct ieee80211_hw *hw, int index, int force) | |||
1318 | 1316 | ||
1319 | ieee80211_tx_status_irqsafe(hw, skb); | 1317 | ieee80211_tx_status_irqsafe(hw, skb); |
1320 | 1318 | ||
1321 | wake = !priv->inconfig && priv->radio_state; | 1319 | wake = !priv->inconfig && priv->radio_on; |
1322 | } | 1320 | } |
1323 | 1321 | ||
1324 | if (wake) | 1322 | if (wake) |
@@ -1726,18 +1724,16 @@ struct mwl8k_cmd_802_11_radio_control { | |||
1726 | __le16 radio_on; | 1724 | __le16 radio_on; |
1727 | } __attribute__((packed)); | 1725 | } __attribute__((packed)); |
1728 | 1726 | ||
1729 | static int mwl8k_cmd_802_11_radio_control(struct ieee80211_hw *hw, int enable) | 1727 | static int |
1728 | mwl8k_cmd_802_11_radio_control(struct ieee80211_hw *hw, bool enable, bool force) | ||
1730 | { | 1729 | { |
1731 | struct mwl8k_priv *priv = hw->priv; | 1730 | struct mwl8k_priv *priv = hw->priv; |
1732 | struct mwl8k_cmd_802_11_radio_control *cmd; | 1731 | struct mwl8k_cmd_802_11_radio_control *cmd; |
1733 | int rc; | 1732 | int rc; |
1734 | 1733 | ||
1735 | if (((enable & MWL8K_RADIO_ENABLE) == priv->radio_state) && | 1734 | if (enable == priv->radio_on && !force) |
1736 | !(enable & MWL8K_RADIO_FORCE)) | ||
1737 | return 0; | 1735 | return 0; |
1738 | 1736 | ||
1739 | enable &= MWL8K_RADIO_ENABLE; | ||
1740 | |||
1741 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); | 1737 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); |
1742 | if (cmd == NULL) | 1738 | if (cmd == NULL) |
1743 | return -ENOMEM; | 1739 | return -ENOMEM; |
@@ -1752,11 +1748,21 @@ static int mwl8k_cmd_802_11_radio_control(struct ieee80211_hw *hw, int enable) | |||
1752 | kfree(cmd); | 1748 | kfree(cmd); |
1753 | 1749 | ||
1754 | if (!rc) | 1750 | if (!rc) |
1755 | priv->radio_state = enable; | 1751 | priv->radio_on = enable; |
1756 | 1752 | ||
1757 | return rc; | 1753 | return rc; |
1758 | } | 1754 | } |
1759 | 1755 | ||
1756 | static int mwl8k_cmd_802_11_radio_disable(struct ieee80211_hw *hw) | ||
1757 | { | ||
1758 | return mwl8k_cmd_802_11_radio_control(hw, 0, 0); | ||
1759 | } | ||
1760 | |||
1761 | static int mwl8k_cmd_802_11_radio_enable(struct ieee80211_hw *hw) | ||
1762 | { | ||
1763 | return mwl8k_cmd_802_11_radio_control(hw, 1, 0); | ||
1764 | } | ||
1765 | |||
1760 | static int | 1766 | static int |
1761 | mwl8k_set_radio_preamble(struct ieee80211_hw *hw, bool short_preamble) | 1767 | mwl8k_set_radio_preamble(struct ieee80211_hw *hw, bool short_preamble) |
1762 | { | 1768 | { |
@@ -1770,8 +1776,7 @@ mwl8k_set_radio_preamble(struct ieee80211_hw *hw, bool short_preamble) | |||
1770 | MWL8K_RADIO_SHORT_PREAMBLE : | 1776 | MWL8K_RADIO_SHORT_PREAMBLE : |
1771 | MWL8K_RADIO_LONG_PREAMBLE); | 1777 | MWL8K_RADIO_LONG_PREAMBLE); |
1772 | 1778 | ||
1773 | return mwl8k_cmd_802_11_radio_control(hw, | 1779 | return mwl8k_cmd_802_11_radio_control(hw, 1, 1); |
1774 | MWL8K_RADIO_ENABLE | MWL8K_RADIO_FORCE); | ||
1775 | } | 1780 | } |
1776 | 1781 | ||
1777 | /* | 1782 | /* |
@@ -2483,7 +2488,7 @@ static irqreturn_t mwl8k_interrupt(int irq, void *dev_id) | |||
2483 | 2488 | ||
2484 | if (status & MWL8K_A2H_INT_QUEUE_EMPTY) { | 2489 | if (status & MWL8K_A2H_INT_QUEUE_EMPTY) { |
2485 | if (!priv->inconfig && | 2490 | if (!priv->inconfig && |
2486 | priv->radio_state && | 2491 | priv->radio_on && |
2487 | mwl8k_txq_busy(priv)) | 2492 | mwl8k_txq_busy(priv)) |
2488 | mwl8k_tx_start(priv); | 2493 | mwl8k_tx_start(priv); |
2489 | } | 2494 | } |
@@ -2661,7 +2666,7 @@ static void mwl8k_config_thread(struct work_struct *wt) | |||
2661 | 2666 | ||
2662 | spin_lock_irq(&priv->tx_lock); | 2667 | spin_lock_irq(&priv->tx_lock); |
2663 | priv->inconfig = false; | 2668 | priv->inconfig = false; |
2664 | if (priv->pending_tx_pkts && priv->radio_state) | 2669 | if (priv->pending_tx_pkts && priv->radio_on) |
2665 | mwl8k_tx_start(priv); | 2670 | mwl8k_tx_start(priv); |
2666 | spin_unlock_irq(&priv->tx_lock); | 2671 | spin_unlock_irq(&priv->tx_lock); |
2667 | ieee80211_wake_queues(hw); | 2672 | ieee80211_wake_queues(hw); |
@@ -2745,7 +2750,7 @@ static int mwl8k_start_wt(struct work_struct *wt) | |||
2745 | } | 2750 | } |
2746 | 2751 | ||
2747 | /* Turn on radio */ | 2752 | /* Turn on radio */ |
2748 | if (mwl8k_cmd_802_11_radio_control(hw, MWL8K_RADIO_ENABLE)) { | 2753 | if (mwl8k_cmd_802_11_radio_enable(hw)) { |
2749 | rc = -EIO; | 2754 | rc = -EIO; |
2750 | goto mwl8k_start_exit; | 2755 | goto mwl8k_start_exit; |
2751 | } | 2756 | } |
@@ -2839,11 +2844,8 @@ static int mwl8k_stop_wt(struct work_struct *wt) | |||
2839 | { | 2844 | { |
2840 | struct mwl8k_stop_worker *worker = (struct mwl8k_stop_worker *)wt; | 2845 | struct mwl8k_stop_worker *worker = (struct mwl8k_stop_worker *)wt; |
2841 | struct ieee80211_hw *hw = worker->header.hw; | 2846 | struct ieee80211_hw *hw = worker->header.hw; |
2842 | int rc; | ||
2843 | |||
2844 | rc = mwl8k_cmd_802_11_radio_control(hw, MWL8K_RADIO_DISABLE); | ||
2845 | 2847 | ||
2846 | return rc; | 2848 | return mwl8k_cmd_802_11_radio_disable(hw); |
2847 | } | 2849 | } |
2848 | 2850 | ||
2849 | static void mwl8k_stop(struct ieee80211_hw *hw) | 2851 | static void mwl8k_stop(struct ieee80211_hw *hw) |
@@ -2958,7 +2960,7 @@ static int mwl8k_config_wt(struct work_struct *wt) | |||
2958 | struct mwl8k_priv *priv = hw->priv; | 2960 | struct mwl8k_priv *priv = hw->priv; |
2959 | int rc = 0; | 2961 | int rc = 0; |
2960 | 2962 | ||
2961 | if (mwl8k_cmd_802_11_radio_control(hw, MWL8K_RADIO_ENABLE)) { | 2963 | if (mwl8k_cmd_802_11_radio_enable(hw)) { |
2962 | rc = -EINVAL; | 2964 | rc = -EINVAL; |
2963 | goto mwl8k_config_exit; | 2965 | goto mwl8k_config_exit; |
2964 | } | 2966 | } |
@@ -3503,7 +3505,7 @@ static int __devinit mwl8k_probe(struct pci_dev *pdev, | |||
3503 | 3505 | ||
3504 | /* Set default radio state and preamble */ | 3506 | /* Set default radio state and preamble */ |
3505 | priv->radio_preamble = MWL8K_RADIO_DEFAULT_PREAMBLE; | 3507 | priv->radio_preamble = MWL8K_RADIO_DEFAULT_PREAMBLE; |
3506 | priv->radio_state = MWL8K_RADIO_DISABLE; | 3508 | priv->radio_on = 0; |
3507 | 3509 | ||
3508 | /* Finalize join worker */ | 3510 | /* Finalize join worker */ |
3509 | INIT_WORK(&priv->finalize_join_worker, mwl8k_finalize_join_worker); | 3511 | INIT_WORK(&priv->finalize_join_worker, mwl8k_finalize_join_worker); |
@@ -3584,7 +3586,7 @@ static int __devinit mwl8k_probe(struct pci_dev *pdev, | |||
3584 | } | 3586 | } |
3585 | 3587 | ||
3586 | /* Turn radio off */ | 3588 | /* Turn radio off */ |
3587 | rc = mwl8k_cmd_802_11_radio_control(hw, MWL8K_RADIO_DISABLE); | 3589 | rc = mwl8k_cmd_802_11_radio_disable(hw); |
3588 | if (rc) { | 3590 | if (rc) { |
3589 | printk(KERN_ERR "%s: Cannot disable\n", priv->name); | 3591 | printk(KERN_ERR "%s: Cannot disable\n", priv->name); |
3590 | goto err_stop_firmware; | 3592 | goto err_stop_firmware; |