]> sigrok.org Git - libsigrok.git/blobdiff - hardware/chronovu-la8/api.c
sr/drivers: change driver dev_open/dev_close calls to use sdi
[libsigrok.git] / hardware / chronovu-la8 / api.c
index e1f32acafd0ed5911e4260672c43da854001cc89..337c07ff90080f9047580f4757883eb57ac6b063 100644 (file)
@@ -75,10 +75,11 @@ static int hw_init(void)
 
 static GSList *hw_scan(GSList *options)
 {
-       int ret;
        struct sr_dev_inst *sdi;
        struct context *ctx;
        GSList *devices;
+       unsigned int i;
+       int ret;
 
        (void)options;
        devices = NULL;
@@ -141,7 +142,7 @@ static GSList *hw_scan(GSList *options)
                sr_err("la8: %s: sr_dev_inst_new failed", __func__);
                goto err_close_ftdic;
        }
-
+       sdi->driver = cdi;
        sdi->priv = ctx;
 
        devices = g_slist_append(devices, sdi);
@@ -167,16 +168,10 @@ err_free_nothing:
        return NULL;
 }
 
-static int hw_dev_open(int dev_index)
+static int hw_dev_open(struct sr_dev_inst *sdi)
 {
-       int ret;
-       struct sr_dev_inst *sdi;
        struct context *ctx;
-
-       if (!(sdi = sr_dev_inst_get(cdi->instances, dev_index))) {
-               sr_err("la8: %s: sdi was NULL", __func__);
-               return SR_ERR_BUG;
-       }
+       int ret;
 
        if (!(ctx = sdi->priv)) {
                sr_err("la8: %s: sdi->priv was NULL", __func__);
@@ -226,16 +221,10 @@ err_dev_open_close_ftdic:
        return SR_ERR;
 }
 
-static int hw_dev_close(int dev_index)
+static int hw_dev_close(struct sr_dev_inst *sdi)
 {
-       struct sr_dev_inst *sdi;
        struct context *ctx;
 
-       if (!(sdi = sr_dev_inst_get(cdi->instances, dev_index))) {
-               sr_err("la8: %s: sdi was NULL", __func__);
-               return SR_ERR_BUG;
-       }
-
        if (!(ctx = sdi->priv)) {
                sr_err("la8: %s: sdi->priv was NULL", __func__);
                return SR_ERR_BUG;
@@ -277,6 +266,9 @@ static int hw_info_get(int info_id, const void **data,
                *data = sdi;
                sr_spew("la8: %s: Returning sdi.", __func__);
                break;
+       case SR_DI_HWCAPS:
+               *data = hwcaps;
+               break;
        case SR_DI_NUM_PROBES:
                *data = GINT_TO_POINTER(NUM_PROBES);
                sr_spew("la8: %s: Returning number of probes: %d.", __func__,
@@ -305,6 +297,8 @@ static int hw_info_get(int info_id, const void **data,
                } else
                        return SR_ERR;
                break;
+       default:
+               return SR_ERR_ARG;
        }
 
        return SR_OK;
@@ -324,30 +318,16 @@ static int hw_dev_status_get(int dev_index)
        return sdi->status;
 }
 
-static const int *hw_hwcap_get_all(void)
-{
-       sr_spew("la8: Returning list of device capabilities.");
-
-       return hwcaps;
-}
-
-static int hw_dev_config_set(int dev_index, int hwcap, const void *value)
+static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
+               const void *value)
 {
-       struct sr_dev_inst *sdi;
        struct context *ctx;
 
-       if (!(sdi = sr_dev_inst_get(cdi->instances, dev_index))) {
-               sr_err("la8: %s: sdi was NULL", __func__);
-               return SR_ERR_BUG;
-       }
-
        if (!(ctx = sdi->priv)) {
                sr_err("la8: %s: sdi->priv was NULL", __func__);
                return SR_ERR_BUG;
        }
 
-       sr_spew("la8: %s: dev_index %d, hwcap %d", __func__, dev_index, hwcap);
-
        switch (hwcap) {
        case SR_HWCAP_SAMPLERATE:
                if (set_samplerate(sdi, *(const uint64_t *)value) == SR_ERR) {
@@ -556,7 +536,6 @@ SR_PRIV struct sr_dev_driver chronovu_la8_driver_info = {
        .dev_close = hw_dev_close,
        .info_get = hw_info_get,
        .dev_status_get = hw_dev_status_get,
-//     .hwcap_get_all = hw_hwcap_get_all,
        .dev_config_set = hw_dev_config_set,
        .dev_acquisition_start = hw_dev_acquisition_start,
        .dev_acquisition_stop = hw_dev_acquisition_stop,