mac80211: backport brcmfmac data structure rework
[openwrt/staging/wigyori.git] / package / kernel / mac80211 / patches / 548-ath9k_enable_gpio_chip.patch
index 2a1cfffc14f89a27f550f234a58f902a970df7ae..31dac29ad77b89626d300d9a82ba3bd2cc2210a1 100644 (file)
@@ -18,7 +18,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  
  #include "common.h"
  #include "debug.h"
-@@ -960,6 +961,14 @@ struct ath_led {
+@@ -1001,6 +1002,14 @@ struct ath_led {
        struct led_classdev cdev;
  };
  
@@ -33,7 +33,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  struct ath_softc {
        struct ieee80211_hw *hw;
        struct device *dev;
-@@ -1014,6 +1023,9 @@ struct ath_softc {
+@@ -1058,6 +1067,9 @@ struct ath_softc {
  #ifdef CPTCFG_MAC80211_LEDS
        const char *led_default_trigger;
        struct list_head leds;
@@ -123,6 +123,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
 +      if (!gc)
 +              return;
 +
++      gc->sc = sc;
 +      snprintf(gc->label, sizeof(gc->label), "ath9k-%s",
 +               wiphy_name(sc->hw->wiphy));
 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0)
@@ -138,15 +139,14 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
 +      gc->gchip.get_direction = ath9k_gpio_pin_get_dir;
 +      gc->gchip.get = ath9k_gpio_pin_get;
 +      gc->gchip.set = ath9k_gpio_pin_set;
-+      gc->gchip.owner = THIS_MODULE;
 +
 +      if (gpiochip_add(&gc->gchip)) {
 +              kfree(gc);
 +              return;
 +      }
 +
++      gc->gchip.owner = NULL;
 +      sc->gpiochip = gc;
-+      gc->sc = sc;
 +}
 +
 +/* remove GPIO chip */
@@ -196,7 +196,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        return 0;
  }
  
-@@ -136,12 +264,18 @@ void ath_deinit_leds(struct ath_softc *s
+@@ -136,17 +264,24 @@ void ath_deinit_leds(struct ath_softc *s
  
        while (!list_empty(&sc->leds)) {
                led = list_first_entry(&sc->leds, struct ath_led, list);
@@ -215,18 +215,31 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  }
  
  void ath_init_leds(struct ath_softc *sc)
-@@ -158,6 +292,8 @@ void ath_init_leds(struct ath_softc *sc)
+ {
+       struct ath9k_platform_data *pdata = sc->dev->platform_data;
++      struct device_node *np = sc->dev->of_node;
+       char led_name[32];
+       const char *trigger;
+       int i;
+@@ -156,6 +291,15 @@ void ath_init_leds(struct ath_softc *sc)
+       if (AR_SREV_9100(sc->sc_ah))
+               return;
  
++      if (!np)
++              ath9k_register_gpio_chip(sc);
++
++      /* setup gpio controller only if requested and skip the led_pin setup */
++      if (of_property_read_bool(np, "gpio-controller")) {
++              ath9k_register_gpio_chip(sc);
++              return;
++      }
++
        ath_fill_led_pin(sc);
  
-+      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)
+@@ -180,6 +324,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