cpe_err.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015, 2017, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __CPE_ERR__
  6. #define __CPE_ERR__
  7. #include <linux/errno.h>
  8. /* ERROR CODES */
  9. /* Success. The operation completed with no errors. */
  10. #define CPE_EOK 0x00000000
  11. /* General failure. */
  12. #define CPE_EFAILED 0x00000001
  13. /* Bad operation parameter. */
  14. #define CPE_EBADPARAM 0x00000002
  15. /* Unsupported routine or operation. */
  16. #define CPE_EUNSUPPORTED 0x00000003
  17. /* Unsupported version. */
  18. #define CPE_EVERSION 0x00000004
  19. /* Unexpected problem encountered. */
  20. #define CPE_EUNEXPECTED 0x00000005
  21. /* Unhandled problem occurred. */
  22. #define CPE_EPANIC 0x00000006
  23. /* Unable to allocate resource. */
  24. #define CPE_ENORESOURCE 0x00000007
  25. /* Invalid handle. */
  26. #define CPE_EHANDLE 0x00000008
  27. /* Operation is already processed. */
  28. #define CPE_EALREADY 0x00000009
  29. /* Operation is not ready to be processed. */
  30. #define CPE_ENOTREADY 0x0000000A
  31. /* Operation is pending completion. */
  32. #define CPE_EPENDING 0x0000000B
  33. /* Operation could not be accepted or processed. */
  34. #define CPE_EBUSY 0x0000000C
  35. /* Operation aborted due to an error. */
  36. #define CPE_EABORTED 0x0000000D
  37. /* Operation preempted by a higher priority. */
  38. #define CPE_EPREEMPTED 0x0000000E
  39. /* Operation requests intervention to complete. */
  40. #define CPE_ECONTINUE 0x0000000F
  41. /* Operation requests immediate intervention to complete. */
  42. #define CPE_EIMMEDIATE 0x00000010
  43. /* Operation is not implemented. */
  44. #define CPE_ENOTIMPL 0x00000011
  45. /* Operation needs more data or resources. */
  46. #define CPE_ENEEDMORE 0x00000012
  47. /* Operation does not have memory. */
  48. #define CPE_ENOMEMORY 0x00000014
  49. /* Item does not exist. */
  50. #define CPE_ENOTEXIST 0x00000015
  51. /* Operation is finished. */
  52. #define CPE_ETERMINATED 0x00000016
  53. /* Max count for adsp error code sent to HLOS*/
  54. #define CPE_ERR_MAX (CPE_ETERMINATED + 1)
  55. /* ERROR STRING */
  56. /* Success. The operation completed with no errors. */
  57. #define CPE_EOK_STR "CPE_EOK"
  58. /* General failure. */
  59. #define CPE_EFAILED_STR "CPE_EFAILED"
  60. /* Bad operation parameter. */
  61. #define CPE_EBADPARAM_STR "CPE_EBADPARAM"
  62. /* Unsupported routine or operation. */
  63. #define CPE_EUNSUPPORTED_STR "CPE_EUNSUPPORTED"
  64. /* Unsupported version. */
  65. #define CPE_EVERSION_STR "CPE_EVERSION"
  66. /* Unexpected problem encountered. */
  67. #define CPE_EUNEXPECTED_STR "CPE_EUNEXPECTED"
  68. /* Unhandled problem occurred. */
  69. #define CPE_EPANIC_STR "CPE_EPANIC"
  70. /* Unable to allocate resource. */
  71. #define CPE_ENORESOURCE_STR "CPE_ENORESOURCE"
  72. /* Invalid handle. */
  73. #define CPE_EHANDLE_STR "CPE_EHANDLE"
  74. /* Operation is already processed. */
  75. #define CPE_EALREADY_STR "CPE_EALREADY"
  76. /* Operation is not ready to be processed. */
  77. #define CPE_ENOTREADY_STR "CPE_ENOTREADY"
  78. /* Operation is pending completion. */
  79. #define CPE_EPENDING_STR "CPE_EPENDING"
  80. /* Operation could not be accepted or processed. */
  81. #define CPE_EBUSY_STR "CPE_EBUSY"
  82. /* Operation aborted due to an error. */
  83. #define CPE_EABORTED_STR "CPE_EABORTED"
  84. /* Operation preempted by a higher priority. */
  85. #define CPE_EPREEMPTED_STR "CPE_EPREEMPTED"
  86. /* Operation requests intervention to complete. */
  87. #define CPE_ECONTINUE_STR "CPE_ECONTINUE"
  88. /* Operation requests immediate intervention to complete. */
  89. #define CPE_EIMMEDIATE_STR "CPE_EIMMEDIATE"
  90. /* Operation is not implemented. */
  91. #define CPE_ENOTIMPL_STR "CPE_ENOTIMPL"
  92. /* Operation needs more data or resources. */
  93. #define CPE_ENEEDMORE_STR "CPE_ENEEDMORE"
  94. /* Operation does not have memory. */
  95. #define CPE_ENOMEMORY_STR "CPE_ENOMEMORY"
  96. /* Item does not exist. */
  97. #define CPE_ENOTEXIST_STR "CPE_ENOTEXIST"
  98. /* Operation is finished. */
  99. #define CPE_ETERMINATED_STR "CPE_ETERMINATED"
  100. /* Unexpected error code. */
  101. #define CPE_ERR_MAX_STR "CPE_ERR_MAX"
  102. struct cpe_err_code {
  103. int lnx_err_code;
  104. char *cpe_err_str;
  105. };
  106. static struct cpe_err_code cpe_err_code_info[CPE_ERR_MAX+1] = {
  107. { 0, CPE_EOK_STR},
  108. { -ENOTRECOVERABLE, CPE_EFAILED_STR},
  109. { -EINVAL, CPE_EBADPARAM_STR},
  110. { -EOPNOTSUPP, CPE_EUNSUPPORTED_STR},
  111. { -ENOPROTOOPT, CPE_EVERSION_STR},
  112. { -ENOTRECOVERABLE, CPE_EUNEXPECTED_STR},
  113. { -ENOTRECOVERABLE, CPE_EPANIC_STR},
  114. { -ENOSPC, CPE_ENORESOURCE_STR},
  115. { -EBADR, CPE_EHANDLE_STR},
  116. { -EALREADY, CPE_EALREADY_STR},
  117. { -EPERM, CPE_ENOTREADY_STR},
  118. { -EINPROGRESS, CPE_EPENDING_STR},
  119. { -EBUSY, CPE_EBUSY_STR},
  120. { -ECANCELED, CPE_EABORTED_STR},
  121. { -EAGAIN, CPE_EPREEMPTED_STR},
  122. { -EAGAIN, CPE_ECONTINUE_STR},
  123. { -EAGAIN, CPE_EIMMEDIATE_STR},
  124. { -EAGAIN, CPE_ENOTIMPL_STR},
  125. { -ENODATA, CPE_ENEEDMORE_STR},
  126. { -EADV, CPE_ERR_MAX_STR},
  127. { -ENOMEM, CPE_ENOMEMORY_STR},
  128. { -ENODEV, CPE_ENOTEXIST_STR},
  129. { -EADV, CPE_ETERMINATED_STR},
  130. { -EADV, CPE_ERR_MAX_STR},
  131. };
  132. static inline int cpe_err_get_lnx_err_code(u32 cpe_error)
  133. {
  134. if (cpe_error > CPE_ERR_MAX)
  135. return cpe_err_code_info[CPE_ERR_MAX].lnx_err_code;
  136. else
  137. return cpe_err_code_info[cpe_error].lnx_err_code;
  138. }
  139. static inline char *cpe_err_get_err_str(u32 cpe_error)
  140. {
  141. if (cpe_error > CPE_ERR_MAX)
  142. return cpe_err_code_info[CPE_ERR_MAX].cpe_err_str;
  143. else
  144. return cpe_err_code_info[cpe_error].cpe_err_str;
  145. }
  146. #endif