ath9k: unset the default LED pin if used by platform leds
authorMathias Kresin <dev@kresin.me>
Tue, 21 Mar 2017 22:21:57 +0000 (23:21 +0100)
committerMathias Kresin <dev@kresin.me>
Sat, 8 Apr 2017 12:30:00 +0000 (14:30 +0200)
Unset the default LED gpio pin if the same gpio pin is used by a LED
defined via platform LED. This prevents that the default led trigger
gets assigned to this LED and the GPIO value gets changed on
wifi up/down in case the led is not used for signaling the wifi state.

Signed-off-by: Mathias Kresin <dev@kresin.me>
package/kernel/mac80211/patches/531-ath9k_extra_platform_leds.patch
package/kernel/mac80211/patches/546-ath9k_platform_led_name.patch
package/kernel/mac80211/patches/548-ath9k_enable_gpio_chip.patch
package/kernel/mac80211/patches/549-ath9k_enable_gpio_buttons.patch

index 35d8e8b..8ed7ad8 100644 (file)
  
        INIT_LIST_HEAD(&sc->leds);
  
-@@ -144,6 +165,12 @@ void ath_init_leds(struct ath_softc *sc)
+@@ -134,6 +155,17 @@ void ath_init_leds(struct ath_softc *sc)
  
-       ath_create_gpio_led(sc, sc->sc_ah->led_pin, led_name, trigger,
-                          !sc->sc_ah->config.led_active_high);
+       ath_fill_led_pin(sc);
++      if (pdata && pdata->leds && pdata->num_leds)
++              for (i = 0; i < pdata->num_leds; i++) {
++                      if (pdata->leds[i].gpio == sc->sc_ah->led_pin)
++                              sc->sc_ah->led_pin = -1;
++
++                      ath_create_platform_led(sc, &pdata->leds[i]);
++              }
 +
-+      if (!pdata)
++      if (sc->sc_ah->led_pin < 0)
 +              return;
 +
-+      for (i = 0; i < pdata->num_leds; i++)
-+              ath_create_platform_led(sc, &pdata->leds[i]);
- }
- #endif
+       snprintf(led_name, sizeof(led_name), "ath9k-%s",
+                wiphy_name(sc->hw->wiphy));
  
index ced72c6..ddb3fe6 100644 (file)
@@ -7,15 +7,15 @@ Enable platform-supplied WLAN LED name for ath9k device. It replaces generic
 
 Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
 ---
- drivers/net/wireless/ath/ath9k/gpio.c |   10 +++++++---
- include/linux/ath9k_platform.h        |    1 +
- 2 files changed, 8 insertions(+), 3 deletions(-)
+ drivers/net/wireless/ath/ath9k/gpio.c | 7 +++++--
+ include/linux/ath9k_platform.h        | 1 +
+ 2 files changed, 6 insertions(+), 2 deletions(-)
 
 --- a/drivers/net/wireless/ath/ath9k/gpio.c
 +++ b/drivers/net/wireless/ath/ath9k/gpio.c
-@@ -155,8 +155,11 @@ void ath_init_leds(struct ath_softc *sc)
-       ath_fill_led_pin(sc);
+@@ -166,8 +166,11 @@ void ath_init_leds(struct ath_softc *sc)
+       if (sc->sc_ah->led_pin < 0)
+               return;
  
 -      snprintf(led_name, sizeof(led_name), "ath9k-%s",
 -               wiphy_name(sc->hw->wiphy));
index d426928..4e28abb 100644 (file)
@@ -221,12 +221,12 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  
 +      ath9k_register_gpio_chip(sc);
 +
-       if (pdata && pdata->led_name)
-               strncpy(led_name, pdata->led_name, sizeof(led_name));
-       else
-@@ -178,6 +314,7 @@ void ath_init_leds(struct ath_softc *sc)
-       for (i = 0; i < pdata->num_leds; i++)
-               ath_create_platform_led(sc, &pdata->leds[i]);
+       if (pdata && pdata->leds && pdata->num_leds)
+               for (i = 0; i < pdata->num_leds; i++) {
+                       if (pdata->leds[i].gpio == sc->sc_ah->led_pin)
+@@ -183,6 +319,7 @@ void ath_init_leds(struct ath_softc *sc)
+       ath_create_gpio_led(sc, sc->sc_ah->led_pin, led_name, trigger,
+                          !sc->sc_ah->config.led_active_high);
  }
 +
  #endif
index f40bac9..8aefcf4 100644 (file)
@@ -123,17 +123,8 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        ath9k_register_gpio_chip(sc);
 +      ath9k_init_buttons(sc);
  
-       if (pdata && pdata->led_name)
-               strncpy(led_name, pdata->led_name, sizeof(led_name));
-@@ -308,7 +378,7 @@ void ath_init_leds(struct ath_softc *sc)
-       ath_create_gpio_led(sc, sc->sc_ah->led_pin, led_name, trigger,
-                          !sc->sc_ah->config.led_active_high);
--      if (!pdata)
-+      if (!pdata || !pdata->leds || !pdata->num_leds)
-               return;
-       for (i = 0; i < pdata->num_leds; i++)
+       if (pdata && pdata->leds && pdata->num_leds)
+               for (i = 0; i < pdata->num_leds; i++) {
 --- a/include/linux/ath9k_platform.h
 +++ b/include/linux/ath9k_platform.h
 @@ -50,6 +50,10 @@ struct ath9k_platform_data {