]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoder.c
Add a DSI protocol decoder.
[libsigrokdecode.git] / decoder.c
index eba5a287f4176008aed1568d465a13018c6be866..83b758f84a8f546496904b287fd40a5dfb524d0e 100644 (file)
--- a/decoder.c
+++ b/decoder.c
@@ -682,8 +682,8 @@ SRD_API int srd_decoder_load(const char *module_name)
         * PDs of different API versions are incompatible and cannot work.
         */
        apiver = srd_decoder_apiver(d);
-       if (apiver != 2) {
-               srd_exception_catch("Only PD API version 2 is supported, "
+       if (apiver != 2 && apiver != 3) {
+               srd_exception_catch("Only PD API version 2/3 is supported, "
                        "decoder %s has version %ld", module_name, apiver);
                fail_txt = "API version mismatch";
                goto err_out;
@@ -767,13 +767,9 @@ SRD_API int srd_decoder_load(const char *module_name)
        return SRD_OK;
 
 except_out:
-       if (fail_txt) {
-               srd_exception_catch("Failed to load decoder %s: %s",
-                                   module_name, fail_txt);
-               fail_txt = NULL;
-       } else {
-               srd_exception_catch("Failed to load decoder %s", module_name);
-       }
+       srd_exception_catch("Failed to load decoder %s: %s",
+                           module_name, fail_txt);
+       fail_txt = NULL;
 err_out:
        if (fail_txt)
                srd_err("Failed to load decoder %s: %s", module_name, fail_txt);
@@ -849,7 +845,7 @@ SRD_API int srd_decoder_unload(struct srd_decoder *dec)
         */
        for (l = sessions; l; l = l->next) {
                sess = l->data;
-               srd_inst_free_all(sess, NULL);
+               srd_inst_free_all(sess);
        }
 
        /* Remove the PD from the list of loaded decoders. */
@@ -992,13 +988,7 @@ SRD_API int srd_decoder_load_all(void)
  */
 SRD_API int srd_decoder_unload_all(void)
 {
-       GSList *l;
-       struct srd_decoder *dec;
-
-       for (l = pd_list; l; l = l->next) {
-               dec = l->data;
-               srd_decoder_unload(dec);
-       }
+       g_slist_foreach(pd_list, (GFunc)srd_decoder_unload, NULL);
        g_slist_free(pd_list);
        pd_list = NULL;