qdf_timer.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * Copyright (c) 2014-2016, 2018-2019 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /**
  19. * DOC: qdf_timer
  20. * This file abstracts OS timers running in soft IRQ context.
  21. */
  22. #ifndef _QDF_TIMER_H
  23. #define _QDF_TIMER_H
  24. #include <qdf_types.h>
  25. #include <i_qdf_timer.h>
  26. typedef struct __qdf_timer_t qdf_timer_t;
  27. /**
  28. * qdf_timer_init() - initialize a timer
  29. * @hdl: OS handle
  30. * @timer: Timer object pointer
  31. * @func: Timer function
  32. * @arg: Argument of timer function
  33. * @type: deferrable or non deferrable timer type
  34. *
  35. * Timer type QDF_TIMER_TYPE_SW means its a deferrable sw timer which will
  36. * not cause CPU wake upon expiry
  37. * Timer type QDF_TIMER_TYPE_WAKE_APPS means its a non-deferrable timer which
  38. * will cause CPU wake up on expiry
  39. *
  40. * Return: QDF_STATUS
  41. */
  42. static inline QDF_STATUS
  43. qdf_timer_init(qdf_handle_t hdl, qdf_timer_t *timer, qdf_timer_func_t func,
  44. void *arg, QDF_TIMER_TYPE type)
  45. {
  46. return __qdf_timer_init(timer, func, arg, type);
  47. }
  48. #ifdef QDF_TIMER_MULTIPLIER_FRAC
  49. #define qdf_msecs_to_jiffies(msec) \
  50. (QDF_TIMER_MULTIPLIER_FRAC * __qdf_msecs_to_jiffies(msec))
  51. #else
  52. #define qdf_msecs_to_jiffies(msec) \
  53. (qdf_timer_get_multiplier() * __qdf_msecs_to_jiffies(msec))
  54. #endif
  55. /**
  56. * qdf_timer_start() - start a timer
  57. * @timer: timer to start
  58. * @msec: Expiration period in milliseconds
  59. *
  60. * Return: none
  61. */
  62. static inline void qdf_timer_start(qdf_timer_t *timer, int msec)
  63. {
  64. __qdf_timer_start(timer, msec);
  65. }
  66. /**
  67. * qdf_timer_mod() - modify the timeout on a timer
  68. * @timer: timer to modify
  69. * @msec: Expiration period in milliseconds
  70. *
  71. * If @timer is not active, it will be activated.
  72. *
  73. * Return: none
  74. */
  75. static inline void qdf_timer_mod(qdf_timer_t *timer, int msec)
  76. {
  77. __qdf_timer_mod(timer, msec);
  78. }
  79. /**
  80. * qdf_timer_stop() - cancel a timer
  81. * @timer: timer to cancel
  82. *
  83. * Note! The timer callback may be executing when this function call returns.
  84. * If you want to ensure that it is not, use qdf_timer_sync_cancel() instead.
  85. *
  86. * Return: true if @timer was deactivated, false if @timer was not active
  87. */
  88. static inline bool qdf_timer_stop(qdf_timer_t *timer)
  89. {
  90. return __qdf_timer_stop(timer);
  91. }
  92. /**
  93. * qdf_timer_sync_cancel - Cancel a timer synchronously
  94. * @timer: timer to cancel
  95. *
  96. * If the timer callback is already running, this function blocks until it
  97. * completes.
  98. *
  99. * Return: true if @timer was deactivated, false if @timer was not active
  100. */
  101. static inline bool qdf_timer_sync_cancel(qdf_timer_t *timer)
  102. {
  103. return __qdf_timer_sync_cancel(timer);
  104. }
  105. /**
  106. * qdf_timer_free() - free a timer
  107. * @timer: timer to free
  108. *
  109. * If the timer callback is already running, this function blocks until it
  110. * completes.
  111. *
  112. * Return: none
  113. */
  114. static inline void qdf_timer_free(qdf_timer_t *timer)
  115. {
  116. __qdf_timer_free(timer);
  117. }
  118. #endif /* _QDF_TIMER_H */