]> sigrok.org Git - libsigrok.git/blobdiff - hardware/alsa/alsa.c
sr: don't free driver-specific per-device struct in drivers
[libsigrok.git] / hardware / alsa / alsa.c
index 4c930e4f18676076df63ff72ca68dfb1990e586e..b6dd66c4ca0a92405bb2649a72dbdd397d1c167e 100644 (file)
@@ -77,7 +77,7 @@ static int hw_init(const char *deviceinfo)
                return 0;
        }
 
-       sdi = sr_device_instance_new(0, SR_ST_ACTIVE, "alsa", NULL, NULL);
+       sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, "alsa", NULL, NULL);
        if (!sdi)
                goto free_alsa;
 
@@ -97,7 +97,7 @@ static int hw_opendev(int device_index)
        struct alsa *alsa;
        int err;
 
-       if (!(sdi = sr_get_device_instance(device_instances, device_index)))
+       if (!(sdi = sr_dev_inst_get(device_instances, device_index)))
                return SR_ERR;
        alsa = sdi->priv;
 
@@ -131,7 +131,7 @@ static int hw_closedev(int device_index)
        struct sr_device_instance *sdi;
        struct alsa *alsa;
 
-       if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
+       if (!(sdi = sr_dev_inst_get(device_instances, device_index))) {
                sr_err("alsa: %s: sdi was NULL", __func__);
                return SR_ERR; /* TODO: SR_ERR_ARG? */
        }
@@ -150,15 +150,18 @@ static int hw_closedev(int device_index)
        return SR_OK;
 }
 
-static void hw_cleanup(void)
+static int hw_cleanup(void)
 {
        struct sr_device_instance *sdi;
 
-       if (!(sdi = sr_get_device_instance(device_instances, 0)))
-               return;
+       if (!(sdi = sr_dev_inst_get(device_instances, 0))) {
+               sr_err("alsa: %s: sdi was NULL", __func__);
+               return SR_ERR_BUG;
+       }
+
+       sr_dev_inst_free(sdi);
 
-       g_free(sdi->priv);
-       sr_device_instance_free(sdi);
+       return SR_OK;
 }
 
 static void *hw_get_device_info(int device_index, int device_info_id)
@@ -167,7 +170,7 @@ static void *hw_get_device_info(int device_index, int device_info_id)
        struct alsa *alsa;
        void *info = NULL;
 
-       if (!(sdi = sr_get_device_instance(device_instances, device_index)))
+       if (!(sdi = sr_dev_inst_get(device_instances, device_index)))
                return NULL;
        alsa = sdi->priv;
 
@@ -210,7 +213,7 @@ static int hw_set_configuration(int device_index, int capability, void *value)
        struct sr_device_instance *sdi;
        struct alsa *alsa;
 
-       if (!(sdi = sr_get_device_instance(device_instances, device_index)))
+       if (!(sdi = sr_dev_inst_get(device_instances, device_index)))
                return SR_ERR;
        alsa = sdi->priv;
 
@@ -296,7 +299,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
        int count;
        int err;
 
-       if (!(sdi = sr_get_device_instance(device_instances, device_index)))
+       if (!(sdi = sr_dev_inst_get(device_instances, device_index)))
                return SR_ERR;
        alsa = sdi->priv;
 
@@ -379,11 +382,13 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
        return SR_OK;
 }
 
-static void hw_stop_acquisition(int device_index, gpointer session_device_id)
+static int hw_stop_acquisition(int device_index, gpointer session_device_id)
 {
        /* Avoid compiler warnings. */
        device_index = device_index;
        session_device_id = session_device_id;
+
+       return SR_OK;
 }
 
 SR_PRIV struct sr_device_plugin alsa_plugin_info = {