1
0

531-ath9k_extra_platform_leds.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. bool use_eeprom;
  6. +
  7. + int num_leds;
  8. + const struct gpio_led *leds;
  9. };
  10. #endif /* _LINUX_ATH9K_PLATFORM_H */
  11. --- a/drivers/net/wireless/ath/ath9k/gpio.c
  12. +++ b/drivers/net/wireless/ath/ath9k/gpio.c
  13. @@ -15,6 +15,7 @@
  14. */
  15. #include "ath9k.h"
  16. +#include <linux/ath9k_platform.h>
  17. /********************************/
  18. /* LED functions */
  19. @@ -108,6 +109,24 @@ int ath_create_gpio_led(struct ath_softc
  20. return ret;
  21. }
  22. +static int ath_create_platform_led(struct ath_softc *sc,
  23. + const struct gpio_led *gpio)
  24. +{
  25. + struct ath_led *led;
  26. + int ret;
  27. +
  28. + led = kzalloc(sizeof(*led), GFP_KERNEL);
  29. + if (!led)
  30. + return -ENOMEM;
  31. +
  32. + led->gpio = gpio;
  33. + ret = ath_add_led(sc, led);
  34. + if (ret < 0)
  35. + kfree(led);
  36. +
  37. + return ret;
  38. +}
  39. +
  40. void ath_deinit_leds(struct ath_softc *sc)
  41. {
  42. struct ath_led *led;
  43. @@ -124,8 +143,10 @@ void ath_deinit_leds(struct ath_softc *s
  44. void ath_init_leds(struct ath_softc *sc)
  45. {
  46. + struct ath9k_platform_data *pdata = sc->dev->platform_data;
  47. char led_name[32];
  48. const char *trigger;
  49. + int i;
  50. INIT_LIST_HEAD(&sc->leds);
  51. @@ -144,6 +165,12 @@ void ath_init_leds(struct ath_softc *sc)
  52. ath_create_gpio_led(sc, sc->sc_ah->led_pin, led_name, trigger,
  53. !sc->sc_ah->config.led_active_high);
  54. +
  55. + if (!pdata)
  56. + return;
  57. +
  58. + for (i = 0; i < pdata->num_leds; i++)
  59. + ath_create_platform_led(sc, &pdata->leds[i]);
  60. }
  61. #endif