iwmc3200wifi: rfkill cleanup
authorZhu Yi <yi.zhu@intel.com>
Mon, 15 Jun 2009 19:59:56 +0000 (21:59 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 10 Jul 2009 18:57:52 +0000 (14:57 -0400)
The patch cleans up the unused rfkill related structures and flags.
It also adds wext and cfg80211 handlers for txpower auto and off so
that software rfkill could be issued by user space.

Signed-off-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: Samuel Ortiz <samuel.ortiz@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/iwmc3200wifi/cfg80211.c
drivers/net/wireless/iwmc3200wifi/iwm.h
drivers/net/wireless/iwmc3200wifi/netdev.c
drivers/net/wireless/iwmc3200wifi/rx.c
drivers/net/wireless/iwmc3200wifi/sdio.c
drivers/net/wireless/iwmc3200wifi/wext.c

index 0cdd7ef68b78e5daa8b2194e79e4b2e950a3d208..d0629d4757d7cc3cfb16f5d43e671cf6a1713768 100644 (file)
@@ -500,6 +500,28 @@ static int iwm_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
        return 0;
 }
 
+static int iwm_cfg80211_set_txpower(struct wiphy *wiphy,
+                                   enum tx_power_setting type, int dbm)
+{
+       switch (type) {
+       case TX_POWER_AUTOMATIC:
+               return 0;
+       default:
+               return -EOPNOTSUPP;
+       }
+
+       return 0;
+}
+
+static int iwm_cfg80211_get_txpower(struct wiphy *wiphy, int *dbm)
+{
+       struct iwm_priv *iwm = wiphy_to_iwm(wiphy);
+
+       *dbm = iwm->txpower;
+
+       return 0;
+}
+
 static struct cfg80211_ops iwm_cfg80211_ops = {
        .change_virtual_intf = iwm_cfg80211_change_iface,
        .add_key = iwm_cfg80211_add_key,
@@ -510,6 +532,8 @@ static struct cfg80211_ops iwm_cfg80211_ops = {
        .set_wiphy_params = iwm_cfg80211_set_wiphy_params,
        .join_ibss = iwm_cfg80211_join_ibss,
        .leave_ibss = iwm_cfg80211_leave_ibss,
+       .set_tx_power = iwm_cfg80211_set_txpower,
+       .get_tx_power = iwm_cfg80211_get_txpower,
 };
 
 struct wireless_dev *iwm_wdev_alloc(int sizeof_bus, struct device *dev)
index 90b05d99963574f64cf919205f127b090193a7b9..4da57f737f2707e3e3d69fd3d197c30574b79a0e 100644 (file)
@@ -184,10 +184,6 @@ struct iwm_key {
 #define IWM_STATUS_ASSOCIATING         3
 #define IWM_STATUS_ASSOCIATED          4
 
-#define IWM_RADIO_RFKILL_OFF           0
-#define IWM_RADIO_RFKILL_HW            1
-#define IWM_RADIO_RFKILL_SW            2
-
 struct iwm_tx_queue {
        int id;
        struct sk_buff_head queue;
@@ -221,7 +217,6 @@ struct iwm_priv {
        struct iwm_conf conf;
 
        unsigned long status;
-       unsigned long radio;
 
        struct list_head pending_notif;
        wait_queue_head_t notif_queue;
@@ -240,6 +235,7 @@ struct iwm_priv {
        u8 bssid[ETH_ALEN];
        u8 channel;
        u16 rate;
+       u32 txpower;
 
        struct iwm_sta_info sta_table[IWM_STA_TABLE_NUM];
        struct list_head bss_list;
@@ -290,7 +286,6 @@ struct iwm_priv {
        struct timer_list watchdog;
        struct work_struct reset_worker;
        struct mutex mutex;
-       struct rfkill *rfkill;
 
        char private[0] __attribute__((__aligned__(NETDEV_ALIGN)));
 };
index d4deb4b471e529f208f64b21904de47c0a5cf549..e94e96955b99ba2268a0f0f3e3343125298eb676 100644 (file)
 static int iwm_open(struct net_device *ndev)
 {
        struct iwm_priv *iwm = ndev_to_iwm(ndev);
-       int ret = 0;
-
-       if (!test_bit(IWM_RADIO_RFKILL_SW, &iwm->radio))
-               ret = iwm_up(iwm);
 
-       return ret;
+       return iwm_up(iwm);
 }
 
 static int iwm_stop(struct net_device *ndev)
 {
        struct iwm_priv *iwm = ndev_to_iwm(ndev);
-       int ret = 0;
-
-       if (!test_bit(IWM_RADIO_RFKILL_SW, &iwm->radio))
-               ret = iwm_down(iwm);
 
-       return ret;
+       return iwm_down(iwm);
 }
 
 /*
index 49a8be7c539604d7203dea1630f5de3125de66fa..55871da695a93a2c62a827efd9561f66f78fb04d 100644 (file)
@@ -143,17 +143,18 @@ static int iwm_ntf_init_complete(struct iwm_priv *iwm, u8 *buf,
                                 unsigned long buf_size,
                                 struct iwm_wifi_cmd *cmd)
 {
+       struct wiphy *wiphy = iwm_to_wiphy(iwm);
        struct iwm_umac_notif_init_complete *init_complete =
                        (struct iwm_umac_notif_init_complete *)(buf);
        u16 status = le16_to_cpu(init_complete->status);
+       bool blocked = (status == UMAC_NTFY_INIT_COMPLETE_STATUS_ERR);
 
-       if (status == UMAC_NTFY_INIT_COMPLETE_STATUS_ERR) {
+       if (blocked)
                IWM_DBG_NTF(iwm, DBG, "Hardware rf kill is on (radio off)\n");
-               set_bit(IWM_RADIO_RFKILL_HW, &iwm->radio);
-       } else {
+       else
                IWM_DBG_NTF(iwm, DBG, "Hardware rf kill is off (radio on)\n");
-               clear_bit(IWM_RADIO_RFKILL_HW, &iwm->radio);
-       }
+
+       wiphy_rfkill_set_hw_state(wiphy, blocked);
 
        return 0;
 }
@@ -875,6 +876,7 @@ static int iwm_ntf_statistics(struct iwm_priv *iwm, u8 *buf,
                /* UMAC passes rate info multiplies by 2 */
                iwm->rate = max_rate >> 1;
        }
+       iwm->txpower = le32_to_cpu(stats->tx_power);
 
        wstats->status = 0;
 
@@ -1015,6 +1017,7 @@ static int iwm_ntf_wifi_if_wrapper(struct iwm_priv *iwm, u8 *buf,
 static int iwm_ntf_card_state(struct iwm_priv *iwm, u8 *buf,
                              unsigned long buf_size, struct iwm_wifi_cmd *cmd)
 {
+       struct wiphy *wiphy = iwm_to_wiphy(iwm);
        struct iwm_lmac_card_state *state = (struct iwm_lmac_card_state *)
                                (buf + sizeof(struct iwm_umac_wifi_in_hdr));
        u32 flags = le32_to_cpu(state->flags);
@@ -1023,10 +1026,7 @@ static int iwm_ntf_card_state(struct iwm_priv *iwm, u8 *buf,
                 flags & IWM_CARD_STATE_HW_DISABLED ? "ON" : "OFF",
                 flags & IWM_CARD_STATE_CTKILL_DISABLED ? "ON" : "OFF");
 
-       if (flags & IWM_CARD_STATE_HW_DISABLED)
-               set_bit(IWM_RADIO_RFKILL_HW, &iwm->radio);
-       else
-               clear_bit(IWM_RADIO_RFKILL_HW, &iwm->radio);
+       wiphy_rfkill_set_hw_state(wiphy, flags & IWM_CARD_STATE_HW_DISABLED);
 
        return 0;
 }
index 916681837fd2296825dfc41471a29ef2ceb890fb..b93f620ee4f17efa1432c7438bf0f19d52c792be 100644 (file)
@@ -506,11 +506,7 @@ static struct sdio_driver iwm_sdio_driver = {
 
 static int __init iwm_sdio_init_module(void)
 {
-       int ret;
-
-       ret = sdio_register_driver(&iwm_sdio_driver);
-
-       return ret;
+       return sdio_register_driver(&iwm_sdio_driver);
 }
 
 static void __exit iwm_sdio_exit_module(void)
index 3062f37bbe95a72f7e6582d5ff13b44f90aee93f..973457383c113af04e81687fcfe86a1f97555be0 100644 (file)
@@ -452,8 +452,8 @@ static const iw_handler iwm_handlers[] =
        (iw_handler) cfg80211_wext_giwrts,              /* SIOCGIWRTS */
        (iw_handler) cfg80211_wext_siwfrag,             /* SIOCSIWFRAG */
        (iw_handler) cfg80211_wext_giwfrag,             /* SIOCGIWFRAG */
-       (iw_handler) NULL,                              /* SIOCSIWTXPOW */
-       (iw_handler) NULL,                              /* SIOCGIWTXPOW */
+       (iw_handler) cfg80211_wext_siwtxpower,          /* SIOCSIWTXPOW */
+       (iw_handler) cfg80211_wext_giwtxpower,          /* SIOCGIWTXPOW */
        (iw_handler) NULL,                              /* SIOCSIWRETRY */
        (iw_handler) NULL,                              /* SIOCGIWRETRY */
        (iw_handler) cfg80211_wext_siwencode,           /* SIOCSIWENCODE */