/*
- * This file is part of the sigrok project.
+ * This file is part of the libsigrok project.
*
* Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
* Copyright (C) 2011 Olivier Fauchon <olivier@aixmarseille.com>
sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, DEMONAME, NULL, NULL);
if (!sdi) {
- sr_err("%s: sr_dev_inst_new failed", __func__);
- return 0;
+ sr_err("Device instance creation failed.");
+ return NULL;
}
sdi->driver = di;
drvc->instances = g_slist_append(drvc->instances, sdi);
if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
- sr_err("%s: devc malloc failed", __func__);
- return SR_ERR_MALLOC;
+ sr_err("Device context malloc failed.");
+ return NULL;
}
devc->sdi = sdi;
{
(void)sdi;
- /* Nothing needed so far. */
+ sdi->status = SR_ST_ACTIVE;
return SR_OK;
}
{
(void)sdi;
- /* Nothing needed so far. */
+ sdi->status = SR_ST_INACTIVE;
return SR_OK;
}
}
break;
default:
- return SR_ERR_ARG;
+ return SR_ERR_NA;
}
return SR_OK;
struct dev_context *const devc = sdi->priv;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
if (id == SR_CONF_SAMPLERATE) {
devc->cur_samplerate = g_variant_get_uint64(data);
sr_dbg("%s: setting samplerate to %" PRIu64, __func__,
sr_dbg("%s: setting pattern to %d",
__func__, devc->sample_generator);
} else {
- ret = SR_ERR;
+ ret = SR_ERR_NA;
}
return ret;
*data = g_variant_new_strv(pattern_strings, ARRAY_SIZE(pattern_strings));
break;
default:
- return SR_ERR_ARG;
+ return SR_ERR_NA;
}
return SR_OK;
{
struct dev_context *const devc = sdi->priv;
+ if (sdi->status != SR_ST_ACTIVE)
+ return SR_ERR_DEV_CLOSED;
+
devc->cb_data = cb_data;
devc->samples_counter = 0;