led.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. if (!atomic_read(&local->rx_led_active))
  14. return;
  15. led_trigger_blink_oneshot(&local->rx_led, MAC80211_BLINK_DELAY, MAC80211_BLINK_DELAY, 0);
  16. #endif
  17. }
  18. static inline void ieee80211_led_tx(struct ieee80211_local *local)
  19. {
  20. #ifdef CONFIG_MAC80211_LEDS
  21. if (!atomic_read(&local->tx_led_active))
  22. return;
  23. led_trigger_blink_oneshot(&local->tx_led, MAC80211_BLINK_DELAY, MAC80211_BLINK_DELAY, 0);
  24. #endif
  25. }
  26. #ifdef CONFIG_MAC80211_LEDS
  27. void ieee80211_led_assoc(struct ieee80211_local *local,
  28. bool associated);
  29. void ieee80211_led_radio(struct ieee80211_local *local,
  30. bool enabled);
  31. void ieee80211_alloc_led_names(struct ieee80211_local *local);
  32. void ieee80211_free_led_names(struct ieee80211_local *local);
  33. void ieee80211_led_init(struct ieee80211_local *local);
  34. void ieee80211_led_exit(struct ieee80211_local *local);
  35. void ieee80211_mod_tpt_led_trig(struct ieee80211_local *local,
  36. unsigned int types_on, unsigned int types_off);
  37. #else
  38. static inline void ieee80211_led_assoc(struct ieee80211_local *local,
  39. bool associated)
  40. {
  41. }
  42. static inline void ieee80211_led_radio(struct ieee80211_local *local,
  43. bool enabled)
  44. {
  45. }
  46. static inline void ieee80211_alloc_led_names(struct ieee80211_local *local)
  47. {
  48. }
  49. static inline void ieee80211_free_led_names(struct ieee80211_local *local)
  50. {
  51. }
  52. static inline void ieee80211_led_init(struct ieee80211_local *local)
  53. {
  54. }
  55. static inline void ieee80211_led_exit(struct ieee80211_local *local)
  56. {
  57. }
  58. static inline void ieee80211_mod_tpt_led_trig(struct ieee80211_local *local,
  59. unsigned int types_on,
  60. unsigned int types_off)
  61. {
  62. }
  63. #endif
  64. static inline void
  65. ieee80211_tpt_led_trig_tx(struct ieee80211_local *local, int bytes)
  66. {
  67. #ifdef CONFIG_MAC80211_LEDS
  68. if (atomic_read(&local->tpt_led_active))
  69. local->tpt_led_trigger->tx_bytes += bytes;
  70. #endif
  71. }
  72. static inline void
  73. ieee80211_tpt_led_trig_rx(struct ieee80211_local *local, int bytes)
  74. {
  75. #ifdef CONFIG_MAC80211_LEDS
  76. if (atomic_read(&local->tpt_led_active))
  77. local->tpt_led_trigger->rx_bytes += bytes;
  78. #endif
  79. }