From f38d620f4c172feb435d332ad7aba353fe7326d9 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 17 Feb 2013 18:56:23 +0100 Subject: [PATCH] add a function to get a string for a qmi error code --- dev.c | 14 ++++++++++++++ uqmi.h | 1 + 2 files changed, 15 insertions(+) diff --git a/dev.c b/dev.c index ed9d60f..21e30ea 100644 --- a/dev.c +++ b/dev.c @@ -4,6 +4,8 @@ #include #include #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 2f06890..213dbc5 100644 --- 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 -- 2.25.1