X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Flecroy-xstream%2Fapi.c;h=34b50b7ae33d91e6c325d05c79f81608b1befb9d;hb=3553451f1ed45d92bff11952cb131ac6a891b69f;hp=1727ab6d4590e7242942e310690de70963f347f5;hpb=8662130615d7a59883c303914f94377032101cb9;p=libsigrok.git diff --git a/src/hardware/lecroy-xstream/api.c b/src/hardware/lecroy-xstream/api.c index 1727ab6d..34b50b7a 100644 --- a/src/hardware/lecroy-xstream/api.c +++ b/src/hardware/lecroy-xstream/api.c @@ -104,8 +104,7 @@ static struct sr_dev_inst *probe_serial_device(struct sr_scpi_dev_inst *scpi) fail: sr_scpi_hw_info_free(hw_info); - if (sdi) - sr_dev_inst_free(sdi); + sr_dev_inst_free(sdi); g_free(devc); return NULL; @@ -116,47 +115,31 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return sr_scpi_scan(di->context, options, probe_serial_device); } -static void clear_helper(void *priv) +static void clear_helper(struct dev_context *devc) { - struct dev_context *devc; - - devc = priv; - lecroy_xstream_state_free(devc->model_state); - g_free(devc->analog_groups); - - g_free(devc); } static int dev_clear(const struct sr_dev_driver *di) { - return std_dev_clear(di, clear_helper); + return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper); } static int dev_open(struct sr_dev_inst *sdi) { - if (sdi->status != SR_ST_ACTIVE && sr_scpi_open(sdi->conn) != SR_OK) + if (sr_scpi_open(sdi->conn) != SR_OK) return SR_ERR; if (lecroy_xstream_state_get(sdi) != SR_OK) return SR_ERR; - sdi->status = SR_ST_ACTIVE; - return SR_OK; } static int dev_close(struct sr_dev_inst *sdi) { - if (sdi->status == SR_ST_INACTIVE) - return SR_OK; - - sr_scpi_close(sdi->conn); - - sdi->status = SR_ST_INACTIVE; - - return SR_OK; + return sr_scpi_close(sdi->conn); } static int config_get(uint32_t key, GVariant **data, @@ -554,9 +537,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) int ret; struct sr_scpi_dev_inst *scpi; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - devc = sdi->priv; scpi = sdi->conn; /* Preset empty results. */ @@ -617,9 +597,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) std_session_send_df_end(sdi); - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - devc = sdi->priv; devc->num_frames = 0;