scpi: Move closing of discovered devices to sr_scpi_scan_resource().
This commit is contained in:
parent
b7b873cea3
commit
a00106b7f8
|
@ -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);
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue