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