]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/scpi-pps/api.c
sr_dev_open(): Set status to SR_ST_ACTIVE upon success.
[libsigrok.git] / src / hardware / scpi-pps / api.c
index ad3d0a379ea89a7e233d954181e645d8ed117151..52b70d3e0adf5a6f582b23004e3ed312b20bf986 100644 (file)
@@ -43,9 +43,8 @@ static const struct pps_channel_instance pci[] = {
 };
 
 static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi,
-                                       int (*get_hw_id)(struct sr_scpi_dev_inst *scpi,
-                                                       struct sr_scpi_hw_info **scpi_response)
-                          )
+               int (*get_hw_id)(struct sr_scpi_dev_inst *scpi,
+               struct sr_scpi_hw_info **scpi_response))
 {
        struct dev_context *devc;
        struct sr_dev_inst *sdi;
@@ -252,15 +251,10 @@ static int dev_open(struct sr_dev_inst *sdi)
        struct sr_scpi_dev_inst *scpi;
        GVariant *beeper;
 
-       if (sdi->status != SR_ST_INACTIVE)
-               return SR_ERR;
-
        scpi = sdi->conn;
        if (sr_scpi_open(scpi) < 0)
                return SR_ERR;
 
-       sdi->status = SR_ST_ACTIVE;
-
        devc = sdi->priv;
        scpi_cmd(sdi, devc->device->commands, SCPI_CMD_REMOTE);
        devc->beeper_was_set = FALSE;
@@ -281,9 +275,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        struct sr_scpi_dev_inst *scpi;
        struct dev_context *devc;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        devc = sdi->priv;
        scpi = sdi->conn;
        if (scpi) {
@@ -451,9 +442,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        if (!sdi)
                return SR_ERR_ARG;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        if (cg)
                /* Channel group specified. */
                select_channel(sdi, cg->channels->data);
@@ -643,16 +631,13 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        struct pps_channel *pch;
        int cmd, ret;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        devc = sdi->priv;
        scpi = sdi->conn;
 
        if ((ret = sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 10,
                        scpi_pps_receive_data, (void *)sdi)) != SR_OK)
                return ret;
-       std_session_send_df_header(sdi, LOG_PREFIX);
+       std_session_send_df_header(sdi);
 
        /* Prime the pipe with the first channel's fetch. */
        ch = sr_next_enabled_channel(sdi, NULL);
@@ -679,9 +664,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        struct sr_scpi_dev_inst *scpi;
        float f;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        scpi = sdi->conn;
 
        /*
@@ -692,7 +674,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        sr_scpi_get_float(scpi, NULL, &f);
        sr_scpi_source_remove(sdi->session, scpi);
 
-       std_session_send_df_end(sdi, LOG_PREFIX);
+       std_session_send_df_end(sdi);
 
        return SR_OK;
 }