osif_psoc_sync.h 5.6 KB

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