X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fagilent-dmm%2Fapi.c;h=dd39322cf3f5b6a2e65b030abcd46482d15fde45;hb=208c1d35435626a11afa1ab301b2071b2a4e187b;hp=19a4144cca2aed4ea75df880087be1767ae7ace6;hpb=dcd438ee3523098201c7937e75e55775da3b506f;p=libsigrok.git diff --git a/src/hardware/agilent-dmm/api.c b/src/hardware/agilent-dmm/api.c index 19a4144c..dd39322c 100644 --- a/src/hardware/agilent-dmm/api.c +++ b/src/hardware/agilent-dmm/api.c @@ -17,13 +17,13 @@ * along with this program. If not, see . */ +#include #include #include #include #include #include -#include -#include "libsigrok.h" +#include #include "libsigrok-internal.h" #include "agilent-dmm.h" @@ -89,7 +89,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) const char *conn, *serialcomm; char *buf, **tokens; - drvc = di->priv; + drvc = di->context; drvc->instances = NULL; devices = NULL; @@ -122,10 +122,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) } len = 128; - if (!(buf = g_try_malloc(len))) { - sr_err("Serial buffer malloc failed."); - return NULL; - } + buf = g_malloc(len); serial_readline(serial, &buf, &len, 250); if (!len) return NULL; @@ -166,7 +163,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) 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) @@ -238,14 +235,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } - + devc = sdi->priv; devc->cb_data = cb_data; - /* Send header packet to the session bus. */ std_session_send_df_header(cb_data, LOG_PREFIX); /* Poll every 100ms, or whenever some data comes in. */ @@ -278,5 +270,5 @@ SR_PRIV struct sr_dev_driver agdmm_driver_info = { .dev_close = std_serial_dev_close, .dev_acquisition_start = dev_acquisition_start, .dev_acquisition_stop = dev_acquisition_stop, - .priv = NULL, + .context = NULL, };