Commit 5ed540ae authored by Wey-Yi Guy's avatar Wey-Yi Guy

iwlwifi: use mac80211 throughput trigger

Instead of keeping track of LED blink speed
in the driver, use the new mac80211 trigger
and link it up with an LED classdev that we
now register. This also allows users more
flexibility in how they want to have the LED
blink or not.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarWey-Yi Guy <wey-yi.w.guy@intel.com>
parent 4a4fdf2e
...@@ -2,6 +2,10 @@ config IWLWIFI ...@@ -2,6 +2,10 @@ config IWLWIFI
tristate "Intel Wireless Wifi" tristate "Intel Wireless Wifi"
depends on PCI && MAC80211 depends on PCI && MAC80211
select FW_LOADER select FW_LOADER
select NEW_LEDS
select LEDS_CLASS
select LEDS_TRIGGERS
select MAC80211_LEDS
menu "Debugging Options" menu "Debugging Options"
depends on IWLWIFI depends on IWLWIFI
......
...@@ -59,33 +59,6 @@ static int iwl3945_send_led_cmd(struct iwl_priv *priv, ...@@ -59,33 +59,6 @@ static int iwl3945_send_led_cmd(struct iwl_priv *priv,
return iwl_send_cmd(priv, &cmd); return iwl_send_cmd(priv, &cmd);
} }
/* Set led on command */
static int iwl3945_led_on(struct iwl_priv *priv)
{
struct iwl_led_cmd led_cmd = {
.id = IWL_LED_LINK,
.on = IWL_LED_SOLID,
.off = 0,
.interval = IWL_DEF_LED_INTRVL
};
return iwl3945_send_led_cmd(priv, &led_cmd);
}
/* Set led off command */
static int iwl3945_led_off(struct iwl_priv *priv)
{
struct iwl_led_cmd led_cmd = {
.id = IWL_LED_LINK,
.on = 0,
.off = 0,
.interval = IWL_DEF_LED_INTRVL
};
IWL_DEBUG_LED(priv, "led off\n");
return iwl3945_send_led_cmd(priv, &led_cmd);
}
const struct iwl_led_ops iwl3945_led_ops = { const struct iwl_led_ops iwl3945_led_ops = {
.cmd = iwl3945_send_led_cmd, .cmd = iwl3945_send_led_cmd,
.on = iwl3945_led_on,
.off = iwl3945_led_off,
}; };
...@@ -63,23 +63,11 @@ static int iwl_send_led_cmd(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd) ...@@ -63,23 +63,11 @@ static int iwl_send_led_cmd(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd)
} }
/* Set led register off */ /* Set led register off */
static int iwl_led_on_reg(struct iwl_priv *priv) void iwlagn_led_enable(struct iwl_priv *priv)
{ {
IWL_DEBUG_LED(priv, "led on\n");
iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_ON); iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_ON);
return 0;
}
/* Set led register off */
static int iwl_led_off_reg(struct iwl_priv *priv)
{
IWL_DEBUG_LED(priv, "LED Reg off\n");
iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_OFF);
return 0;
} }
const struct iwl_led_ops iwlagn_led_ops = { const struct iwl_led_ops iwlagn_led_ops = {
.cmd = iwl_send_led_cmd, .cmd = iwl_send_led_cmd,
.on = iwl_led_on_reg,
.off = iwl_led_off_reg,
}; };
...@@ -28,5 +28,6 @@ ...@@ -28,5 +28,6 @@
#define __iwl_agn_led_h__ #define __iwl_agn_led_h__
extern const struct iwl_led_ops iwlagn_led_ops; extern const struct iwl_led_ops iwlagn_led_ops;
void iwlagn_led_enable(struct iwl_priv *priv);
#endif /* __iwl_agn_led_h__ */ #endif /* __iwl_agn_led_h__ */
...@@ -557,12 +557,10 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw, ...@@ -557,12 +557,10 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw,
if (changes & BSS_CHANGED_ASSOC) { if (changes & BSS_CHANGED_ASSOC) {
if (bss_conf->assoc) { if (bss_conf->assoc) {
iwl_led_associate(priv);
priv->timestamp = bss_conf->timestamp; priv->timestamp = bss_conf->timestamp;
ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;
} else { } else {
ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
iwl_led_disassociate(priv);
} }
} }
......
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
#include "iwl-sta.h" #include "iwl-sta.h"
#include "iwl-agn-calib.h" #include "iwl-agn-calib.h"
#include "iwl-agn.h" #include "iwl-agn.h"
#include "iwl-agn-led.h"
/****************************************************************************** /******************************************************************************
...@@ -2741,8 +2742,6 @@ static void iwl_alive_start(struct iwl_priv *priv) ...@@ -2741,8 +2742,6 @@ static void iwl_alive_start(struct iwl_priv *priv)
/* At this point, the NIC is initialized and operational */ /* At this point, the NIC is initialized and operational */
iwl_rf_kill_ct_config(priv); iwl_rf_kill_ct_config(priv);
iwl_leds_init(priv);
IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n"); IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n");
wake_up_interruptible(&priv->wait_command_queue); wake_up_interruptible(&priv->wait_command_queue);
...@@ -3234,6 +3233,8 @@ static int iwl_mac_setup_register(struct iwl_priv *priv, ...@@ -3234,6 +3233,8 @@ static int iwl_mac_setup_register(struct iwl_priv *priv,
priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
&priv->bands[IEEE80211_BAND_5GHZ]; &priv->bands[IEEE80211_BAND_5GHZ];
iwl_leds_init(priv);
ret = ieee80211_register_hw(priv->hw); ret = ieee80211_register_hw(priv->hw);
if (ret) { if (ret) {
IWL_ERR(priv, "Failed to register hw (error %d)\n", ret); IWL_ERR(priv, "Failed to register hw (error %d)\n", ret);
...@@ -3278,7 +3279,7 @@ int iwlagn_mac_start(struct ieee80211_hw *hw) ...@@ -3278,7 +3279,7 @@ int iwlagn_mac_start(struct ieee80211_hw *hw)
} }
} }
iwl_led_start(priv); iwlagn_led_enable(priv);
out: out:
priv->is_open = 1; priv->is_open = 1;
...@@ -4288,6 +4289,9 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev) ...@@ -4288,6 +4289,9 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev)
* we need to set STATUS_EXIT_PENDING bit. * we need to set STATUS_EXIT_PENDING bit.
*/ */
set_bit(STATUS_EXIT_PENDING, &priv->status); set_bit(STATUS_EXIT_PENDING, &priv->status);
iwl_leds_exit(priv);
if (priv->mac80211_registered) { if (priv->mac80211_registered) {
ieee80211_unregister_hw(priv->hw); ieee80211_unregister_hw(priv->hw);
priv->mac80211_registered = 0; priv->mac80211_registered = 0;
......
...@@ -1676,7 +1676,6 @@ void iwl_clear_traffic_stats(struct iwl_priv *priv) ...@@ -1676,7 +1676,6 @@ void iwl_clear_traffic_stats(struct iwl_priv *priv)
{ {
memset(&priv->tx_stats, 0, sizeof(struct traffic_stats)); memset(&priv->tx_stats, 0, sizeof(struct traffic_stats));
memset(&priv->rx_stats, 0, sizeof(struct traffic_stats)); memset(&priv->rx_stats, 0, sizeof(struct traffic_stats));
priv->led_tpt = 0;
} }
/* /*
...@@ -1769,7 +1768,6 @@ void iwl_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, u16 len) ...@@ -1769,7 +1768,6 @@ void iwl_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, u16 len)
stats->data_cnt++; stats->data_cnt++;
stats->data_bytes += len; stats->data_bytes += len;
} }
iwl_leds_background(priv);
} }
EXPORT_SYMBOL(iwl_update_stats); EXPORT_SYMBOL(iwl_update_stats);
#endif #endif
......
...@@ -227,8 +227,6 @@ struct iwl_lib_ops { ...@@ -227,8 +227,6 @@ struct iwl_lib_ops {
struct iwl_led_ops { struct iwl_led_ops {
int (*cmd)(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd); int (*cmd)(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd);
int (*on)(struct iwl_priv *priv);
int (*off)(struct iwl_priv *priv);
}; };
/* NIC specific ops */ /* NIC specific ops */
...@@ -494,18 +492,6 @@ static inline void iwl_dbg_log_rx_data_frame(struct iwl_priv *priv, ...@@ -494,18 +492,6 @@ static inline void iwl_dbg_log_rx_data_frame(struct iwl_priv *priv,
static inline void iwl_update_stats(struct iwl_priv *priv, bool is_tx, static inline void iwl_update_stats(struct iwl_priv *priv, bool is_tx,
__le16 fc, u16 len) __le16 fc, u16 len)
{ {
struct traffic_stats *stats;
if (is_tx)
stats = &priv->tx_stats;
else
stats = &priv->rx_stats;
if (ieee80211_is_data(fc)) {
/* data */
stats->data_bytes += len;
}
iwl_leds_background(priv);
} }
#endif #endif
/***************************************************** /*****************************************************
......
...@@ -668,29 +668,6 @@ static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf, ...@@ -668,29 +668,6 @@ static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
return simple_read_from_buffer(user_buf, count, ppos, buf, pos); return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
} }
static ssize_t iwl_dbgfs_led_read(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
struct iwl_priv *priv = file->private_data;
int pos = 0;
char buf[256];
const size_t bufsz = sizeof(buf);
pos += scnprintf(buf + pos, bufsz - pos,
"allow blinking: %s\n",
(priv->allow_blinking) ? "True" : "False");
if (priv->allow_blinking) {
pos += scnprintf(buf + pos, bufsz - pos,
"Led blinking rate: %u\n",
priv->last_blink_rate);
pos += scnprintf(buf + pos, bufsz - pos,
"Last blink time: %lu\n",
priv->last_blink_time);
}
return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
}
static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file, static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
char __user *user_buf, char __user *user_buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
...@@ -856,7 +833,6 @@ DEBUGFS_READ_FILE_OPS(channels); ...@@ -856,7 +833,6 @@ DEBUGFS_READ_FILE_OPS(channels);
DEBUGFS_READ_FILE_OPS(status); DEBUGFS_READ_FILE_OPS(status);
DEBUGFS_READ_WRITE_FILE_OPS(interrupt); DEBUGFS_READ_WRITE_FILE_OPS(interrupt);
DEBUGFS_READ_FILE_OPS(qos); DEBUGFS_READ_FILE_OPS(qos);
DEBUGFS_READ_FILE_OPS(led);
DEBUGFS_READ_FILE_OPS(thermal_throttling); DEBUGFS_READ_FILE_OPS(thermal_throttling);
DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override); DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
...@@ -1725,7 +1701,6 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) ...@@ -1725,7 +1701,6 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR); DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR);
DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR); DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR);
DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR); DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR);
DEBUGFS_ADD_FILE(led, dir_data, S_IRUSR);
if (!priv->cfg->base_params->broken_powersave) { if (!priv->cfg->base_params->broken_powersave) {
DEBUGFS_ADD_FILE(sleep_level_override, dir_data, DEBUGFS_ADD_FILE(sleep_level_override, dir_data,
S_IWUSR | S_IRUSR); S_IWUSR | S_IRUSR);
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/pci.h> /* for struct pci_device_id */ #include <linux/pci.h> /* for struct pci_device_id */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/leds.h>
#include <net/ieee80211_radiotap.h> #include <net/ieee80211_radiotap.h>
#include "iwl-eeprom.h" #include "iwl-eeprom.h"
...@@ -996,7 +997,6 @@ struct reply_agg_tx_error_statistics { ...@@ -996,7 +997,6 @@ struct reply_agg_tx_error_statistics {
u32 unknown; u32 unknown;
}; };
#ifdef CONFIG_IWLWIFI_DEBUGFS
/* management statistics */ /* management statistics */
enum iwl_mgmt_stats { enum iwl_mgmt_stats {
MANAGEMENT_ASSOC_REQ = 0, MANAGEMENT_ASSOC_REQ = 0,
...@@ -1027,16 +1027,13 @@ enum iwl_ctrl_stats { ...@@ -1027,16 +1027,13 @@ enum iwl_ctrl_stats {
}; };
struct traffic_stats { struct traffic_stats {
#ifdef CONFIG_IWLWIFI_DEBUGFS
u32 mgmt[MANAGEMENT_MAX]; u32 mgmt[MANAGEMENT_MAX];
u32 ctrl[CONTROL_MAX]; u32 ctrl[CONTROL_MAX];
u32 data_cnt; u32 data_cnt;
u64 data_bytes; u64 data_bytes;
};
#else
struct traffic_stats {
u64 data_bytes;
};
#endif #endif
};
/* /*
* iwl_switch_rxon: "channel switch" structure * iwl_switch_rxon: "channel switch" structure
...@@ -1338,11 +1335,6 @@ struct iwl_priv { ...@@ -1338,11 +1335,6 @@ struct iwl_priv {
struct iwl_init_alive_resp card_alive_init; struct iwl_init_alive_resp card_alive_init;
struct iwl_alive_resp card_alive; struct iwl_alive_resp card_alive;
unsigned long last_blink_time;
u8 last_blink_rate;
u8 allow_blinking;
u64 led_tpt;
u16 active_rate; u16 active_rate;
u8 start_calib; u8 start_calib;
...@@ -1580,6 +1572,10 @@ struct iwl_priv { ...@@ -1580,6 +1572,10 @@ struct iwl_priv {
bool hw_ready; bool hw_ready;
struct iwl_event_log event_log; struct iwl_event_log event_log;
struct led_classdev led;
unsigned long blink_on, blink_off;
bool led_registered;
}; /*iwl_priv */ }; /*iwl_priv */
static inline void iwl_txq_ctx_activate(struct iwl_priv *priv, int txq_id) static inline void iwl_txq_ctx_activate(struct iwl_priv *priv, int txq_id)
......
...@@ -48,31 +48,19 @@ module_param(led_mode, int, S_IRUGO); ...@@ -48,31 +48,19 @@ module_param(led_mode, int, S_IRUGO);
MODULE_PARM_DESC(led_mode, "0=system default, " MODULE_PARM_DESC(led_mode, "0=system default, "
"1=On(RF On)/Off(RF Off), 2=blinking"); "1=On(RF On)/Off(RF Off), 2=blinking");
static const struct { static const struct ieee80211_tpt_blink iwl_blink[] = {
u16 tpt; /* Mb/s */ { .throughput = 0 * 1024 - 1, .blink_time = 334 },
u8 on_time; { .throughput = 1 * 1024 - 1, .blink_time = 260 },
u8 off_time; { .throughput = 5 * 1024 - 1, .blink_time = 220 },
} blink_tbl[] = { .throughput = 10 * 1024 - 1, .blink_time = 190 },
{ { .throughput = 20 * 1024 - 1, .blink_time = 170 },
{300, 25, 25}, { .throughput = 50 * 1024 - 1, .blink_time = 150 },
{200, 40, 40}, { .throughput = 70 * 1024 - 1, .blink_time = 130 },
{100, 55, 55}, { .throughput = 100 * 1024 - 1, .blink_time = 110 },
{70, 65, 65}, { .throughput = 200 * 1024 - 1, .blink_time = 80 },
{50, 75, 75}, { .throughput = 300 * 1024 - 1, .blink_time = 50 },
{20, 85, 85},
{10, 95, 95},
{5, 110, 110},
{1, 130, 130},
{0, 167, 167},
/* SOLID_ON */
{-1, IWL_LED_SOLID, 0}
}; };
#define IWL_1MB_RATE (128 * 1024)
#define IWL_LED_THRESHOLD (16)
#define IWL_MAX_BLINK_TBL (ARRAY_SIZE(blink_tbl) - 1) /* exclude SOLID_ON */
#define IWL_SOLID_BLINK_IDX (ARRAY_SIZE(blink_tbl) - 1)
/* /*
* Adjust led blink rate to compensate on a MAC Clock difference on every HW * Adjust led blink rate to compensate on a MAC Clock difference on every HW
* Led blink rate analysis showed an average deviation of 0% on 3945, * Led blink rate analysis showed an average deviation of 0% on 3945,
...@@ -97,133 +85,104 @@ static inline u8 iwl_blink_compensation(struct iwl_priv *priv, ...@@ -97,133 +85,104 @@ static inline u8 iwl_blink_compensation(struct iwl_priv *priv,
} }
/* Set led pattern command */ /* Set led pattern command */
static int iwl_led_pattern(struct iwl_priv *priv, unsigned int idx) static int iwl_led_cmd(struct iwl_priv *priv,
unsigned long on,
unsigned long off)
{ {
struct iwl_led_cmd led_cmd = { struct iwl_led_cmd led_cmd = {
.id = IWL_LED_LINK, .id = IWL_LED_LINK,
.interval = IWL_DEF_LED_INTRVL .interval = IWL_DEF_LED_INTRVL
}; };
int ret;
BUG_ON(idx > IWL_MAX_BLINK_TBL); if (!test_bit(STATUS_READY, &priv->status))
return -EBUSY;
IWL_DEBUG_LED(priv, "Led blink time compensation= %u\n", if (priv->blink_on == on && priv->blink_off == off)
return 0;
IWL_DEBUG_LED(priv, "Led blink time compensation=%u\n",
priv->cfg->base_params->led_compensation); priv->cfg->base_params->led_compensation);
led_cmd.on = led_cmd.on = iwl_blink_compensation(priv, on,
iwl_blink_compensation(priv, blink_tbl[idx].on_time,
priv->cfg->base_params->led_compensation); priv->cfg->base_params->led_compensation);
led_cmd.off = led_cmd.off = iwl_blink_compensation(priv, off,
iwl_blink_compensation(priv, blink_tbl[idx].off_time,
priv->cfg->base_params->led_compensation); priv->cfg->base_params->led_compensation);
return priv->cfg->ops->led->cmd(priv, &led_cmd); ret = priv->cfg->ops->led->cmd(priv, &led_cmd);
if (!ret) {
priv->blink_on = on;
priv->blink_off = off;
}
return ret;
} }
int iwl_led_start(struct iwl_priv *priv) static void iwl_led_brightness_set(struct led_classdev *led_cdev,
enum led_brightness brightness)
{ {
return priv->cfg->ops->led->on(priv); struct iwl_priv *priv = container_of(led_cdev, struct iwl_priv, led);
} unsigned long on = 0;
EXPORT_SYMBOL(iwl_led_start);
int iwl_led_associate(struct iwl_priv *priv) if (brightness > 0)
{ on = IWL_LED_SOLID;
IWL_DEBUG_LED(priv, "Associated\n");
if (priv->cfg->led_mode == IWL_LED_BLINK)
priv->allow_blinking = 1;
priv->last_blink_time = jiffies;
return 0; iwl_led_cmd(priv, on, 0);
} }
EXPORT_SYMBOL(iwl_led_associate);
int iwl_led_disassociate(struct iwl_priv *priv) static int iwl_led_blink_set(struct led_classdev *led_cdev,
unsigned long *delay_on,
unsigned long *delay_off)
{ {
priv->allow_blinking = 0; struct iwl_priv *priv = container_of(led_cdev, struct iwl_priv, led);
return 0; return iwl_led_cmd(priv, *delay_on, *delay_off);
} }
EXPORT_SYMBOL(iwl_led_disassociate);
/* void iwl_leds_init(struct iwl_priv *priv)
* calculate blink rate according to last second Tx/Rx activities
*/
static int iwl_get_blink_rate(struct iwl_priv *priv)
{
int i;
/* count both tx and rx traffic to be able to
* handle traffic in either direction
*/
u64 current_tpt = priv->tx_stats.data_bytes +
priv->rx_stats.data_bytes;
s64 tpt = current_tpt - priv->led_tpt;
if (tpt < 0) /* wraparound */
tpt = -tpt;
IWL_DEBUG_LED(priv, "tpt %lld current_tpt %llu\n",
(long long)tpt,
(unsigned long long)current_tpt);
priv->led_tpt = current_tpt;
if (!priv->allow_blinking)
i = IWL_MAX_BLINK_TBL;
else
for (i = 0; i < IWL_MAX_BLINK_TBL; i++)
if (tpt > (blink_tbl[i].tpt * IWL_1MB_RATE))
break;
IWL_DEBUG_LED(priv, "LED BLINK IDX=%d\n", i);
return i;
}
/*
* this function called from handler. Since setting Led command can
* happen very frequent we postpone led command to be called from
* REPLY handler so we know ucode is up
*/
void iwl_leds_background(struct iwl_priv *priv)
{ {
u8 blink_idx; int mode = led_mode;
int ret;
if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
priv->last_blink_time = 0; if (mode == IWL_LED_DEFAULT)
return; mode = priv->cfg->led_mode;
}
if (iwl_is_rfkill(priv)) { priv->led.name = kasprintf(GFP_KERNEL, "%s-led",
priv->last_blink_time = 0; wiphy_name(priv->hw->wiphy));
return; priv->led.brightness_set = iwl_led_brightness_set;
priv->led.blink_set = iwl_led_blink_set;
priv->led.max_brightness = 1;
switch (mode) {
case IWL_LED_DEFAULT:
WARN_ON(1);
break;
case IWL_LED_BLINK:
priv->led.default_trigger =
ieee80211_create_tpt_led_trigger(priv->hw,
IEEE80211_TPT_LEDTRIG_FL_CONNECTED,
iwl_blink, ARRAY_SIZE(iwl_blink));
break;
case IWL_LED_RF_STATE:
priv->led.default_trigger =
ieee80211_get_radio_led_name(priv->hw);
break;
} }
if (!priv->allow_blinking) { ret = led_classdev_register(&priv->pci_dev->dev, &priv->led);
priv->last_blink_time = 0; if (ret) {
if (priv->last_blink_rate != IWL_SOLID_BLINK_IDX) { kfree(priv->led.name);
priv->last_blink_rate = IWL_SOLID_BLINK_IDX;
iwl_led_pattern(priv, IWL_SOLID_BLINK_IDX);
}
return; return;
} }
if (!priv->last_blink_time ||
!time_after(jiffies, priv->last_blink_time +
msecs_to_jiffies(1000)))
return;
blink_idx = iwl_get_blink_rate(priv);
/* call only if blink rate change */ priv->led_registered = true;
if (blink_idx != priv->last_blink_rate)
iwl_led_pattern(priv, blink_idx);
priv->last_blink_time = jiffies;
priv->last_blink_rate = blink_idx;
} }
EXPORT_SYMBOL(iwl_leds_background); EXPORT_SYMBOL(iwl_leds_init);
void iwl_leds_init(struct iwl_priv *priv) void iwl_leds_exit(struct iwl_priv *priv)
{ {
priv->last_blink_rate = 0; if (!priv->led_registered)
priv->last_blink_time = 0; return;
priv->allow_blinking = 0;
if (led_mode != IWL_LED_DEFAULT && led_classdev_unregister(&priv->led);
led_mode != priv->cfg->led_mode) kfree(priv->led.name);
priv->cfg->led_mode = led_mode;
} }
EXPORT_SYMBOL(iwl_leds_init); EXPORT_SYMBOL(iwl_leds_exit);
...@@ -31,23 +31,14 @@ ...@@ -31,23 +31,14 @@
struct iwl_priv; struct iwl_priv;
#define IWL_LED_SOLID 11 #define IWL_LED_SOLID 11
#define IWL_LED_NAME_LEN 31
#define IWL_DEF_LED_INTRVL cpu_to_le32(1000) #define IWL_DEF_LED_INTRVL cpu_to_le32(1000)
#define IWL_LED_ACTIVITY (0<<1) #define IWL_LED_ACTIVITY (0<<1)
#define IWL_LED_LINK (1<<1) #define IWL_LED_LINK (1<<1)
enum led_type {
IWL_LED_TRG_TX,
IWL_LED_TRG_RX,
IWL_LED_TRG_ASSOC,
IWL_LED_TRG_RADIO,
IWL_LED_TRG_MAX,
};
/* /*
* LED mode * LED mode
* IWL_LED_DEFAULT: use system default * IWL_LED_DEFAULT: use device default
* IWL_LED_RF_STATE: turn LED on/off based on RF state * IWL_LED_RF_STATE: turn LED on/off based on RF state
* LED ON = RF ON * LED ON = RF ON
* LED OFF = RF OFF * LED OFF = RF OFF
...@@ -60,9 +51,6 @@ enum iwl_led_mode { ...@@ -60,9 +51,6 @@ enum iwl_led_mode {
}; };
void iwl_leds_init(struct iwl_priv *priv); void iwl_leds_init(struct iwl_priv *priv);
void iwl_leds_background(struct iwl_priv *priv); void iwl_leds_exit(struct iwl_priv *priv);
int iwl_led_start(struct iwl_priv *priv);
int iwl_led_associate(struct iwl_priv *priv);
int iwl_led_disassociate(struct iwl_priv *priv);
#endif /* __iwl_leds_h__ */ #endif /* __iwl_leds_h__ */
...@@ -332,7 +332,6 @@ static inline void iwl_set_no_assoc(struct iwl_priv *priv, ...@@ -332,7 +332,6 @@ static inline void iwl_set_no_assoc(struct iwl_priv *priv,
{ {
struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
iwl_led_disassociate(priv);
/* /*
* inform the ucode that there is no longer an * inform the ucode that there is no longer an
* association and that no more packets should be * association and that no more packets should be
...@@ -520,8 +519,6 @@ void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, ...@@ -520,8 +519,6 @@ void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw,
if (bss_conf->assoc) { if (bss_conf->assoc) {
priv->timestamp = bss_conf->timestamp; priv->timestamp = bss_conf->timestamp;
iwl_led_associate(priv);
if (!iwl_is_rfkill(priv)) if (!iwl_is_rfkill(priv))
priv->cfg->ops->legacy->post_associate(priv); priv->cfg->ops->legacy->post_associate(priv);
} else } else
...@@ -545,7 +542,6 @@ void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, ...@@ -545,7 +542,6 @@ void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw,
memcpy(ctx->staging.bssid_addr, memcpy(ctx->staging.bssid_addr,
bss_conf->bssid, ETH_ALEN); bss_conf->bssid, ETH_ALEN);
memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN); memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN);
iwl_led_associate(priv);
priv->cfg->ops->legacy->config_ap(priv); priv->cfg->ops->legacy->config_ap(priv);
} else } else
iwl_set_no_assoc(priv, vif); iwl_set_no_assoc(priv, vif);
......
...@@ -2540,8 +2540,6 @@ static void iwl3945_alive_start(struct iwl_priv *priv) ...@@ -2540,8 +2540,6 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
iwl3945_reg_txpower_periodic(priv); iwl3945_reg_txpower_periodic(priv);
iwl_leds_init(priv);
IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n"); IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n");
set_bit(STATUS_READY, &priv->status); set_bit(STATUS_READY, &priv->status);
wake_up_interruptible(&priv->wait_command_queue); wake_up_interruptible(&priv->wait_command_queue);
...@@ -3170,8 +3168,6 @@ static int iwl3945_mac_start(struct ieee80211_hw *hw) ...@@ -3170,8 +3168,6 @@ static int iwl3945_mac_start(struct ieee80211_hw *hw)
* no need to poll the killswitch state anymore */ * no need to poll the killswitch state anymore */
cancel_delayed_work(&priv->_3945.rfkill_poll); cancel_delayed_work(&priv->_3945.rfkill_poll);
iwl_led_start(priv);
priv->is_open = 1; priv->is_open = 1;
IWL_DEBUG_MAC80211(priv, "leave\n"); IWL_DEBUG_MAC80211(priv, "leave\n");
return 0; return 0;
...@@ -3935,6 +3931,8 @@ static int iwl3945_setup_mac(struct iwl_priv *priv) ...@@ -3935,6 +3931,8 @@ static int iwl3945_setup_mac(struct iwl_priv *priv)
priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
&priv->bands[IEEE80211_BAND_5GHZ]; &priv->bands[IEEE80211_BAND_5GHZ];
iwl_leds_init(priv);
ret = ieee80211_register_hw(priv->hw); ret = ieee80211_register_hw(priv->hw);
if (ret) { if (ret) {
IWL_ERR(priv, "Failed to register hw (error %d)\n", ret); IWL_ERR(priv, "Failed to register hw (error %d)\n", ret);
...@@ -4194,6 +4192,8 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev) ...@@ -4194,6 +4192,8 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev)
set_bit(STATUS_EXIT_PENDING, &priv->status); set_bit(STATUS_EXIT_PENDING, &priv->status);
iwl_leds_exit(priv);
if (priv->mac80211_registered) { if (priv->mac80211_registered) {
ieee80211_unregister_hw(priv->hw); ieee80211_unregister_hw(priv->hw);
priv->mac80211_registered = 0; priv->mac80211_registered = 0;
......
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