ath9k: improve ANI debugfs file
[openwrt.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 @@ -37,6 +37,9 @@ struct ath9k_platform_data {
4  
5         int (*get_mac_revision)(void);
6         int (*external_reset)(void);
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 @@ -88,6 +89,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 @@ -103,8 +122,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 @@ -120,6 +141,12 @@ void ath_init_leds(struct ath_softc *sc)
60                 trigger = ieee80211_get_radio_led_name(sc->hw);
61  
62         ath_create_gpio_led(sc, sc->sc_ah->led_pin, led_name, trigger, 1);
63 +
64 +       if (!pdata)
65 +               return;
66 +
67 +       for (i = 0; i < pdata->num_leds; i++)
68 +               ath_create_platform_led(sc, &pdata->leds[i]);
69  }
70  
71  void ath_fill_led_pin(struct ath_softc *sc)