From: Alexander Couzens Date: Tue, 17 Oct 2023 11:15:22 +0000 (+0300) Subject: move qmi_get_error_str to into utils.c X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=5320c1d656ed30b467b6555472721b25fd3f0c58;p=project%2Fuqmi.git move qmi_get_error_str to into utils.c In prepration to allow uqmid to use it as well. Signed-off-by: Alexander Couzens --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 016b016..e449b88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ ADD_DEFINITIONS(-Os -ggdb -Wall -Werror --std=gnu99 -Wmissing-declarations -Wno- SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") -SET(SOURCES qmi-message.c mbim.c) +SET(SOURCES qmi-message.c mbim.c utils.c) SET(UQMI uqmi.c dev.c commands.c ${SOURCES}) FIND_PATH(ubox_include_dir libubox/usock.h) diff --git a/commands.c b/commands.c index 7ac67b4..ec412d0 100644 --- a/commands.c +++ b/commands.c @@ -29,6 +29,7 @@ #include #include "uqmi.h" +#include "utils.h" #include "commands.h" struct blob_buf status; diff --git a/dev.c b/dev.c index 76be5cd..495a7be 100644 --- a/dev.c +++ b/dev.c @@ -458,15 +458,3 @@ 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 dd88151..19140fe 100644 --- a/uqmi.h +++ b/uqmi.h @@ -122,6 +122,5 @@ 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); int qmi_service_release_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 diff --git a/utils.c b/utils.c new file mode 100644 index 0000000..3a2681d --- /dev/null +++ b/utils.c @@ -0,0 +1,38 @@ +/* + * uqmi -- tiny QMI support implementation + * + * Copyright (C) 2014-2015 Felix Fietkau + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + */ + +#include "utils.h" +#include "qmi-errors.h" +#include + +#include + +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/utils.h b/utils.h new file mode 100644 index 0000000..d7b7947 --- /dev/null +++ b/utils.h @@ -0,0 +1,28 @@ +/* + * uqmi -- tiny QMI support implementation + * + * Copyright (C) 2014-2015 Felix Fietkau + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + */ + + +#ifndef __UTILS_H +#define __UTILS_H + +const char *qmi_get_error_str(int code); + +#endif /* __UTILS_H */