]> sigrok.org Git - libsigrok.git/blobdiff - device.c
Rename 'struct sr_probe' to 'struct sr_channel' everywhere.
[libsigrok.git] / device.c
index c0df1ecc4b4ee48e7f6bd641ab6b4f107e5761eb..4c8e9d1a742512ef91afd2be20371d8d1d04b1ef 100644 (file)
--- a/device.c
+++ b/device.c
  */
 
 /** @private
- *  Allocate and initialize new struct sr_probe
- *  @param[in]  index @copydoc sr_probe::index
- *  @param[in]  type @copydoc sr_probe::type
- *  @param[in]  enabled @copydoc sr_probe::enabled
- *  @param[in]  name @copydoc sr_probe::name
+ *  Allocate and initialize new struct sr_channel
+ *  @param[in]  index @copydoc sr_channel::index
+ *  @param[in]  type @copydoc sr_channel::type
+ *  @param[in]  enabled @copydoc sr_channel::enabled
+ *  @param[in]  name @copydoc sr_channel::name
  *
- *  @return NULL (failure) or new struct sr_probe*.
+ *  @return NULL (failure) or new struct sr_channel*.
  */
-SR_PRIV struct sr_probe *sr_probe_new(int index, int type,
+SR_PRIV struct sr_channel *sr_probe_new(int index, int type,
                gboolean enabled, const char *name)
 {
-       struct sr_probe *probe;
+       struct sr_channel *probe;
 
-       if (!(probe = g_try_malloc0(sizeof(struct sr_probe)))) {
+       if (!(probe = g_try_malloc0(sizeof(struct sr_channel)))) {
                sr_err("Probe malloc failed.");
                return NULL;
        }
@@ -87,7 +87,7 @@ SR_API int sr_dev_probe_name_set(const struct sr_dev_inst *sdi,
                int probenum, const char *name)
 {
        GSList *l;
-       struct sr_probe *probe;
+       struct sr_channel *probe;
        int ret;
 
        if (!sdi) {
@@ -126,7 +126,7 @@ SR_API int sr_dev_probe_enable(const struct sr_dev_inst *sdi, int probenum,
                gboolean state)
 {
        GSList *l;
-       struct sr_probe *probe;
+       struct sr_channel *probe;
        int ret;
        gboolean was_enabled;
 
@@ -175,7 +175,7 @@ SR_API int sr_dev_trigger_set(const struct sr_dev_inst *sdi, int probenum,
                const char *trigger)
 {
        GSList *l;
-       struct sr_probe *probe;
+       struct sr_channel *probe;
        char *old_trigger;
        int ret;
 
@@ -285,7 +285,7 @@ SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int index, int status,
        sdi->model = model ? g_strdup(model) : NULL;
        sdi->version = version ? g_strdup(version) : NULL;
        sdi->probes = NULL;
-       sdi->probe_groups = NULL;
+       sdi->channel_groups = NULL;
        sdi->conn = NULL;
        sdi->priv = NULL;
 
@@ -298,7 +298,7 @@ SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int index, int status,
  */
 SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi)
 {
-       struct sr_probe *probe;
+       struct sr_channel *probe;
        GSList *l;
 
        for (l = sdi->probes; l; l = l->next) {
@@ -309,8 +309,8 @@ SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi)
        }
        g_slist_free(sdi->probes);
 
-       if (sdi->probe_groups)
-               g_slist_free(sdi->probe_groups);
+       if (sdi->channel_groups)
+               g_slist_free(sdi->channel_groups);
 
        g_free(sdi->vendor);
        g_free(sdi->model);
@@ -456,20 +456,31 @@ SR_API GSList *sr_dev_list(const struct sr_dev_driver *driver)
 }
 
 /**
- * Clear all devices/instances of the specified driver.
+ * Clear the list of device instances a driver knows about.
  *
- * @param driver The driver to use. Must not be NULL.
+ * @param driver The driver to use. This must be a pointer to one of
+ *               the entries returned by sr_driver_list(). Must not be NULL.
  *
- * @return SR_OK upon success, a negative error code upon errors.
+ * @retval SR_OK Success
+ * @retval SR_ERR_ARG Invalid driver
  *
  * @since 0.2.0
  */
 SR_API int sr_dev_clear(const struct sr_dev_driver *driver)
 {
-       if (driver && driver->dev_clear)
-               return driver->dev_clear();
+       int ret;
+
+       if (!driver) {
+               sr_err("Invalid driver.");
+               return SR_ERR_ARG;
+       }
+
+       if (driver->dev_clear)
+               ret = driver->dev_clear();
        else
-               return SR_OK;
+               ret = std_dev_clear(driver, NULL);
+
+       return ret;
 }
 
 /**