qdf_timer.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Copyright (c) 2014-2016, 2018 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. /* Platform timer object */
  27. typedef __qdf_timer_t qdf_timer_t;
  28. /**
  29. * qdf_timer_init() - initialize a timer
  30. * @hdl: OS handle
  31. * @timer: Timer object pointer
  32. * @func: Timer function
  33. * @arg: Argument of timer function
  34. * @type: deferrable or non deferrable timer type
  35. *
  36. * Timer type QDF_TIMER_TYPE_SW means its a deferrable sw timer which will
  37. * not cause CPU wake upon expiry
  38. * Timer type QDF_TIMER_TYPE_WAKE_APPS means its a non-deferrable timer which
  39. * will cause CPU wake up on expiry
  40. *
  41. * Return: QDF_STATUS
  42. */
  43. static inline QDF_STATUS
  44. qdf_timer_init(qdf_handle_t hdl, qdf_timer_t *timer, qdf_timer_func_t func,
  45. void *arg, QDF_TIMER_TYPE type)
  46. {
  47. return __qdf_timer_init(timer, func, arg, type);
  48. }
  49. /**
  50. * qdf_timer_start() - start a one-shot timer
  51. * @timer: Timer object pointer
  52. * @msec: Expiration period in milliseconds
  53. *
  54. * Return: none
  55. */
  56. static inline void
  57. qdf_timer_start(qdf_timer_t *timer, int msec)
  58. {
  59. __qdf_timer_start(timer, msec);
  60. }
  61. /**
  62. * qdf_timer_mod() - modify existing timer to new timeout value
  63. * @timer: Timer object pointer
  64. * @msec: Expiration period in milliseconds
  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 qdf timer
  74. * @timer: Timer object pointer
  75. *
  76. * return: bool TRUE Timer was cancelled and deactived
  77. * FALSE Timer was cancelled but already got fired.
  78. *
  79. * The function will return after any running timer completes.
  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. * The function will return after any running timer completes.
  88. * @timer: timer object pointer
  89. *
  90. * return: bool TRUE timer was cancelled and deactived
  91. * FALSE timer was not cancelled
  92. */
  93. static inline bool qdf_timer_sync_cancel(qdf_timer_t *timer)
  94. {
  95. return __qdf_timer_sync_cancel(timer);
  96. }
  97. /**
  98. * qdf_timer_free() - free qdf timer
  99. * @timer: Timer object pointer
  100. *
  101. * The function will return after any running timer completes.
  102. * Return: none
  103. */
  104. static inline void qdf_timer_free(qdf_timer_t *timer)
  105. {
  106. __qdf_timer_free(timer);
  107. }
  108. #endif /* _QDF_TIMER_H */