qdf_timer.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. /**
  49. * qdf_timer_start() - start a timer
  50. * @timer: timer to start
  51. * @msec: Expiration period in milliseconds
  52. *
  53. * Return: none
  54. */
  55. static inline void qdf_timer_start(qdf_timer_t *timer, int msec)
  56. {
  57. __qdf_timer_start(timer, msec);
  58. }
  59. /**
  60. * qdf_timer_mod() - modify the timeout on a timer
  61. * @timer: timer to modify
  62. * @msec: Expiration period in milliseconds
  63. *
  64. * If @timer is not active, it will be activated.
  65. *
  66. * Return: none
  67. */
  68. static inline void qdf_timer_mod(qdf_timer_t *timer, int msec)
  69. {
  70. __qdf_timer_mod(timer, msec);
  71. }
  72. /**
  73. * qdf_timer_stop() - cancel a timer
  74. * @timer: timer to cancel
  75. *
  76. * Note! The timer callback may be executing when this function call returns.
  77. * If you want to ensure that it is not, use qdf_timer_sync_cancel() instead.
  78. *
  79. * Return: true if @timer was deactivated, false if @timer was not active
  80. */
  81. static inline bool qdf_timer_stop(qdf_timer_t *timer)
  82. {
  83. return __qdf_timer_stop(timer);
  84. }
  85. /**
  86. * qdf_timer_sync_cancel - Cancel a timer synchronously
  87. * @timer: timer to cancel
  88. *
  89. * If the timer callback is already running, this function blocks until it
  90. * completes.
  91. *
  92. * Return: true if @timer was deactivated, false if @timer was not active
  93. */
  94. static inline bool qdf_timer_sync_cancel(qdf_timer_t *timer)
  95. {
  96. return __qdf_timer_sync_cancel(timer);
  97. }
  98. /**
  99. * qdf_timer_free() - free a timer
  100. * @timer: timer to free
  101. *
  102. * If the timer callback is already running, this function blocks until it
  103. * completes.
  104. *
  105. * Return: none
  106. */
  107. static inline void qdf_timer_free(qdf_timer_t *timer)
  108. {
  109. __qdf_timer_free(timer);
  110. }
  111. #endif /* _QDF_TIMER_H */