diff options
author | Felix Fietkau <nbd@openwrt.org> | 2013-02-17 18:56:23 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2013-02-17 18:56:23 +0100 |
commit | f38d620f4c172feb435d332ad7aba353fe7326d9 (patch) | |
tree | 8640b45fef211908fbe83fc35d3c407c651d684c | |
parent | cf9256f962c747a95720ceb88e076118743309b8 (diff) |
add a function to get a string for a qmi error code
-rw-r--r-- | dev.c | 14 | ||||
-rw-r--r-- | uqmi.h | 1 |
2 files changed, 15 insertions, 0 deletions
@@ -4,6 +4,8 @@ #include <stdio.h> #include <string.h> #include "uqmi.h" +#include "qmi-errors.h" +#include "qmi-errors.c" #define __qmi_service(_n) [__##_n] = _n static const uint8_t qmi_services[__QMI_SERVICE_LAST] = { @@ -335,3 +337,15 @@ QmiService qmi_service_get_by_name(const char *str) return -1; } + +const char *qmi_get_error_str(int code) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(qmi_errors); i++) { + if (qmi_errors[i].code == code) + return qmi_errors[i].text; + } + + return "Unknown error"; +} @@ -91,5 +91,6 @@ static inline bool qmi_request_pending(struct qmi_request *req) int qmi_service_connect(struct qmi_dev *qmi, QmiService svc, int client_id); int qmi_service_get_client_id(struct qmi_dev *qmi, QmiService svc); QmiService qmi_service_get_by_name(const char *str); +const char *qmi_get_error_str(int code); #endif |