From: Felix Fietkau Date: Sun, 17 Feb 2013 17:56:23 +0000 (+0100) Subject: add a function to get a string for a qmi error code X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f38d620f4c172feb435d332ad7aba353fe7326d9;p=oweals%2Fuqmi.git add a function to get a string for a qmi error code --- 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