led.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright 2006, Johannes Berg <johannes@sipsolutions.net>
  4. */
  5. #include <linux/list.h>
  6. #include <linux/spinlock.h>
  7. #include <linux/leds.h>
  8. #include "ieee80211_i.h"
  9. #define MAC80211_BLINK_DELAY 50 /* ms */
  10. static inline void ieee80211_led_rx(struct ieee80211_local *local)
  11. {
  12. #ifdef CONFIG_MAC80211_LEDS
  13. unsigned long led_delay = MAC80211_BLINK_DELAY;
  14. if (!atomic_read(&local->rx_led_active))
  15. return;
  16. led_trigger_blink_oneshot(&local->rx_led, &led_delay, &led_delay, 0);
  17. #endif
  18. }
  19. static inline void ieee80211_led_tx(struct ieee80211_local *local)
  20. {
  21. #ifdef CONFIG_MAC80211_LEDS
  22. unsigned long led_delay = MAC80211_BLINK_DELAY;
  23. if (!atomic_read(&local->tx_led_active))
  24. return;
  25. led_trigger_blink_oneshot(&local->tx_led, &led_delay, &led_delay, 0);
  26. #endif
  27. }
  28. #ifdef CONFIG_MAC80211_LEDS
  29. void ieee80211_led_assoc(struct ieee80211_local *local,
  30. bool associated);
  31. void ieee80211_led_radio(struct ieee80211_local *local,
  32. bool enabled);
  33. void ieee80211_alloc_led_names(struct ieee80211_local *local);
  34. void ieee80211_free_led_names(struct ieee80211_local *local);
  35. void ieee80211_led_init(struct ieee80211_local *local);
  36. void ieee80211_led_exit(struct ieee80211_local *local);
  37. void ieee80211_mod_tpt_led_trig(struct ieee80211_local *local,
  38. unsigned int types_on, unsigned int types_off);
  39. #else
  40. static inline void ieee80211_led_assoc(struct ieee80211_local *local,
  41. bool associated)
  42. {
  43. }
  44. static inline void ieee80211_led_radio(struct ieee80211_local *local,
  45. bool enabled)
  46. {
  47. }
  48. static inline void ieee80211_alloc_led_names(struct ieee80211_local *local)
  49. {
  50. }
  51. static inline void ieee80211_free_led_names(struct ieee80211_local *local)
  52. {
  53. }
  54. static inline void ieee80211_led_init(struct ieee80211_local *local)
  55. {
  56. }
  57. static inline void ieee80211_led_exit(struct ieee80211_local *local)
  58. {
  59. }
  60. static inline void ieee80211_mod_tpt_led_trig(struct ieee80211_local *local,
  61. unsigned int types_on,
  62. unsigned int types_off)
  63. {
  64. }
  65. #endif
  66. static inline void
  67. ieee80211_tpt_led_trig_tx(struct ieee80211_local *local, __le16 fc, int bytes)
  68. {
  69. #ifdef CONFIG_MAC80211_LEDS
  70. if (ieee80211_is_data(fc) && atomic_read(&local->tpt_led_active))
  71. local->tpt_led_trigger->tx_bytes += bytes;
  72. #endif
  73. }
  74. static inline void
  75. ieee80211_tpt_led_trig_rx(struct ieee80211_local *local, __le16 fc, int bytes)
  76. {
  77. #ifdef CONFIG_MAC80211_LEDS
  78. if (ieee80211_is_data(fc) && atomic_read(&local->tpt_led_active))
  79. local->tpt_led_trigger->rx_bytes += bytes;
  80. #endif
  81. }