X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fmanson-hcs-3xxx%2Fapi.c;h=ad425c163abc1a1ce72c7eb4b69fb34d9ec3a3af;hb=1c47e0da8f2571bc34dbdc368c3c1f55318c3aa0;hp=ccf1bf96f1d5fa034872c91931e37cdd36c892f4;hpb=7a0b98b544ca00f351295f21f895442680b1c014;p=libsigrok.git
diff --git a/src/hardware/manson-hcs-3xxx/api.c b/src/hardware/manson-hcs-3xxx/api.c
index ccf1bf96..ad425c16 100644
--- a/src/hardware/manson-hcs-3xxx/api.c
+++ b/src/hardware/manson-hcs-3xxx/api.c
@@ -20,10 +20,11 @@
*/
/** @file
- * Manson HCS-3xxx Series power supply driver
+ * Manson HCS-3xxx series power supply driver
* @internal
*/
+#include
#include "protocol.h"
static const uint32_t drvopts[] = {
@@ -69,7 +70,7 @@ static const struct hcs_model models[] = {
{ MANSON_HCS_3600, "HCS-3600-USB", "3600", { 1, 16, 0.1 }, { 0, 60, 0.10 } },
{ MANSON_HCS_3602, "HCS-3602-USB", "3602", { 1, 32, 0.1 }, { 0, 30, 0.10 } },
{ MANSON_HCS_3604, "HCS-3604-USB", "3604", { 1, 60, 0.1 }, { 0, 15, 0.10 } },
- { 0, NULL, NULL, { 0, 0, 0 }, { 0, 0, 0 }, },
+ ALL_ZERO
};
SR_PRIV struct sr_dev_driver manson_hcs_3xxx_driver_info;
@@ -96,7 +97,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
struct sr_serial_dev_inst *serial;
char reply[50], **tokens, *dummy;
- drvc = di->priv;
+ drvc = di->context;
drvc->instances = NULL;
devices = NULL;
conn = NULL;
@@ -144,12 +145,12 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
if (!strcmp(models[i].id, tokens[0]))
model_id = i;
}
- g_strfreev(tokens);
-
if (model_id < 0) {
- sr_err("Unknown model id '%s' detected, aborting.", tokens[0]);
+ sr_err("Unknown model ID '%s' detected, aborting.", tokens[0]);
+ g_strfreev(tokens);
return NULL;
}
+ g_strfreev(tokens);
/* Init device instance, etc. */
sdi = g_malloc0(sizeof(struct sr_dev_inst));
@@ -172,8 +173,10 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
(hcs_read_reply(serial, 2, reply, sizeof(reply)) < 0))
goto exit_err;
tokens = g_strsplit((const gchar *)&reply, "\r", 2);
- if (hcs_parse_volt_curr_mode(sdi, tokens) < 0)
+ if (hcs_parse_volt_curr_mode(sdi, tokens) < 0) {
+ g_strfreev(tokens);
goto exit_err;
+ }
g_strfreev(tokens);
/* Get max. voltage and current. */
@@ -204,7 +207,7 @@ exit_err:
static GSList *dev_list(const struct sr_dev_driver *di)
{
- return ((struct drv_context *)(di->priv))->instances;
+ return ((struct drv_context *)(di->context))->instances;
}
static int cleanup(const struct sr_dev_driver *di)
@@ -395,7 +398,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
devc = sdi->priv;
devc->cb_data = cb_data;
- /* Send header packet to the session bus. */
std_session_send_df_header(cb_data, LOG_PREFIX);
devc->starttime = g_get_monotonic_time();
@@ -433,5 +435,5 @@ SR_PRIV struct sr_dev_driver manson_hcs_3xxx_driver_info = {
.dev_close = std_serial_dev_close,
.dev_acquisition_start = dev_acquisition_start,
.dev_acquisition_stop = dev_acquisition_stop,
- .priv = NULL,
+ .context = NULL,
};