add a function to get a string for a qmi error code
authorFelix Fietkau <nbd@openwrt.org>
Sun, 17 Feb 2013 17:56:23 +0000 (18:56 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 17 Feb 2013 17:56:23 +0000 (18:56 +0100)
dev.c
uqmi.h

diff --git a/dev.c b/dev.c
index ed9d60fb16c089ee5e3e21d83fbd52333990d838..21e30eae56bedbb7a5f5af40e2c91a5a56e42def 100644 (file)
--- a/dev.c
+++ b/dev.c
@@ -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";
+}
diff --git a/uqmi.h b/uqmi.h
index 2f068905e1605fb8cb7f3cf6b4dcb70dcfb665a9..213dbc55a164bc4a753f8c3fe67c0fcbc3f76bbf 100644 (file)
--- a/uqmi.h
+++ b/uqmi.h
@@ -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