0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <linux/module.h>
0016 #include <linux/kernel.h>
0017 #include <linux/types.h>
0018 #include <linux/errno.h>
0019
0020 #include <net/nfc/nci.h>
0021 #include <net/nfc/nci_core.h>
0022
0023
0024 int nci_to_errno(__u8 code)
0025 {
0026 switch (code) {
0027 case NCI_STATUS_OK:
0028 return 0;
0029
0030 case NCI_STATUS_REJECTED:
0031 return -EBUSY;
0032
0033 case NCI_STATUS_RF_FRAME_CORRUPTED:
0034 return -EBADMSG;
0035
0036 case NCI_STATUS_NOT_INITIALIZED:
0037 return -EHOSTDOWN;
0038
0039 case NCI_STATUS_SYNTAX_ERROR:
0040 case NCI_STATUS_SEMANTIC_ERROR:
0041 case NCI_STATUS_INVALID_PARAM:
0042 case NCI_STATUS_RF_PROTOCOL_ERROR:
0043 case NCI_STATUS_NFCEE_PROTOCOL_ERROR:
0044 return -EPROTO;
0045
0046 case NCI_STATUS_UNKNOWN_GID:
0047 case NCI_STATUS_UNKNOWN_OID:
0048 return -EBADRQC;
0049
0050 case NCI_STATUS_MESSAGE_SIZE_EXCEEDED:
0051 return -EMSGSIZE;
0052
0053 case NCI_STATUS_DISCOVERY_ALREADY_STARTED:
0054 return -EALREADY;
0055
0056 case NCI_STATUS_DISCOVERY_TARGET_ACTIVATION_FAILED:
0057 case NCI_STATUS_NFCEE_INTERFACE_ACTIVATION_FAILED:
0058 return -ECONNREFUSED;
0059
0060 case NCI_STATUS_RF_TRANSMISSION_ERROR:
0061 case NCI_STATUS_NFCEE_TRANSMISSION_ERROR:
0062 return -ECOMM;
0063
0064 case NCI_STATUS_RF_TIMEOUT_ERROR:
0065 case NCI_STATUS_NFCEE_TIMEOUT_ERROR:
0066 return -ETIMEDOUT;
0067
0068 case NCI_STATUS_FAILED:
0069 default:
0070 return -ENOSYS;
0071 }
0072 }
0073 EXPORT_SYMBOL(nci_to_errno);