Commit 257862f3 authored by Zhu Yi's avatar Zhu Yi Committed by John W. Linville

iwmc3200wifi: rfkill cleanup

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: default avatarZhu Yi <yi.zhu@intel.com>
Signed-off-by: default avatarSamuel Ortiz <samuel.ortiz@intel.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 35497164
...@@ -500,6 +500,28 @@ static int iwm_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) ...@@ -500,6 +500,28 @@ static int iwm_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
return 0; 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 = { static struct cfg80211_ops iwm_cfg80211_ops = {
.change_virtual_intf = iwm_cfg80211_change_iface, .change_virtual_intf = iwm_cfg80211_change_iface,
.add_key = iwm_cfg80211_add_key, .add_key = iwm_cfg80211_add_key,
...@@ -510,6 +532,8 @@ static struct cfg80211_ops iwm_cfg80211_ops = { ...@@ -510,6 +532,8 @@ static struct cfg80211_ops iwm_cfg80211_ops = {
.set_wiphy_params = iwm_cfg80211_set_wiphy_params, .set_wiphy_params = iwm_cfg80211_set_wiphy_params,
.join_ibss = iwm_cfg80211_join_ibss, .join_ibss = iwm_cfg80211_join_ibss,
.leave_ibss = iwm_cfg80211_leave_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) struct wireless_dev *iwm_wdev_alloc(int sizeof_bus, struct device *dev)
......
...@@ -184,10 +184,6 @@ struct iwm_key { ...@@ -184,10 +184,6 @@ struct iwm_key {
#define IWM_STATUS_ASSOCIATING 3 #define IWM_STATUS_ASSOCIATING 3
#define IWM_STATUS_ASSOCIATED 4 #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 { struct iwm_tx_queue {
int id; int id;
struct sk_buff_head queue; struct sk_buff_head queue;
...@@ -221,7 +217,6 @@ struct iwm_priv { ...@@ -221,7 +217,6 @@ struct iwm_priv {
struct iwm_conf conf; struct iwm_conf conf;
unsigned long status; unsigned long status;
unsigned long radio;
struct list_head pending_notif; struct list_head pending_notif;
wait_queue_head_t notif_queue; wait_queue_head_t notif_queue;
...@@ -240,6 +235,7 @@ struct iwm_priv { ...@@ -240,6 +235,7 @@ struct iwm_priv {
u8 bssid[ETH_ALEN]; u8 bssid[ETH_ALEN];
u8 channel; u8 channel;
u16 rate; u16 rate;
u32 txpower;
struct iwm_sta_info sta_table[IWM_STA_TABLE_NUM]; struct iwm_sta_info sta_table[IWM_STA_TABLE_NUM];
struct list_head bss_list; struct list_head bss_list;
...@@ -290,7 +286,6 @@ struct iwm_priv { ...@@ -290,7 +286,6 @@ struct iwm_priv {
struct timer_list watchdog; struct timer_list watchdog;
struct work_struct reset_worker; struct work_struct reset_worker;
struct mutex mutex; struct mutex mutex;
struct rfkill *rfkill;
char private[0] __attribute__((__aligned__(NETDEV_ALIGN))); char private[0] __attribute__((__aligned__(NETDEV_ALIGN)));
}; };
......
...@@ -55,23 +55,15 @@ ...@@ -55,23 +55,15 @@
static int iwm_open(struct net_device *ndev) static int iwm_open(struct net_device *ndev)
{ {
struct iwm_priv *iwm = ndev_to_iwm(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) static int iwm_stop(struct net_device *ndev)
{ {
struct iwm_priv *iwm = ndev_to_iwm(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);
} }
/* /*
......
...@@ -143,17 +143,18 @@ static int iwm_ntf_init_complete(struct iwm_priv *iwm, u8 *buf, ...@@ -143,17 +143,18 @@ static int iwm_ntf_init_complete(struct iwm_priv *iwm, u8 *buf,
unsigned long buf_size, unsigned long buf_size,
struct iwm_wifi_cmd *cmd) 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 *init_complete =
(struct iwm_umac_notif_init_complete *)(buf); (struct iwm_umac_notif_init_complete *)(buf);
u16 status = le16_to_cpu(init_complete->status); 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"); 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"); 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; return 0;
} }
...@@ -875,6 +876,7 @@ static int iwm_ntf_statistics(struct iwm_priv *iwm, u8 *buf, ...@@ -875,6 +876,7 @@ static int iwm_ntf_statistics(struct iwm_priv *iwm, u8 *buf,
/* UMAC passes rate info multiplies by 2 */ /* UMAC passes rate info multiplies by 2 */
iwm->rate = max_rate >> 1; iwm->rate = max_rate >> 1;
} }
iwm->txpower = le32_to_cpu(stats->tx_power);
wstats->status = 0; wstats->status = 0;
...@@ -1015,6 +1017,7 @@ static int iwm_ntf_wifi_if_wrapper(struct iwm_priv *iwm, u8 *buf, ...@@ -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, static int iwm_ntf_card_state(struct iwm_priv *iwm, u8 *buf,
unsigned long buf_size, struct iwm_wifi_cmd *cmd) 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 *) struct iwm_lmac_card_state *state = (struct iwm_lmac_card_state *)
(buf + sizeof(struct iwm_umac_wifi_in_hdr)); (buf + sizeof(struct iwm_umac_wifi_in_hdr));
u32 flags = le32_to_cpu(state->flags); u32 flags = le32_to_cpu(state->flags);
...@@ -1023,10 +1026,7 @@ static int iwm_ntf_card_state(struct iwm_priv *iwm, u8 *buf, ...@@ -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_HW_DISABLED ? "ON" : "OFF",
flags & IWM_CARD_STATE_CTKILL_DISABLED ? "ON" : "OFF"); flags & IWM_CARD_STATE_CTKILL_DISABLED ? "ON" : "OFF");
if (flags & IWM_CARD_STATE_HW_DISABLED) wiphy_rfkill_set_hw_state(wiphy, flags & IWM_CARD_STATE_HW_DISABLED);
set_bit(IWM_RADIO_RFKILL_HW, &iwm->radio);
else
clear_bit(IWM_RADIO_RFKILL_HW, &iwm->radio);
return 0; return 0;
} }
......
...@@ -506,11 +506,7 @@ static struct sdio_driver iwm_sdio_driver = { ...@@ -506,11 +506,7 @@ static struct sdio_driver iwm_sdio_driver = {
static int __init iwm_sdio_init_module(void) static int __init iwm_sdio_init_module(void)
{ {
int ret; return sdio_register_driver(&iwm_sdio_driver);
ret = sdio_register_driver(&iwm_sdio_driver);
return ret;
} }
static void __exit iwm_sdio_exit_module(void) static void __exit iwm_sdio_exit_module(void)
......
...@@ -452,8 +452,8 @@ static const iw_handler iwm_handlers[] = ...@@ -452,8 +452,8 @@ static const iw_handler iwm_handlers[] =
(iw_handler) cfg80211_wext_giwrts, /* SIOCGIWRTS */ (iw_handler) cfg80211_wext_giwrts, /* SIOCGIWRTS */
(iw_handler) cfg80211_wext_siwfrag, /* SIOCSIWFRAG */ (iw_handler) cfg80211_wext_siwfrag, /* SIOCSIWFRAG */
(iw_handler) cfg80211_wext_giwfrag, /* SIOCGIWFRAG */ (iw_handler) cfg80211_wext_giwfrag, /* SIOCGIWFRAG */
(iw_handler) NULL, /* SIOCSIWTXPOW */ (iw_handler) cfg80211_wext_siwtxpower, /* SIOCSIWTXPOW */
(iw_handler) NULL, /* SIOCGIWTXPOW */ (iw_handler) cfg80211_wext_giwtxpower, /* SIOCGIWTXPOW */
(iw_handler) NULL, /* SIOCSIWRETRY */ (iw_handler) NULL, /* SIOCSIWRETRY */
(iw_handler) NULL, /* SIOCGIWRETRY */ (iw_handler) NULL, /* SIOCGIWRETRY */
(iw_handler) cfg80211_wext_siwencode, /* SIOCSIWENCODE */ (iw_handler) cfg80211_wext_siwencode, /* SIOCSIWENCODE */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment