610-rt2x00-change-led-polarity-from-OF.patch 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  2. +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  3. @@ -36,6 +36,7 @@
  4. #include <linux/kernel.h>
  5. #include <linux/module.h>
  6. #include <linux/slab.h>
  7. +#include <linux/of.h>
  8. #include "rt2x00.h"
  9. #include "rt2800lib.h"
  10. @@ -7861,6 +7862,17 @@ static int rt2800_init_eeprom(struct rt2
  11. rt2800_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC);
  12. rt2800_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY);
  13. + {
  14. + struct device_node *np = rt2x00dev->dev->of_node;
  15. + unsigned int led_polarity;
  16. +
  17. + /* Allow overriding polarity from OF */
  18. + if (!of_property_read_u32(np, "ralink,led-polarity",
  19. + &led_polarity))
  20. + rt2x00_set_field16(&eeprom, EEPROM_FREQ_LED_POLARITY,
  21. + led_polarity);
  22. + }
  23. +
  24. rt2x00dev->led_mcu_reg = eeprom;
  25. #endif /* CPTCFG_RT2X00_LIB_LEDS */
  26. --- a/drivers/net/wireless/ralink/rt2x00/rt2x00leds.c
  27. +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00leds.c
  28. @@ -109,6 +109,9 @@ static int rt2x00leds_register_led(struc
  29. led->led_dev.name = name;
  30. led->led_dev.brightness = LED_OFF;
  31. + if (rt2x00_is_soc(rt2x00dev))
  32. + led->led_dev.brightness_set(&led->led_dev, LED_OFF);
  33. +
  34. retval = led_classdev_register(device, &led->led_dev);
  35. if (retval) {
  36. rt2x00_err(rt2x00dev, "Failed to register led handler\n");