diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2022-03-09 13:18:55 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2022-03-09 13:18:55 +0100 |
commit | 4c49071f4b39f7b88b2ed91b29d9080edb16967a (patch) | |
tree | bdd0c3657a0fe91c110a6856fb51358f1ed78a60 /src | |
parent | 26def72b8eea1e23db05ac439f8c0462627443a4 (diff) | |
download | libqmi-4c49071f4b39f7b88b2ed91b29d9080edb16967a.tar.gz |
qmi-firmware-update: new sysfs based helpers backend
Just the skeleton for now
Diffstat (limited to 'src')
-rw-r--r-- | src/qmi-firmware-update/meson.build | 2 | ||||
-rw-r--r-- | src/qmi-firmware-update/qfu-helpers-sysfs.c | 91 | ||||
-rw-r--r-- | src/qmi-firmware-update/qfu-helpers-sysfs.h | 57 | ||||
-rw-r--r-- | src/qmi-firmware-update/qfu-helpers-udev.c | 1 | ||||
-rw-r--r-- | src/qmi-firmware-update/qfu-helpers.h | 8 |
5 files changed, 158 insertions, 1 deletions
diff --git a/src/qmi-firmware-update/meson.build b/src/qmi-firmware-update/meson.build index dca62dc8..f30b1d35 100644 --- a/src/qmi-firmware-update/meson.build +++ b/src/qmi-firmware-update/meson.build @@ -56,6 +56,8 @@ sources = files( if enable_udev sources += files('qfu-helpers-udev.c') +else + sources += files('qfu-helpers-sysfs.c') endif enum_types = 'qfu-enum-types' diff --git a/src/qmi-firmware-update/qfu-helpers-sysfs.c b/src/qmi-firmware-update/qfu-helpers-sysfs.c new file mode 100644 index 00000000..a8426e9c --- /dev/null +++ b/src/qmi-firmware-update/qfu-helpers-sysfs.c @@ -0,0 +1,91 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * qmi-firmware-update -- Command line tool to update firmware in QMI devices + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Copyright (C) 2022 VMware, Inc. + */ + +#include "config.h" +#include <stdlib.h> +#include <gio/gio.h> + +#if defined WITH_UDEV +# error udev found +#endif + +#include "qfu-helpers.h" +#include "qfu-helpers-sysfs.h" + +/******************************************************************************/ +gchar * +qfu_helpers_sysfs_find_by_file (GFile *file, + GError **error) +{ + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "not implemented"); + return NULL; +} + +gchar * +qfu_helpers_sysfs_find_by_file_path (const gchar *path, + GError **error) +{ + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "not implemented"); + return NULL; +} + +gchar * +qfu_helpers_sysfs_find_by_device_info (guint16 vid, + guint16 pid, + guint busnum, + guint devnum, + GError **error) +{ + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "not implemented"); + return NULL; +} + +/******************************************************************************/ + +GList * +qfu_helpers_sysfs_list_devices (QfuHelpersDeviceType device_type, + const gchar *sysfs_path) +{ + return NULL; +} + +/******************************************************************************/ + +GFile * +qfu_helpers_sysfs_wait_for_device_finish (GAsyncResult *res, + GError **error) +{ + return g_task_propagate_pointer (G_TASK (res), error); +} + +void +qfu_helpers_sysfs_wait_for_device (QfuHelpersDeviceType device_type, + const gchar *sysfs_path, + const gchar *peer_port, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GTask *task; + + task = g_task_new (NULL, cancellable, callback, user_data); + g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, "not implemented"); + g_object_unref (task); +} diff --git a/src/qmi-firmware-update/qfu-helpers-sysfs.h b/src/qmi-firmware-update/qfu-helpers-sysfs.h new file mode 100644 index 00000000..39790e68 --- /dev/null +++ b/src/qmi-firmware-update/qfu-helpers-sysfs.h @@ -0,0 +1,57 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * qmi-firmware-update -- Command line tool to update firmware in QMI devices + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Copyright (C) 2022 VMware, Inc. + */ + +#ifndef QFU_HELPERS_SYSFS_H +#define QFU_HELPERS_SYSFS_H + +#include "config.h" +#include <gio/gio.h> + +#if defined WITH_UDEV +# error udev found +#endif + +G_BEGIN_DECLS + +gchar *qfu_helpers_sysfs_find_by_file (GFile *file, + GError **error); +gchar *qfu_helpers_sysfs_find_by_file_path (const gchar *path, + GError **error); +gchar *qfu_helpers_sysfs_find_by_device_info (guint16 vid, + guint16 pid, + guint busnum, + guint devnum, + GError **error); + +GList *qfu_helpers_sysfs_list_devices (QfuHelpersDeviceType device_type, + const gchar *sysfs_path); + +void qfu_helpers_sysfs_wait_for_device (QfuHelpersDeviceType device_type, + const gchar *sysfs_path, + const gchar *peer_port, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GFile *qfu_helpers_sysfs_wait_for_device_finish (GAsyncResult *res, + GError **error); + +G_END_DECLS + +#endif /* QFU_HELPERS_SYSFS_H */ diff --git a/src/qmi-firmware-update/qfu-helpers-udev.c b/src/qmi-firmware-update/qfu-helpers-udev.c index c9b9fa35..c8a030c2 100644 --- a/src/qmi-firmware-update/qfu-helpers-udev.c +++ b/src/qmi-firmware-update/qfu-helpers-udev.c @@ -27,7 +27,6 @@ # error udev is required #endif - #include "qfu-helpers.h" #include "qfu-helpers-udev.h" #include <gudev/gudev.h> diff --git a/src/qmi-firmware-update/qfu-helpers.h b/src/qmi-firmware-update/qfu-helpers.h index b3b13642..f2202fe9 100644 --- a/src/qmi-firmware-update/qfu-helpers.h +++ b/src/qmi-firmware-update/qfu-helpers.h @@ -51,6 +51,14 @@ gchar *qfu_helpers_find_peer_port (const gchar *sysfs_path, # define qfu_helpers_list_devices qfu_helpers_udev_list_devices # define qfu_helpers_wait_for_device qfu_helpers_udev_wait_for_device # define qfu_helpers_wait_for_device_finish qfu_helpers_udev_wait_for_device_finish +#else +# include "qfu-helpers-sysfs.h" +# define qfu_helpers_find_by_file qfu_helpers_sysfs_find_by_file +# define qfu_helpers_find_by_file_path qfu_helpers_sysfs_find_by_file_path +# define qfu_helpers_find_by_device_info qfu_helpers_sysfs_find_by_device_info +# define qfu_helpers_list_devices qfu_helpers_sysfs_list_devices +# define qfu_helpers_wait_for_device qfu_helpers_sysfs_wait_for_device +# define qfu_helpers_wait_for_device_finish qfu_helpers_sysfs_wait_for_device_finish #endif G_END_DECLS |