diff mbox series

[15/25] efw-downloader: subcmd-device: bind Fireworks protocol

Message ID 20200821073111.134857-16-o-takashi@sakamocchi.jp (mailing list archive)
State New, archived
Headers show
Series alsa-tools: efw-downloader: add initial version of firmwre downloader for Echo Audio Fireworks devices | expand

Commit Message

Takashi Sakamoto Aug. 21, 2020, 7:31 a.m. UTC
This commit binds Fireworks protocol for the given node.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 efw-downloader/src/subcmd-device.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff mbox series

Patch

diff --git a/efw-downloader/src/subcmd-device.c b/efw-downloader/src/subcmd-device.c
index b93d62d..1bfa1f2 100644
--- a/efw-downloader/src/subcmd-device.c
+++ b/efw-downloader/src/subcmd-device.c
@@ -100,7 +100,26 @@  int subcmd_device(int argc, char **argv)
         goto err_node;
     }
 
+    proto = efw_proto_new();
+    efw_proto_bind(proto, node, &error);
+    if (error != NULL) {
+        if (g_error_matches(error, HINAWA_FW_NODE_ERROR, HINAWA_FW_NODE_ERROR_FAILED)) {
+            if (strstr(error->message, "16") != NULL) {
+                fprintf(stderr, "The range of address on 1394 OHCI controller already used by "
+                        "ALSA fireworks driver.\n");
+            } else {
+                report_error(error, "bind protocol");
+            }
+        } else {
+            report_error(error, "bind protocol");
+        }
+        goto err_node;
+    }
+
     entry->op(argc, argv, proto, &error);
+
+    efw_proto_unbind(proto);
+    g_object_unref(proto);
 err_node:
     g_object_unref(node);
 err: