]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/yokogawa-dlm/api.c
sr_dev_inst_free(): Allow NULL as argument.
[libsigrok.git] / src / hardware / yokogawa-dlm / api.c
index 0a02f5d129ad6289bbc19ccc49cfbd9754d36a3e..e14e847d9d6346ea845642299b538950ca44b2ec 100644 (file)
@@ -23,7 +23,7 @@
 #include "scpi.h"
 #include "protocol.h"
 
-SR_PRIV struct sr_dev_driver yokogawa_dlm_driver_info;
+static struct sr_dev_driver yokogawa_dlm_driver_info;
 
 static const char *MANUFACTURER_ID = "YOKOGAWA";
 static const char *MANUFACTURER_NAME = "Yokogawa";
@@ -43,14 +43,14 @@ static const uint32_t dlm_devopts[] = {
        SR_CONF_TIMEBASE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
        SR_CONF_NUM_HDIV | SR_CONF_GET,
        SR_CONF_HORIZ_TRIGGERPOS | SR_CONF_GET | SR_CONF_SET,
-       SR_CONF_TRIGGER_SLOPE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
        SR_CONF_TRIGGER_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+       SR_CONF_TRIGGER_SLOPE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
 };
 
 static const uint32_t dlm_analog_devopts[] = {
-       SR_CONF_COUPLING | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
-       SR_CONF_VDIV | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
        SR_CONF_NUM_VDIV | SR_CONF_GET,
+       SR_CONF_VDIV | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
+       SR_CONF_COUPLING | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
 };
 
 static const uint32_t dlm_digital_devopts[] = {
@@ -111,8 +111,7 @@ static struct sr_dev_inst *probe_usbtmc_device(struct sr_scpi_dev_inst *scpi)
 fail:
        if (hw_info)
                sr_scpi_hw_info_free(hw_info);
-       if (sdi)
-               sr_dev_inst_free(sdi);
+       sr_dev_inst_free(sdi);
        g_free(devc);
 
        return NULL;
@@ -209,9 +208,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;
 
@@ -658,7 +659,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
 
-       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;
@@ -674,7 +675,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver yokogawa_dlm_driver_info = {
+static struct sr_dev_driver yokogawa_dlm_driver_info = {
        .name = "yokogawa-dlm",
        .longname = "Yokogawa DL/DLM",
        .api_version = 1,
@@ -693,3 +694,4 @@ SR_PRIV struct sr_dev_driver yokogawa_dlm_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(yokogawa_dlm_driver_info);