Change all callers to set the fields manually as needed.
/** @private
* Allocate and init a new device instance struct.
- * @param[in] index @copydoc sr_dev_inst::index
- * @param[in] status @copydoc sr_dev_inst::status
- * @param[in] vendor @copydoc sr_dev_inst::vendor
- * @param[in] model @copydoc sr_dev_inst::model
- * @param[in] version @copydoc sr_dev_inst::version
*
- * @retval NULL Error
* @retval struct sr_dev_inst *. Dynamically allocated, free using
* sr_dev_inst_free().
*/
-SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int status,
- const char *vendor, const char *model, const char *version)
+SR_PRIV struct sr_dev_inst *sr_dev_inst_new(void)
{
struct sr_dev_inst *sdi;
- if (!(sdi = g_try_malloc(sizeof(struct sr_dev_inst)))) {
- sr_err("Device instance malloc failed.");
- return NULL;
- }
+ sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->driver = NULL;
- sdi->status = status;
+ sdi->status = -1;
sdi->inst_type = -1;
- sdi->vendor = vendor ? g_strdup(vendor) : NULL;
- sdi->model = model ? g_strdup(model) : NULL;
- sdi->version = version ? g_strdup(version) : NULL;
+ sdi->vendor = NULL;
+ sdi->model = NULL;
+ sdi->version = NULL;
sdi->serial_num = NULL;
sdi->connection_id = NULL;
sdi->channels = NULL;
{
struct sr_dev_inst *sdi;
- sdi = sr_dev_inst_new(0, vendor, model, version);
- if (!sdi)
- return NULL;
-
+ sdi = sr_dev_inst_new();
+ sdi->vendor = g_strdup(vendor);
+ sdi->model = g_strdup(model);
+ sdi->version = g_strdup(version);
sdi->inst_type = SR_INST_USER;
return sdi;
for (i = 0; supported_agdmm[i].model; i++) {
if (strcmp(supported_agdmm[i].modelname, tokens[1]))
continue;
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, "Agilent",
- tokens[1], tokens[3])))
- return NULL;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup("Agilent");
+ sdi->model = g_strdup(tokens[1]);
+ sdi->version = g_strdup(tokens[3]);
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
sr_err("Device context malloc failed.");
return NULL;
sr_info("Found device on port %s.", conn);
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, "APPA", "55II", NULL)))
- goto scan_cleanup;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup("APPA");
+ sdi->model = g_strdup("55II");
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
sr_err("Device context malloc failed.");
devc->use_triggers = 0;
/* Register SIGMA device. */
- if (!(sdi = sr_dev_inst_new(SR_ST_INITIALIZING, USB_VENDOR_NAME,
- USB_MODEL_NAME, NULL))) {
- sr_err("%s: sdi was NULL", __func__);
- goto free;
- }
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INITIALIZING;
+ sdi->vendor = g_strdup(USB_VENDOR_NAME);
+ sdi->model = g_strdup(USB_MODEL_NAME);
sdi->driver = di;
for (i = 0; i < ARRAY_SIZE(channel_names); i++) {
return NULL;
}
- sdi = sr_dev_inst_new(SR_ST_INACTIVE, "Atten", model->name, NULL);
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup("Atten");
+ sdi->model = g_strdup(model->name);
sdi->driver = di;
sdi->inst_type = SR_INST_SERIAL;
sdi->conn = serial;
if (!g_file_test(BEAGLELOGIC_DEV_NODE, G_FILE_TEST_EXISTS))
return NULL;
- sdi = sr_dev_inst_new(SR_ST_INACTIVE, NULL, "BeagleLogic", "1.0");
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->model = g_strdup("BeagleLogic");
+ sdi->version = g_strdup("1.0");
sdi->driver = di;
/* Unless explicitly specified, keep max channels to 8 only */
for (l = usb_devices; l; l = l->next) {
usb = l->data;
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE,
- "Brymen", "BM869", NULL))) {
- sr_err("sr_dev_inst_new returned NULL.");
- return NULL;
- }
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup("Brymen");
+ sdi->model = g_strdup("BM869");
if (!(devc = g_try_malloc0(sizeof(*devc)))) {
sr_err("Device context malloc failed.");
sr_info("Found device on port %s.", conn);
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, "Brymen", "BM85x", NULL)))
- goto scan_cleanup;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup("Brymen");
+ sdi->model = g_strdup("BM85x");
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
sr_err("Device context malloc failed.");
while (g_get_monotonic_time() - start < MAX_SCAN_TIME) {
if (serial_read_nonblocking(serial, &c, 1) == 1 && c == 0xa5) {
/* Found one. */
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, "CEM",
- "DT-885x", NULL)))
- return NULL;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup("CEM");
+ sdi->model = g_strdup("DT-885x");
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
sr_dbg("Device context malloc failed.");
sr_info("Found device on port %s.", conn);
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, center_devs[idx].vendor,
- center_devs[idx].device, NULL)))
- goto scan_cleanup;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup(center_devs[idx].vendor);
+ sdi->model = g_strdup(center_devs[idx].device);
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
sr_err("Device context malloc failed.");
devc->cur_samplerate = devc->prof->max_samplerate;
/* Register the device with libsigrok. */
- sdi = sr_dev_inst_new(SR_ST_INITIALIZING,
- "ChronoVu", devc->prof->modelname, NULL);
- if (!sdi) {
- sr_err("Failed to create device instance.");
- ret = SR_ERR;
- goto err_free_final_buf;
- }
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INITIALIZING;
+ sdi->vendor = g_strdup("ChronoVu");
+ sdi->model = g_strdup(devc->prof->modelname);
sdi->driver = di;
sdi->priv = devc;
err_free_dev_inst:
sr_dev_inst_free(sdi);
-err_free_final_buf:
g_free(devc->final_buf);
err_free_devc:
g_free(devc);
if (!serialcomm)
serialcomm = SERIALCOMM;
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, "Colead",
- "SL-5868P", NULL)))
- return NULL;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup("Colead");
+ sdi->model = g_strdup("SL-5868P");
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
sr_dbg("Device context malloc failed.");
sr_spew("Conrad DIGI 35 CPU assumed at %s.", conn);
- if (!(sdi = sr_dev_inst_new(SR_ST_ACTIVE, "Conrad", "DIGI 35 CPU", NULL)))
- return NULL;
-
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_ACTIVE;
+ sdi->vendor = g_strdup("Conrad");
+ sdi->model = g_strdup("DIGI 35 CPU");
sdi->conn = serial;
sdi->priv = NULL;
sdi->driver = di;
}
devices = NULL;
- sdi = sr_dev_inst_new(SR_ST_ACTIVE, "Demo device", NULL, NULL);
- if (!sdi) {
- sr_err("Device instance creation failed.");
- return NULL;
- }
+
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_ACTIVE;
+ sdi->model = "Demo device";
sdi->driver = di;
devc = g_malloc(sizeof(struct dev_context));
continue;
/* Skip leading spaces in version number. */
for (s = 0; tokens[1][s] == ' '; s++);
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, "Fluke",
- tokens[0] + 6, tokens[1] + s)))
- return NULL;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup("Fluke");
+ sdi->model = g_strdup(tokens[0] + 6);
+ sdi->version = g_strdup(tokens[1] + s);
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
sr_err("Device context malloc failed.");
return NULL;
if (!prof)
continue;
- sdi = sr_dev_inst_new(SR_ST_INITIALIZING,
- prof->vendor, prof->model, prof->model_version);
- if (!sdi)
- return NULL;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INITIALIZING;
+ sdi->vendor = g_strdup(prof->vendor);
+ sdi->model = g_strdup(prof->model);
+ sdi->version = g_strdup(prof->model_version);
sdi->driver = di;
sdi->serial_num = g_strdup(serial_num);
sdi->connection_id = g_strdup(connection_id);
if (model != METRAHIT_NONE) {
sr_spew("%s %s detected!", VENDOR_GMC, gmc_model_str(model));
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, VENDOR_GMC,
- gmc_model_str(model), NULL)))
- return NULL;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup(VENDOR_GMC);
+ sdi->model = g_strdup(gmc_model_str(model));
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
sr_err("Device context malloc failed.");
return NULL;
goto exit_err;
}
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, VENDOR_GMC, NULL, NULL)))
- goto exit_err;
-
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup(VENDOR_GMC);
sdi->priv = devc;
/* Send message 03 "Query multimeter version and status" */
goto exit_err;
}
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, VENDOR_GMC, NULL, NULL)))
- goto exit_err;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup(VENDOR_GMC);
}
};
if (check_manufacturer(hw_info->manufacturer) != SR_OK)
goto fail;
- if (!(sdi = sr_dev_inst_new(SR_ST_ACTIVE,
- hw_info->manufacturer, hw_info->model,
- hw_info->firmware_version))) {
- goto fail;
- }
-
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_ACTIVE;
+ sdi->vendor = g_strdup(hw_info->manufacturer);
+ sdi->model = g_strdup(hw_info->model);
+ sdi->version = g_strdup(hw_info->firmware_version);
+ sdi->serial_num = g_strdup(hw_info->serial_number);
sdi->driver = di;
sdi->inst_type = SR_INST_SCPI;
sdi->conn = scpi;
- sdi->serial_num = g_strdup(hw_info->serial_number);
sr_scpi_hw_info_free(hw_info);
hw_info = NULL;
struct dev_context *devc;
int i;
- sdi = sr_dev_inst_new(SR_ST_INITIALIZING, prof->vendor, prof->model, NULL);
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INITIALIZING;
+ sdi->vendor = g_strdup(prof->vendor);
+ sdi->model = g_strdup(prof->model);
sdi->driver = di;
/*
struct sr_usb_dev_inst *usb;
struct device_info dev_info;
int ret, i;
- char *fw_ver_str;
(void)options;
continue;
}
- fw_ver_str = g_strdup_printf("%u.%u", dev_info.fw_ver_major,
- dev_info.fw_ver_minor);
- if (!fw_ver_str) {
- sr_err("Firmware string malloc failed.");
- sr_usb_dev_inst_free(usb);
- libusb_free_transfer(devc->xfer_in);
- libusb_free_transfer(devc->xfer_out);
- g_free(devc);
- continue;
- }
-
- sdi = sr_dev_inst_new(SR_ST_INACTIVE, VENDOR_NAME,
- MODEL_NAME, fw_ver_str);
- g_free(fw_ver_str);
- if (!sdi) {
- sr_err("sr_dev_inst_new failed.");
- sr_usb_dev_inst_free(usb);
- libusb_free_transfer(devc->xfer_in);
- libusb_free_transfer(devc->xfer_out);
- g_free(devc);
- continue;
- }
-
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup(VENDOR_NAME);
+ sdi->model = g_strdup(MODEL_NAME);
+ sdi->version = g_strdup_printf("%u.%u", dev_info.fw_ver_major, dev_info.fw_ver_minor);
+ sdi->serial_num = g_strdup_printf("%d", dev_info.serial);
sdi->priv = devc;
sdi->driver = di;
sdi->inst_type = SR_INST_USB;
sdi->conn = usb;
- sdi->serial_num = g_strdup_printf("%d", dev_info.serial);
for (i = 0; channel_names[i]; i++) {
ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
}
/* Register the device with libsigrok. */
- sdi = sr_dev_inst_new(SR_ST_INITIALIZING,
- USB_VENDOR_NAME, USB_MODEL_NAME, NULL);
- if (!sdi) {
- sr_err("Failed to create device instance.");
- goto err_close_ftdic;
- }
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INITIALIZING;
+ sdi->vendor = g_strdup(USB_VENDOR_NAME);
+ sdi->model = g_strdup(USB_MODEL_NAME);
sdi->driver = di;
sdi->priv = devc;
return devices;
-err_close_ftdic:
scanaplus_close(devc);
err_free_ftdic:
ftdi_free(devc->ftdic); /* NOT free() or g_free()! */
for (l = usb_devices; l; l = l->next) {
if (scan_kecheng(l->data, &model) != SR_OK)
continue;
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, VENDOR,
- model, NULL)))
- return NULL;
- g_free(model);
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup(VENDOR);
+ sdi->model = model; /* Already g_strndup()'d. */
sdi->driver = di;
sdi->inst_type = SR_INST_USB;
sdi->conn = l->data;
return NULL;
}
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, LASCAR_VENDOR,
- profile->modelname, firmware)))
- return NULL;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup(LASCAR_VENDOR);
+ sdi->model = g_strdup(profile->modelname);
+ sdi->version = g_strdup(firmware);
sdi->driver = di;
if (profile->logformat == LOG_TEMP_RH) {
}
/* Init device instance, etc. */
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, "Manson",
- models[model_id].name, NULL))) {
- sr_err("Failed to create device instance.");
- return NULL;
- }
-
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup("Manson");
+ sdi->model = g_strdup(models[model_id].name);
sdi->inst_type = SR_INST_SERIAL;
sdi->conn = serial;
sdi->driver = di;
sr_info("Found device on port %s.", conn);
/* TODO: Fill in version from protocol response. */
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, mic_devs[idx].vendor,
- mic_devs[idx].device, NULL)))
- goto scan_cleanup;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup(mic_devs[idx].vendor);
+ sdi->model = g_strdup(mic_devs[idx].device);
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
sr_err("Device context malloc failed.");
GSList *devices;
const char *conn, *serialcomm;
int cnt;
- gchar buf[LINELEN_MAX];
+ gchar buf[LINELEN_MAX];
gchar channel[10];
- char* verstr;
+ char *verstr;
sdi = NULL;
devc = NULL;
Therefore just print an error message, but do not exit with error. */
sr_err("Failed to query for hardware version: %d %s", errno, strerror(errno));
- sdi = sr_dev_inst_new(SR_ST_INACTIVE, VENDOR_MOTECH, models[modelid].modelstr, verstr);
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup(VENDOR_MOTECH);
+ sdi->model = g_strdup(models[modelid].modelstr);
+ sdi->version = g_strdup(verstr);
sdi->driver = drv;
sdi->inst_type = SR_INST_SERIAL;
sdi->conn = serial;
auxtype = xgittoint(buf[7]);
sr_spew("%s %s DMM %s detected!", get_brandstr(drv), get_typestr(auxtype, drv), buf + 9);
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE,
- get_brandstr(drv), get_typestr(auxtype, drv), buf + 9)))
- return NULL;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup(get_brandstr(drv));
+ sdi->model = g_strdup(get_typestr(auxtype, drv));
+ sdi->version = g_strdup(buf + 9);
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
sr_err("Device context malloc failed.");
return NULL;
} else {
/* Not an OLS -- some other board that uses the sump protocol. */
sr_info("Device does not support metadata.");
- sdi = sr_dev_inst_new(SR_ST_INACTIVE,
- "Sump", "Logic Analyzer", "v1.0");
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup("Sump");
+ sdi->model = g_strdup("Logic Analyzer");
+ sdi->version = g_strdup("v1.0");
sdi->driver = di;
for (i = 0; i < 32; i++) {
if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
GString *tmp_str, *devname, *version;
guchar tmp_c;
- sdi = sr_dev_inst_new(SR_ST_INACTIVE, NULL, NULL, NULL);
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
sdi->driver = di;
devc = ols_dev_new();
sdi->priv = devc;
guchar tmp_c;
int index, i;
- sdi = sr_dev_inst_new(SR_ST_INACTIVE, NULL, NULL, NULL);
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
sdi->driver = di;
sdi->priv = devc;
}
}
- if (!model || !(sdi = sr_dev_inst_new(SR_ST_ACTIVE,
- model->series->vendor->name,
- model->name,
- hw_info->firmware_version))) {
+ if (!model) {
sr_scpi_hw_info_free(hw_info);
return NULL;
}
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_ACTIVE;
+ sdi->vendor = g_strdup(model->series->vendor->name);
+ sdi->model = g_strdup(model->name);
+ sdi->version = g_strdup(hw_info->firmware_version);
sdi->conn = scpi;
sdi->driver = di;
sdi->inst_type = SR_INST_SCPI;
if (des.idVendor != LOGIC16_VID || des.idProduct != LOGIC16_PID)
continue;
- sdi = sr_dev_inst_new(SR_ST_INITIALIZING,
- "Saleae", "Logic16", NULL);
- if (!sdi)
- return NULL;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INITIALIZING;
+ sdi->vendor = g_strdup("Saleae");
+ sdi->model = g_strdup("Logic16");
sdi->driver = di;
sdi->connection_id = g_strdup(connection_id);
return NULL;
}
- sdi = sr_dev_inst_new(SR_ST_ACTIVE, vendor, hw_info->model,
- hw_info->firmware_version);
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_ACTIVE;
+ sdi->vendor = g_strdup(vendor);
+ sdi->model = g_strdup(hw_info->model);
+ sdi->version = g_strdup(hw_info->firmware_version);
sdi->conn = scpi;
sdi->driver = di;
sdi->inst_type = SR_INST_SCPI;
sr_info("Found device on port %s.", conn);
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, dmms[dmm].vendor,
- dmms[dmm].device, NULL)))
- goto scan_cleanup;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup(dmms[dmm].vendor);
+ sdi->model = g_strdup(dmms[dmm].device);
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
sr_err("Device context malloc failed.");
return list;
}
-static struct sr_dev_inst *dev_inst_new()
+static struct sr_dev_inst *dev_inst_new(void)
{
struct sr_dev_inst *sdi;
struct dev_context *devc;
}
/* Register the device with libsigrok. */
- sdi = sr_dev_inst_new(SR_ST_INACTIVE,
- VENDOR_NAME, MODEL_NAME, NULL);
- if (!sdi) {
- sr_err("Failed to instantiate device.");
- g_free(devc);
- return NULL;
- }
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup(VENDOR_NAME);
+ sdi->model = g_strdup(MODEL_NAME);
/* Enable all channels to match the default channel configuration. */
devc->channel_mask = ALL_CHANNELS_MASK;
sr_info("Found device on port %s.", conn);
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, "EDF", "Teleinfo", NULL)))
- goto scan_cleanup;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup("EDF");
+ sdi->model = g_strdup("Teleinfo");
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
sr_err("Device context malloc failed.");
if (strcmp(product, "testo 435/635/735"))
continue;
- sdi = sr_dev_inst_new(SR_ST_INACTIVE, "Testo",
- "435/635/735", NULL);
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup("Testo");
+ sdi->model = g_strdup("435/635/735");
sdi->driver = di;
sdi->inst_type = SR_INST_USB;
sdi->conn = sr_usb_dev_inst_new(libusb_get_bus_number(devlist[i]),
if (!serialcomm)
serialcomm = SERIALCOMM;
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, "Tondaj",
- "SL-814", NULL))) {
- sr_err("Failed to create device instance.");
- return NULL;
- }
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup("Tondaj");
+ sdi->model = g_strdup("SL-814");
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
sr_err("Device context malloc failed.");
devc->first_run = TRUE;
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE,
- udmms[dmm].vendor, udmms[dmm].device, NULL))) {
- sr_err("sr_dev_inst_new returned NULL.");
- return NULL;
- }
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup(udmms[dmm].vendor);
+ sdi->model = g_strdup(udmms[dmm].device);
sdi->priv = devc;
sdi->driver = udmms[dmm].di;
if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
/* We have a list of sr_usb_dev_inst matching the connection
* string. Wrap them in sr_dev_inst and we're done. */
for (l = usb_devices; l; l = l->next) {
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, VENDOR,
- MODEL, NULL)))
- return NULL;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup(VENDOR);
+ sdi->model = g_strdup(MODEL);
sdi->driver = di;
sdi->inst_type = SR_INST_USB;
sdi->conn = l->data;
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE,
- VICTOR_VENDOR, NULL, NULL)))
- return NULL;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup(VICTOR_VENDOR);
sdi->driver = di;
sdi->connection_id = g_strdup(connection_id);
if (dlm_model_get(hw_info->model, &model_name, &model_index) != SR_OK)
goto fail;
- if (!(sdi = sr_dev_inst_new(SR_ST_ACTIVE, MANUFACTURER_NAME,
- model_name, hw_info->firmware_version)))
- goto fail;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_ACTIVE;
+ sdi->vendor = g_strdup(MANUFACTURER_NAME);
+ sdi->model = g_strdup(model_name);
+ sdi->version = g_strdup(hw_info->firmware_version);
sdi->serial_num = g_strdup(hw_info->serial_number);
sr_info("Found ZEROPLUS %s.", prof->model_name);
/* Register the device with libsigrok. */
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE,
- VENDOR_NAME, prof->model_name, NULL))) {
- sr_err("%s: sr_dev_inst_new failed", __func__);
- return NULL;
- }
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup(VENDOR_NAME);
+ sdi->model = g_strdup(prof->model_name);
sdi->driver = di;
sdi->serial_num = g_strdup(serial_num);
sdi->connection_id = g_strdup(connection_id);
return SR_ERR_ARG;
}
- in->sdi = sr_dev_inst_new(SR_ST_ACTIVE, NULL, NULL, NULL);
+ in->sdi = sr_dev_inst_new();
in->priv = inc = g_malloc0(sizeof(struct context));
inc->samplerate = g_variant_get_uint64(g_hash_table_lookup(options, "samplerate"));
return SR_ERR_ARG;
}
- in->sdi = sr_dev_inst_new(SR_ST_ACTIVE, NULL, NULL, NULL);
+ in->sdi = sr_dev_inst_new();
in->priv = inc = g_malloc0(sizeof(struct context));
inc->samplerate = g_variant_get_uint64(g_hash_table_lookup(options, "samplerate"));
struct context *inc;
const char *s;
- in->sdi = sr_dev_inst_new(SR_ST_ACTIVE, NULL, NULL, NULL);
+ in->sdi = sr_dev_inst_new();
in->priv = inc = g_malloc0(sizeof(struct context));
inc->single_column = g_variant_get_int32(g_hash_table_lookup(options, "single-column"));
inc->skip = g_variant_get_int32(g_hash_table_lookup(options, "skip"));
inc->skip /= inc->downsample;
- in->sdi = sr_dev_inst_new(SR_ST_ACTIVE, NULL, NULL, NULL);
+ in->sdi = sr_dev_inst_new();
in->priv = inc;
for (i = 0; i < num_channels; i++) {
{
(void)options;
- in->sdi = sr_dev_inst_new(SR_ST_ACTIVE, NULL, NULL, NULL);
+ in->sdi = sr_dev_inst_new();
in->priv = g_malloc0(sizeof(struct context));
return SR_OK;
sr_info("Found device on port %s.", serial->port);
- if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, vendor, model, NULL)))
- goto scan_cleanup;
+ sdi = sr_dev_inst_new();
+ sdi->status = SR_ST_INACTIVE;
+ sdi->vendor = g_strdup(vendor);
+ sdi->model = g_strdup(model);
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
sr_err("Device context malloc failed.");
};
/* Generic device instances */
-SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int status,
- const char *vendor, const char *model, const char *version);
+SR_PRIV struct sr_dev_inst *sr_dev_inst_new(void);
SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi);
#ifdef HAVE_LIBUSB_1_0
for (j = 0; keys[j]; j++) {
val = g_key_file_get_string(kf, sections[i], keys[j], NULL);
if (!strcmp(keys[j], "capturefile")) {
- sdi = sr_dev_inst_new(SR_ST_ACTIVE, NULL, NULL, NULL);
+ sdi = sr_dev_inst_new();
sdi->driver = &session_driver;
+ sdi->status = SR_ST_ACTIVE;
if (!session_driver_initialized) {
/* first device, init the driver */
session_driver_initialized = 1;