osif_psoc_sync.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. * Copyright (c) 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. #ifndef __OSIF_PSOC_SYNC_H
  19. #define __OSIF_PSOC_SYNC_H
  20. #include "linux/device.h"
  21. #include "wlan_dsc_driver.h"
  22. #include "qdf_types.h"
  23. /**
  24. * struct osif_psoc_sync - opaque synchronization handle for a psoc
  25. */
  26. struct osif_psoc_sync;
  27. /**
  28. * osif_psoc_sync_create() - create a psoc synchronization context
  29. * @out_psoc_sync: out parameter for the new synchronization context
  30. *
  31. * Return: Errno
  32. */
  33. qdf_must_check int
  34. osif_psoc_sync_create(struct osif_psoc_sync **out_psoc_sync);
  35. /**
  36. * osif_psoc_sync_create_and_trans() - create a psoc synchronization context
  37. * @out_psoc_sync: out parameter for the new synchronization context
  38. *
  39. * For protecting the device creation process.
  40. *
  41. * Return: Errno
  42. */
  43. #define osif_psoc_sync_create_and_trans(out_psoc_sync) \
  44. __osif_psoc_sync_create_and_trans(out_psoc_sync, __func__)
  45. qdf_must_check int
  46. __osif_psoc_sync_create_and_trans(struct osif_psoc_sync **out_psoc_sync,
  47. const char *desc);
  48. /**
  49. * osif_psoc_sync_destroy() - destroy a psoc synchronization context
  50. * @psoc_sync: the context to destroy
  51. *
  52. * Return: none
  53. */
  54. void osif_psoc_sync_destroy(struct osif_psoc_sync *psoc_sync);
  55. /**
  56. * osif_psoc_sync_register() - register a psoc for operations/transitions
  57. * @dev: the device to use as the operation/transition lookup key
  58. * @psoc_sync: the psoc synchronization context to register
  59. *
  60. * Return: none
  61. */
  62. void osif_psoc_sync_register(struct device *dev,
  63. struct osif_psoc_sync *psoc_sync);
  64. /**
  65. * osif_psoc_sync_unregister() - unregister a psoc for operations/transitions
  66. * @dev: the device originally used to register the psoc_sync context
  67. *
  68. * Return: the psoc synchronization context that was registered for @dev
  69. */
  70. struct osif_psoc_sync *osif_psoc_sync_unregister(struct device *dev);
  71. /**
  72. * osif_psoc_sync_trans_start() - attempt to start a transition on @dev
  73. * @dev: the device to transition
  74. * @out_psoc_sync: out parameter for the synchronization context registered with
  75. * @dev, populated on success
  76. *
  77. * Return: Errno
  78. */
  79. #define osif_psoc_sync_trans_start(dev, out_psoc_sync) \
  80. __osif_psoc_sync_trans_start(dev, out_psoc_sync, __func__)
  81. qdf_must_check int
  82. __osif_psoc_sync_trans_start(struct device *dev,
  83. struct osif_psoc_sync **out_psoc_sync,
  84. const char *desc);
  85. /**
  86. * osif_psoc_sync_trans_start_wait() - attempt to start a transition on @dev,
  87. * blocking if a conflicting transition is in flight
  88. * @dev: the device to transition
  89. * @out_psoc_sync: out parameter for the synchronization context registered with
  90. * @dev, populated on success
  91. *
  92. * Return: Errno
  93. */
  94. #define osif_psoc_sync_trans_start_wait(dev, out_psoc_sync) \
  95. __osif_psoc_sync_trans_start_wait(dev, out_psoc_sync, __func__)
  96. qdf_must_check int
  97. __osif_psoc_sync_trans_start_wait(struct device *dev,
  98. struct osif_psoc_sync **out_psoc_sync,
  99. const char *desc);
  100. /**
  101. * osif_psoc_sync_trans_resume() - resume a transition on @dev
  102. * @dev: the device under transition
  103. * @out_psoc_sync: out parameter for the synchronization context registered with
  104. * @dev, populated on success
  105. *
  106. * Return: Errno
  107. */
  108. int osif_psoc_sync_trans_resume(struct device *dev,
  109. struct osif_psoc_sync **out_psoc_sync);
  110. /**
  111. * osif_psoc_sync_trans_stop() - stop a transition associated with @psoc_sync
  112. * @psoc_sync: the synchonization context tracking the transition
  113. *
  114. * Return: none
  115. */
  116. void osif_psoc_sync_trans_stop(struct osif_psoc_sync *psoc_sync);
  117. /**
  118. * osif_psoc_sync_assert_trans_protected() - assert that @dev is currently
  119. * protected by a transition
  120. * @dev: the device to check
  121. *
  122. * Return: none
  123. */
  124. void osif_psoc_sync_assert_trans_protected(struct device *dev);
  125. /**
  126. * osif_psoc_sync_op_start() - attempt to start an operation on @dev
  127. * @dev: the device to operate against
  128. * @out_psoc_sync: out parameter for the synchronization context registered with
  129. * @dev, populated on success
  130. *
  131. * Return: Errno
  132. */
  133. #define osif_psoc_sync_op_start(dev, out_psoc_sync) \
  134. __osif_psoc_sync_op_start(dev, out_psoc_sync, __func__)
  135. qdf_must_check int
  136. __osif_psoc_sync_op_start(struct device *dev,
  137. struct osif_psoc_sync **out_psoc_sync,
  138. const char *func);
  139. /**
  140. * osif_psoc_sync_op_stop() - stop an operation associated with @psoc_sync
  141. * @psoc_sync: the synchonization context tracking the operation
  142. *
  143. * Return: none
  144. */
  145. #define osif_psoc_sync_op_stop(psoc_sync) \
  146. __osif_psoc_sync_op_stop(psoc_sync, __func__)
  147. void __osif_psoc_sync_op_stop(struct osif_psoc_sync *psoc_sync,
  148. const char *func);
  149. /**
  150. * osif_psoc_sync_wait_for_ops() - wait until all @psoc_sync operations complete
  151. * @psoc_sync: the synchonization context tracking the operations
  152. *
  153. * Return: None
  154. */
  155. void osif_psoc_sync_wait_for_ops(struct osif_psoc_sync *psoc_sync);
  156. #endif /* __OSIF_PSOC_SYNC_H */