]> sigrok.org Git - libsigrok.git/commitdiff
scpi: Move closing of discovered devices to sr_scpi_scan_resource().
authorMartin Ling <redacted>
Sat, 24 Oct 2015 21:27:45 +0000 (22:27 +0100)
committerUwe Hermann <redacted>
Sun, 25 Oct 2015 21:40:35 +0000 (22:40 +0100)
src/hardware/gwinstek-gds-800/api.c
src/hardware/hameg-hmo/api.c
src/hardware/rigol-ds/api.c
src/hardware/scpi-pps/api.c
src/hardware/yokogawa-dlm/api.c
src/scpi/scpi.c

index 4f384aa2923e958d81a4b4fb3ad037157f86da1c..cfec15ee2236381c48af3d64bf4ed46ad0585270 100644 (file)
@@ -57,7 +57,6 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
        }
 
        sdi = g_malloc0(sizeof(struct sr_dev_inst));
-       sdi->status = SR_ST_ACTIVE;
        sdi->vendor = g_strdup(hw_info->manufacturer);
        sdi->model = g_strdup(hw_info->model);
        sdi->version = g_strdup(hw_info->firmware_version);
index 7a2d91c7cc631d7c1d4997148d4de3782a9d5140..415f945b12c9a9a693fe8b19e0178789820573a6 100644 (file)
@@ -81,7 +81,6 @@ static struct sr_dev_inst *hmo_probe_serial_device(struct sr_scpi_dev_inst *scpi
                goto fail;
 
        sdi = g_malloc0(sizeof(struct sr_dev_inst));
-       sdi->status = SR_ST_ACTIVE;
        sdi->vendor = g_strdup(hw_info->manufacturer);
        sdi->model = g_strdup(hw_info->model);
        sdi->version = g_strdup(hw_info->firmware_version);
@@ -100,10 +99,6 @@ static struct sr_dev_inst *hmo_probe_serial_device(struct sr_scpi_dev_inst *scpi
        if (hmo_init_device(sdi) != SR_OK)
                goto fail;
 
-       sr_scpi_close(sdi->conn);
-
-       sdi->status = SR_ST_INACTIVE;
-
        return sdi;
 
 fail:
index 442f4820ce129accb62f5318683803909f8ac971..1f784cfce344177d997a08d5fc73e5a8f0f8e76a 100644 (file)
@@ -313,7 +313,6 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
        }
 
        sdi = g_malloc0(sizeof(struct sr_dev_inst));
-       sdi->status = SR_ST_ACTIVE;
        sdi->vendor = g_strdup(model->series->vendor->name);
        sdi->model = g_strdup(model->name);
        sdi->version = g_strdup(hw_info->firmware_version);
@@ -404,10 +403,6 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
 
        sdi->priv = devc;
 
-       sdi->status = SR_ST_INACTIVE;
-
-       sr_scpi_close(scpi);
-
        return sdi;
 }
 
index 25bc7eed773424bd2f6ce2ef64e14530906bb54a..a29744edefa0b79e6744906b414121511de0a37d 100644 (file)
@@ -91,7 +91,6 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
        }
 
        sdi = g_malloc0(sizeof(struct sr_dev_inst));
-       sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup(vendor);
        sdi->model = g_strdup(hw_info->model);
        sdi->version = g_strdup(hw_info->firmware_version);
@@ -168,7 +167,6 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
        hw_info = NULL;
 
        scpi_cmd(sdi, devc->device->commands, SCPI_CMD_LOCAL);
-       sr_scpi_close(scpi);
 
        return sdi;
 }
index 61c71ea8320d0101992180d6fd5970d656d4360b..21fa1657acb7779ee461114cb422f71a35a09daa 100644 (file)
@@ -92,7 +92,6 @@ static struct sr_dev_inst *probe_usbtmc_device(struct sr_scpi_dev_inst *scpi)
                goto fail;
 
        sdi = g_malloc0(sizeof(struct sr_dev_inst));
-       sdi->status = SR_ST_ACTIVE;
        sdi->vendor = g_strdup(MANUFACTURER_NAME);
        sdi->model = g_strdup(model_name);
        sdi->version = g_strdup(hw_info->firmware_version);
@@ -112,9 +111,6 @@ static struct sr_dev_inst *probe_usbtmc_device(struct sr_scpi_dev_inst *scpi)
        if (dlm_device_init(sdi, model_index) != SR_OK)
                goto fail;
 
-       sr_scpi_close(sdi->conn);
-
-       sdi->status = SR_ST_INACTIVE;
        return sdi;
 
 fail:
index 0efde8bab7b9c11f8d2cec00ee48f1afd0ecac4f..c3c2f7130e5c14d00a0eef3ed0af90be5bd89d50 100644 (file)
@@ -110,12 +110,16 @@ static struct sr_dev_inst *sr_scpi_scan_resource(struct drv_context *drvc,
                return NULL;
        };
 
-       if ((sdi = probe_device(scpi)))
-               return sdi;
+       sdi = probe_device(scpi);
 
        sr_scpi_close(scpi);
-       sr_scpi_free(scpi);
-       return NULL;
+
+       if (sdi)
+               sdi->status = SR_ST_INACTIVE;
+       else
+               sr_scpi_free(scpi);
+
+       return sdi;
 }
 
 SR_PRIV GSList *sr_scpi_scan(struct drv_context *drvc, GSList *options,