mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 10:57:46 +00:00
rtl8187: add radio led and fix warnings on suspend
Michael Buesch reports that his rtl8187 gives warnings on suspend ("queueing ieee80211 work while going to suspend" warnings), as rtl8187 can call ieee80211_queue_delayed_work after mac80211 is suspended. This change enhances rtl8187 led code so we can avoid queuing work after mac80211 is suspended: now we register a radio led and make additional checks to ensure led is off/on properly as mac80211 wants. Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br> Tested-by: Larry Finger <Larry.Finger@lwfinger.net> Cc: Stable <stable@vger.kernel.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
parent
512414b0be
commit
49d7590ce4
3 changed files with 50 additions and 21 deletions
|
@ -108,6 +108,7 @@ struct rtl8187_priv {
|
||||||
struct delayed_work work;
|
struct delayed_work work;
|
||||||
struct ieee80211_hw *dev;
|
struct ieee80211_hw *dev;
|
||||||
#ifdef CONFIG_RTL8187_LEDS
|
#ifdef CONFIG_RTL8187_LEDS
|
||||||
|
struct rtl8187_led led_radio;
|
||||||
struct rtl8187_led led_tx;
|
struct rtl8187_led led_tx;
|
||||||
struct rtl8187_led led_rx;
|
struct rtl8187_led led_rx;
|
||||||
struct delayed_work led_on;
|
struct delayed_work led_on;
|
||||||
|
|
|
@ -105,19 +105,36 @@ static void rtl8187_led_brightness_set(struct led_classdev *led_dev,
|
||||||
struct rtl8187_led *led = container_of(led_dev, struct rtl8187_led,
|
struct rtl8187_led *led = container_of(led_dev, struct rtl8187_led,
|
||||||
led_dev);
|
led_dev);
|
||||||
struct ieee80211_hw *hw = led->dev;
|
struct ieee80211_hw *hw = led->dev;
|
||||||
struct rtl8187_priv *priv = hw->priv;
|
struct rtl8187_priv *priv;
|
||||||
|
static bool radio_on;
|
||||||
|
|
||||||
if (brightness == LED_OFF) {
|
if (!hw)
|
||||||
ieee80211_queue_delayed_work(hw, &priv->led_off, 0);
|
return;
|
||||||
/* The LED is off for 1/20 sec so that it just blinks. */
|
priv = hw->priv;
|
||||||
ieee80211_queue_delayed_work(hw, &priv->led_on, HZ / 20);
|
if (led->is_radio) {
|
||||||
} else
|
if (brightness == LED_FULL) {
|
||||||
ieee80211_queue_delayed_work(hw, &priv->led_on, 0);
|
ieee80211_queue_delayed_work(hw, &priv->led_on, 0);
|
||||||
|
radio_on = true;
|
||||||
|
} else if (radio_on) {
|
||||||
|
radio_on = false;
|
||||||
|
cancel_delayed_work_sync(&priv->led_on);
|
||||||
|
ieee80211_queue_delayed_work(hw, &priv->led_off, 0);
|
||||||
|
}
|
||||||
|
} else if (radio_on) {
|
||||||
|
if (brightness == LED_OFF) {
|
||||||
|
ieee80211_queue_delayed_work(hw, &priv->led_off, 0);
|
||||||
|
/* The LED is off for 1/20 sec - it just blinks. */
|
||||||
|
ieee80211_queue_delayed_work(hw, &priv->led_on,
|
||||||
|
HZ / 20);
|
||||||
|
} else
|
||||||
|
ieee80211_queue_delayed_work(hw, &priv->led_on, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rtl8187_register_led(struct ieee80211_hw *dev,
|
static int rtl8187_register_led(struct ieee80211_hw *dev,
|
||||||
struct rtl8187_led *led, const char *name,
|
struct rtl8187_led *led, const char *name,
|
||||||
const char *default_trigger, u8 ledpin)
|
const char *default_trigger, u8 ledpin,
|
||||||
|
bool is_radio)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
struct rtl8187_priv *priv = dev->priv;
|
struct rtl8187_priv *priv = dev->priv;
|
||||||
|
@ -128,6 +145,7 @@ static int rtl8187_register_led(struct ieee80211_hw *dev,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
led->dev = dev;
|
led->dev = dev;
|
||||||
led->ledpin = ledpin;
|
led->ledpin = ledpin;
|
||||||
|
led->is_radio = is_radio;
|
||||||
strncpy(led->name, name, sizeof(led->name));
|
strncpy(led->name, name, sizeof(led->name));
|
||||||
|
|
||||||
led->led_dev.name = led->name;
|
led->led_dev.name = led->name;
|
||||||
|
@ -145,7 +163,11 @@ static int rtl8187_register_led(struct ieee80211_hw *dev,
|
||||||
|
|
||||||
static void rtl8187_unregister_led(struct rtl8187_led *led)
|
static void rtl8187_unregister_led(struct rtl8187_led *led)
|
||||||
{
|
{
|
||||||
|
struct ieee80211_hw *hw = led->dev;
|
||||||
|
struct rtl8187_priv *priv = hw->priv;
|
||||||
|
|
||||||
led_classdev_unregister(&led->led_dev);
|
led_classdev_unregister(&led->led_dev);
|
||||||
|
flush_delayed_work(&priv->led_off);
|
||||||
led->dev = NULL;
|
led->dev = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,34 +204,38 @@ void rtl8187_leds_init(struct ieee80211_hw *dev, u16 custid)
|
||||||
INIT_DELAYED_WORK(&priv->led_on, led_turn_on);
|
INIT_DELAYED_WORK(&priv->led_on, led_turn_on);
|
||||||
INIT_DELAYED_WORK(&priv->led_off, led_turn_off);
|
INIT_DELAYED_WORK(&priv->led_off, led_turn_off);
|
||||||
|
|
||||||
|
snprintf(name, sizeof(name),
|
||||||
|
"rtl8187-%s::radio", wiphy_name(dev->wiphy));
|
||||||
|
err = rtl8187_register_led(dev, &priv->led_radio, name,
|
||||||
|
ieee80211_get_radio_led_name(dev), ledpin, true);
|
||||||
|
if (err)
|
||||||
|
return;
|
||||||
|
|
||||||
snprintf(name, sizeof(name),
|
snprintf(name, sizeof(name),
|
||||||
"rtl8187-%s::tx", wiphy_name(dev->wiphy));
|
"rtl8187-%s::tx", wiphy_name(dev->wiphy));
|
||||||
err = rtl8187_register_led(dev, &priv->led_tx, name,
|
err = rtl8187_register_led(dev, &priv->led_tx, name,
|
||||||
ieee80211_get_tx_led_name(dev), ledpin);
|
ieee80211_get_tx_led_name(dev), ledpin, false);
|
||||||
if (err)
|
if (err)
|
||||||
goto error;
|
goto err_tx;
|
||||||
|
|
||||||
snprintf(name, sizeof(name),
|
snprintf(name, sizeof(name),
|
||||||
"rtl8187-%s::rx", wiphy_name(dev->wiphy));
|
"rtl8187-%s::rx", wiphy_name(dev->wiphy));
|
||||||
err = rtl8187_register_led(dev, &priv->led_rx, name,
|
err = rtl8187_register_led(dev, &priv->led_rx, name,
|
||||||
ieee80211_get_rx_led_name(dev), ledpin);
|
ieee80211_get_rx_led_name(dev), ledpin, false);
|
||||||
if (!err) {
|
if (!err)
|
||||||
ieee80211_queue_delayed_work(dev, &priv->led_on, 0);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
/* registration of RX LED failed - unregister TX */
|
/* registration of RX LED failed - unregister */
|
||||||
rtl8187_unregister_led(&priv->led_tx);
|
rtl8187_unregister_led(&priv->led_tx);
|
||||||
error:
|
err_tx:
|
||||||
/* If registration of either failed, cancel delayed work */
|
rtl8187_unregister_led(&priv->led_radio);
|
||||||
cancel_delayed_work_sync(&priv->led_off);
|
|
||||||
cancel_delayed_work_sync(&priv->led_on);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rtl8187_leds_exit(struct ieee80211_hw *dev)
|
void rtl8187_leds_exit(struct ieee80211_hw *dev)
|
||||||
{
|
{
|
||||||
struct rtl8187_priv *priv = dev->priv;
|
struct rtl8187_priv *priv = dev->priv;
|
||||||
|
|
||||||
/* turn the LED off before exiting */
|
rtl8187_unregister_led(&priv->led_radio);
|
||||||
ieee80211_queue_delayed_work(dev, &priv->led_off, 0);
|
|
||||||
rtl8187_unregister_led(&priv->led_rx);
|
rtl8187_unregister_led(&priv->led_rx);
|
||||||
rtl8187_unregister_led(&priv->led_tx);
|
rtl8187_unregister_led(&priv->led_tx);
|
||||||
cancel_delayed_work_sync(&priv->led_off);
|
cancel_delayed_work_sync(&priv->led_off);
|
||||||
|
|
|
@ -47,6 +47,8 @@ struct rtl8187_led {
|
||||||
u8 ledpin;
|
u8 ledpin;
|
||||||
/* The unique name string for this LED device. */
|
/* The unique name string for this LED device. */
|
||||||
char name[RTL8187_LED_MAX_NAME_LEN + 1];
|
char name[RTL8187_LED_MAX_NAME_LEN + 1];
|
||||||
|
/* If the LED is radio or tx/rx */
|
||||||
|
bool is_radio;
|
||||||
};
|
};
|
||||||
|
|
||||||
void rtl8187_leds_init(struct ieee80211_hw *dev, u16 code);
|
void rtl8187_leds_init(struct ieee80211_hw *dev, u16 code);
|
||||||
|
|
Loading…
Reference in a new issue