ac8ee533d92a22bc5e69da9c7347298b48ff5b21
[openwrt/staging/mkresin.git] / package / mac80211 / patches / 552-ath9k_extra_platform_leds.patch
1 --- a/include/linux/ath9k_platform.h
2 +++ b/include/linux/ath9k_platform.h
3 @@ -33,6 +33,9 @@ struct ath9k_platform_data {
4 bool is_clk_25mhz;
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 @@ -14,6 +14,7 @@
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 +#include <linux/ath9k_platform.h>
20 #include "ath9k.h"
21
22 /********************************/
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 @@ -133,6 +154,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 #endif
71