X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fhameg-hmo%2Fapi.c;h=92f5ab673a96fa4d48f94c7509465b90dd513f37;hb=d5a61aaf2d634c4558bda225e64e720104a0203f;hp=b89de8d8a096a393b07cf15f8c4bbd8f3b23435c;hpb=c2fdcc25a47c4c8f25e3ea96ea36a674a151e839;p=libsigrok.git diff --git a/src/hardware/hameg-hmo/api.c b/src/hardware/hameg-hmo/api.c index b89de8d8..92f5ab67 100644 --- a/src/hardware/hameg-hmo/api.c +++ b/src/hardware/hameg-hmo/api.c @@ -24,7 +24,7 @@ #define SERIALCOMM "115200/8n1/flow=1" -SR_PRIV struct sr_dev_driver hameg_hmo_driver_info; +static struct sr_dev_driver hameg_hmo_driver_info; static const char *manufacturers[] = { "HAMEG", @@ -189,9 +189,11 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s const struct scope_config *model; struct scope_state *state; - if (!sdi || !(devc = sdi->priv)) + if (!sdi) return SR_ERR_ARG; + devc = sdi->priv; + if ((cg_type = check_channel_group(devc, cg)) == CG_INVALID) return SR_ERR; @@ -318,9 +320,11 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd double tmp_d; gboolean update_sample_rate; - if (!sdi || !(devc = sdi->priv)) + if (!sdi) return SR_ERR_ARG; + devc = sdi->priv; + if ((cg_type = check_channel_group(devc, cg)) == CG_INVALID) return SR_ERR; @@ -483,7 +487,8 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * struct dev_context *devc = NULL; const struct scope_config *model = NULL; - if (sdi && (devc = sdi->priv)) { + if (sdi) { + devc = sdi->priv; if ((cg_type = check_channel_group(devc, cg)) == CG_INVALID) return SR_ERR; @@ -700,6 +705,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) struct sr_channel *ch; struct dev_context *devc; struct sr_scpi_dev_inst *scpi; + int ret; if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -729,22 +735,29 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) if (hmo_check_channels(devc->enabled_channels) != SR_OK) { sr_err("Invalid channel configuration specified!"); - return SR_ERR_NA; + ret = SR_ERR_NA; + goto free_enabled; } if (hmo_setup_channels(sdi) != SR_OK) { sr_err("Failed to setup channel configuration!"); - return SR_ERR; + ret = SR_ERR; + goto free_enabled; } sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 50, hmo_receive_data, (void *)sdi); - std_session_send_df_header(sdi, LOG_PREFIX); + std_session_send_df_header(sdi); devc->current_channel = devc->enabled_channels; return hmo_request_data(sdi); + +free_enabled: + g_slist_free(devc->enabled_channels); + devc->enabled_channels = NULL; + return ret; } static int dev_acquisition_stop(struct sr_dev_inst *sdi) @@ -752,7 +765,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) struct dev_context *devc; struct sr_scpi_dev_inst *scpi; - std_session_send_df_end(sdi, LOG_PREFIX); + std_session_send_df_end(sdi); if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -768,7 +781,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) return SR_OK; } -SR_PRIV struct sr_dev_driver hameg_hmo_driver_info = { +static struct sr_dev_driver hameg_hmo_driver_info = { .name = "hameg-hmo", .longname = "Hameg HMO", .api_version = 1, @@ -786,3 +799,4 @@ SR_PRIV struct sr_dev_driver hameg_hmo_driver_info = { .dev_acquisition_stop = dev_acquisition_stop, .context = NULL, }; +SR_REGISTER_DEV_DRIVER(hameg_hmo_driver_info);