1 /* 2 * Copyright (c) 2014-2019 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 #include "linux/errno.h" 21 #include "qdf_module.h" 22 #include "qdf_status.h" 23 24 int qdf_status_to_os_return(QDF_STATUS status) 25 { 26 switch (status) { 27 case QDF_STATUS_SUCCESS: 28 return 0; 29 case QDF_STATUS_E_RESOURCES: 30 return -EBUSY; 31 case QDF_STATUS_E_NOMEM: 32 return -ENOMEM; 33 case QDF_STATUS_E_AGAIN: 34 return -EAGAIN; 35 case QDF_STATUS_E_INVAL: 36 return -EINVAL; 37 case QDF_STATUS_E_FAULT: 38 return -EFAULT; 39 case QDF_STATUS_E_ALREADY: 40 return -EALREADY; 41 case QDF_STATUS_E_BADMSG: 42 return -EBADMSG; 43 case QDF_STATUS_E_BUSY: 44 return -EBUSY; 45 case QDF_STATUS_E_CANCELED: 46 return -ECANCELED; 47 case QDF_STATUS_E_ABORTED: 48 return -ECONNABORTED; 49 case QDF_STATUS_E_PERM: 50 return -EPERM; 51 case QDF_STATUS_E_EXISTS: 52 return -EEXIST; 53 case QDF_STATUS_E_NOENT: 54 return -ENOENT; 55 case QDF_STATUS_E_E2BIG: 56 return -E2BIG; 57 case QDF_STATUS_E_NOSPC: 58 return -ENOSPC; 59 case QDF_STATUS_E_ADDRNOTAVAIL: 60 return -EADDRNOTAVAIL; 61 case QDF_STATUS_E_ENXIO: 62 return -ENXIO; 63 case QDF_STATUS_E_NETDOWN: 64 return -ENETDOWN; 65 case QDF_STATUS_E_IO: 66 return -EIO; 67 case QDF_STATUS_E_NETRESET: 68 return -ENETRESET; 69 case QDF_STATUS_E_PENDING: 70 return -EINPROGRESS; 71 case QDF_STATUS_E_TIMEOUT: 72 return -ETIMEDOUT; 73 default: 74 return -EPERM; 75 } 76 } 77 qdf_export_symbol(qdf_status_to_os_return); 78 79 QDF_STATUS qdf_status_from_os_return(int rc) 80 { 81 switch (rc) { 82 case 0: 83 return QDF_STATUS_SUCCESS; 84 case -ENOMEM: 85 return QDF_STATUS_E_NOMEM; 86 case -EAGAIN: 87 return QDF_STATUS_E_AGAIN; 88 case -EINVAL: 89 return QDF_STATUS_E_INVAL; 90 case -EFAULT: 91 return QDF_STATUS_E_FAULT; 92 case -EALREADY: 93 return QDF_STATUS_E_ALREADY; 94 case -EBADMSG: 95 return QDF_STATUS_E_BADMSG; 96 case -EBUSY: 97 return QDF_STATUS_E_BUSY; 98 case -ECANCELED: 99 return QDF_STATUS_E_CANCELED; 100 case -ECONNABORTED: 101 return QDF_STATUS_E_ABORTED; 102 case -EPERM: 103 return QDF_STATUS_E_PERM; 104 case -EEXIST: 105 return QDF_STATUS_E_EXISTS; 106 case -ENOENT: 107 return QDF_STATUS_E_NOENT; 108 case -E2BIG: 109 return QDF_STATUS_E_E2BIG; 110 case -ENOSPC: 111 return QDF_STATUS_E_NOSPC; 112 case -EADDRNOTAVAIL: 113 return QDF_STATUS_E_ADDRNOTAVAIL; 114 case -ENXIO: 115 return QDF_STATUS_E_ENXIO; 116 case -ENETDOWN: 117 return QDF_STATUS_E_NETDOWN; 118 case -EIO: 119 return QDF_STATUS_E_IO; 120 case -ENETRESET: 121 return QDF_STATUS_E_NETRESET; 122 case -EINPROGRESS: 123 return QDF_STATUS_E_PENDING; 124 case -ETIMEDOUT: 125 return QDF_STATUS_E_TIMEOUT; 126 case -ERESTARTSYS: 127 return QDF_STATUS_E_RESTART; 128 default: 129 return QDF_STATUS_E_PERM; 130 } 131 } 132 qdf_export_symbol(qdf_status_from_os_return); 133 134