led.h 2.6 KB

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