[PATCH 14/25] efw-downloader: subcmd-device: check supported models or not

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This commit checks whether the device for node is supported models or not.
When it's unsupported, the runtime exits with EXIT_FAILURE.

Signed-off-by: Takashi Sakamoto <o-takashi@xxxxxxxxxxxxx>
---
 efw-downloader/src/subcmd-device.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/efw-downloader/src/subcmd-device.c b/efw-downloader/src/subcmd-device.c
index e1be025..b93d62d 100644
--- a/efw-downloader/src/subcmd-device.c
+++ b/efw-downloader/src/subcmd-device.c
@@ -6,6 +6,7 @@
 #include <assert.h>
 
 #include "efw-proto.h"
+#include "config-rom.h"
 
 #define report_error(error, msg)                                                    \
         fprintf(stderr, "Fail to %s: %s %d %s\n",                                   \
@@ -55,6 +56,9 @@ int subcmd_device(int argc, char **argv)
     const char *path;
     const char *op_name;
     HinawaFwNode *node;
+    const guint8 *rom;
+    gsize length;
+    guint32 vendor_id, model_id;
     EfwProto *proto;
     int err;
     int i;
@@ -83,8 +87,21 @@ int subcmd_device(int argc, char **argv)
         goto err;
     }
 
-    entry->op(argc, argv, proto, &error);
+    hinawa_fw_node_get_config_rom(node, &rom, &length, &error);
+    if (error != NULL) {
+        report_error(error, "get config rom");
+        goto err_node;
+    }
 
+    if (!config_rom_detect_vendor_and_model(rom, &vendor_id, &model_id)) {
+        fprintf(stderr, "The node is not for Fireworks device: %s\n", path);
+        g_set_error_literal(&error, G_FILE_ERROR, g_file_error_from_errno(ENXIO),
+                            "The node is not for Fireworks device");
+        goto err_node;
+    }
+
+    entry->op(argc, argv, proto, &error);
+err_node:
     g_object_unref(node);
 err:
     if (error != NULL) {
-- 
2.25.1




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux