v1.5 branch refresh based upon upstream master @ c8677ca89e53e3be7988d54280fce166cc894a7e
[librecmc/librecmc.git] / package / kernel / mac80211 / patches / 531-ath9k_extra_platform_leds.patch
1 --- a/include/linux/ath9k_platform.h
2 +++ b/include/linux/ath9k_platform.h
3 @@ -46,6 +46,9 @@ struct ath9k_platform_data {
4         int (*external_reset)(void);
5  
6         bool use_eeprom;
7 +
8 +       int num_leds;
9 +       const struct gpio_led *leds;
10  };
11  
12  #endif /* _LINUX_ATH9K_PLATFORM_H */
13 --- a/drivers/net/wireless/ath/ath9k/gpio.c
14 +++ b/drivers/net/wireless/ath/ath9k/gpio.c
15 @@ -15,6 +15,7 @@
16   */
17  
18  #include "ath9k.h"
19 +#include <linux/ath9k_platform.h>
20  
21  /********************************/
22  /*      LED functions          */
23 @@ -108,6 +109,24 @@ int ath_create_gpio_led(struct ath_softc
24         return ret;
25  }
26  
27 +static int ath_create_platform_led(struct ath_softc *sc,
28 +                                  const struct gpio_led *gpio)
29 +{
30 +       struct ath_led *led;
31 +       int ret;
32 +
33 +       led = kzalloc(sizeof(*led), GFP_KERNEL);
34 +       if (!led)
35 +               return -ENOMEM;
36 +
37 +       led->gpio = gpio;
38 +       ret = ath_add_led(sc, led);
39 +       if (ret < 0)
40 +               kfree(led);
41 +
42 +       return ret;
43 +}
44 +
45  void ath_deinit_leds(struct ath_softc *sc)
46  {
47         struct ath_led *led;
48 @@ -124,8 +143,10 @@ void ath_deinit_leds(struct ath_softc *s
49  
50  void ath_init_leds(struct ath_softc *sc)
51  {
52 +       struct ath9k_platform_data *pdata = sc->dev->platform_data;
53         char led_name[32];
54         const char *trigger;
55 +       int i;
56  
57         INIT_LIST_HEAD(&sc->leds);
58  
59 @@ -134,6 +155,17 @@ void ath_init_leds(struct ath_softc *sc)
60  
61         ath_fill_led_pin(sc);
62  
63 +       if (pdata && pdata->leds && pdata->num_leds)
64 +               for (i = 0; i < pdata->num_leds; i++) {
65 +                       if (pdata->leds[i].gpio == sc->sc_ah->led_pin)
66 +                               sc->sc_ah->led_pin = -1;
67 +
68 +                       ath_create_platform_led(sc, &pdata->leds[i]);
69 +               }
70 +
71 +       if (sc->sc_ah->led_pin < 0)
72 +               return;
73 +
74         snprintf(led_name, sizeof(led_name), "ath9k-%s",
75                  wiphy_name(sc->hw->wiphy));
76