Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 150440
b: refs/heads/master
c: 749e091
h: refs/heads/master
v: v3
  • Loading branch information
Abhijeet Kolekar authored and John W. Linville committed May 22, 2009
1 parent 38628cd commit a57722d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2c7e57981f24e9f8b732ecf1c01e16111d21b7a5
refs/heads/master: 749e091ee0065ed366cc26c115abc237e07ed786
70 changes: 46 additions & 24 deletions trunk/drivers/net/wireless/iwlwifi/iwl-3945-led.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
#include "iwl-core.h"
#include "iwl-dev.h"

#ifdef CONFIG_IWLWIFI_DEBUG
static const char *led_type_str[] = {
__stringify(IWL_LED_TRG_TX),
__stringify(IWL_LED_TRG_RX),
__stringify(IWL_LED_TRG_ASSOC),
__stringify(IWL_LED_TRG_RADIO),
NULL
};
#endif /* CONFIG_IWLWIFI_DEBUG */

static const struct {
u16 brightness;
Expand All @@ -61,7 +70,7 @@ static const struct {
{10, 110, 110},
{5, 130, 130},
{0, 167, 167},
/*SOLID_ON*/
/* SOLID_ON */
{-1, IWL_LED_SOLID, 0}
};

Expand Down Expand Up @@ -142,6 +151,30 @@ static int iwl3945_led_off(struct iwl_priv *priv, int led_id)
return iwl_send_led_cmd(priv, &led_cmd);
}

/*
* Set led on in case of association
* */
static int iwl3945_led_associate(struct iwl_priv *priv, int led_id)
{
IWL_DEBUG_LED(priv, "Associated\n");

priv->allow_blinking = 1;
return iwl3945_led_on(priv, led_id);
}
/* Set Led off in case of disassociation */
static int iwl3945_led_disassociate(struct iwl_priv *priv, int led_id)
{
IWL_DEBUG_LED(priv, "Disassociated\n");

priv->allow_blinking = 0;
if (iwl_is_rfkill(priv))
iwl3945_led_off(priv, led_id);
else
iwl3945_led_on(priv, led_id);

return 0;
}

/*
* brightness call back function for Tx/Rx LED
*/
Expand All @@ -165,26 +198,21 @@ static void iwl3945_led_brightness_set(struct led_classdev *led_cdev,
enum led_brightness brightness)
{
struct iwl_led *led = container_of(led_cdev,
struct iwl_led, led_dev);
struct iwl_led, led_dev);
struct iwl_priv *priv = led->priv;

if (test_bit(STATUS_EXIT_PENDING, &priv->status))
return;

IWL_DEBUG_LED(priv, "Led type = %s brightness = %d\n",
led_type_str[led->type], brightness);

switch (brightness) {
case LED_FULL:
if (led->type == IWL_LED_TRG_ASSOC) {
priv->allow_blinking = 1;
IWL_DEBUG_LED(priv, "MAC is associated\n");
}
if (led->led_on)
led->led_on(priv, IWL_LED_LINK);
break;
case LED_OFF:
if (led->type == IWL_LED_TRG_ASSOC) {
priv->allow_blinking = 0;
IWL_DEBUG_LED(priv, "MAC is disassociated\n");
}
if (led->led_off)
led->led_off(priv, IWL_LED_LINK);
break;
Expand All @@ -197,8 +225,6 @@ static void iwl3945_led_brightness_set(struct led_classdev *led_cdev,
}
}



/*
* Register led class with the system
*/
Expand Down Expand Up @@ -237,26 +263,22 @@ static int iwl3945_led_register_led(struct iwl_priv *priv,
static inline u8 get_blink_rate(struct iwl_priv *priv)
{
int index;
u64 current_tpt = priv->rxtxpackets;
s64 tpt = current_tpt - priv->led_tpt;
s64 tpt = priv->rxtxpackets;

if (tpt < 0)
tpt = -tpt;
priv->led_tpt = current_tpt;

IWL_DEBUG_LED(priv, "tpt %lld \n", (long long)tpt);

if (!priv->allow_blinking)
index = IWL_MAX_BLINK_TBL;
else
for (index = 0; index < IWL_MAX_BLINK_TBL; index++)
if (tpt > (blink_tbl[index].brightness * IWL_1MB_RATE))
break;
return index;
}

static inline int is_rf_kill(struct iwl_priv *priv)
{
return test_bit(STATUS_RF_KILL_HW, &priv->status) ||
test_bit(STATUS_RF_KILL_SW, &priv->status);
IWL_DEBUG_LED(priv, "LED BLINK IDX=%d\n", index);
return index;
}

/*
Expand All @@ -272,7 +294,7 @@ void iwl3945_led_background(struct iwl_priv *priv)
priv->last_blink_time = 0;
return;
}
if (is_rf_kill(priv)) {
if (iwl_is_rfkill(priv)) {
priv->last_blink_time = 0;
return;
}
Expand Down Expand Up @@ -341,8 +363,8 @@ int iwl3945_led_register(struct iwl_priv *priv)
IWL_LED_TRG_ASSOC, 0, trigger);

/* for assoc always turn led on */
priv->led[IWL_LED_TRG_ASSOC].led_on = iwl3945_led_on;
priv->led[IWL_LED_TRG_ASSOC].led_off = iwl3945_led_on;
priv->led[IWL_LED_TRG_ASSOC].led_on = iwl3945_led_associate;
priv->led[IWL_LED_TRG_ASSOC].led_off = iwl3945_led_disassociate;
priv->led[IWL_LED_TRG_ASSOC].led_pattern = NULL;

if (ret)
Expand Down

0 comments on commit a57722d

Please sign in to comment.