g_free(chunk->data);
g_slist_free(ds->chunklist);
g_free(ds);
-
- /* TODO: Set ds = NULL? */
+ ds = NULL;
return SR_OK;
}
* TODO: Error checks?
* TODO: Option to only scan for specific devices or device classes.
*
- * @return SR_OK upon success, SR_ERR upon errors.
+ * @return SR_OK upon success, SR_ERR_BUG upon internal errors.
*/
SR_API int sr_dev_scan(void)
{
drivers = sr_driver_list();
if (!drivers[0]) {
sr_err("dev: %s: no supported hardware drivers", __func__);
- return SR_ERR; /* TODO: More specific error? */
+ return SR_ERR_BUG;
}
/*
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("alsa: %s: sdi was NULL", __func__);
- return SR_ERR; /* TODO: SR_ERR_ARG? */
+ return SR_ERR_BUG;
}
if (!(ctx = sdi->priv)) {
sr_err("alsa: %s: sdi->priv was NULL", __func__);
- return SR_ERR; /* TODO: SR_ERR_ARG? */
+ return SR_ERR_BUG;
}
// TODO: Return values of snd_*?
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("sigma: %s: sdi was NULL", __func__);
- return SR_ERR; /* TODO: SR_ERR_ARG? */
+ return SR_ERR_BUG;
}
if (!(ctx = sdi->priv)) {
sr_err("sigma: %s: sdi->priv was NULL", __func__);
- return SR_ERR; /* TODO: SR_ERR_ARG? */
+ return SR_ERR_BUG;
}
/* TODO */
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("la8: %s: sdi was NULL", __func__);
- return SR_ERR; /* TODO: SR_ERR_ARG? */
+ return SR_ERR_BUG;
}
if (!(ctx = sdi->priv)) {
sr_err("la8: %s: sdi->priv was NULL", __func__);
- return SR_ERR; /* TODO: SR_ERR_ARG? */
+ return SR_ERR_BUG;
}
sr_dbg("la8: Opening LA8 device (%04x:%04x).", USB_VENDOR_ID,
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("la8: %s: sdi was NULL", __func__);
- return SR_ERR; /* TODO: SR_ERR_ARG? */
+ return SR_ERR_BUG;
}
if (!(ctx = sdi->priv)) {
sr_err("la8: %s: sdi->priv was NULL", __func__);
- return SR_ERR; /* TODO: SR_ERR_ARG? */
+ return SR_ERR_BUG;
}
sr_dbg("la8: Closing device.");
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("la8: %s: sdi was NULL", __func__);
- return SR_ERR; /* TODO: SR_ERR_ARG? */
+ return SR_ERR_BUG;
}
if (!(ctx = sdi->priv)) {
sr_err("la8: %s: sdi->priv was NULL", __func__);
- return SR_ERR; /* TODO: SR_ERR_ARG? */
+ return SR_ERR_BUG;
}
sr_spew("la8: %s: dev_index %d, hwcap %d", __func__, dev_index, hwcap);
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("la8: %s: sdi was NULL", __func__);
- return SR_ERR; /* TODO: SR_ERR_ARG? */
+ return SR_ERR_BUG;
}
if (!(ctx = sdi->priv)) {
sr_err("la8: %s: sdi->priv was NULL", __func__);
- return SR_ERR; /* TODO: SR_ERR_ARG? */
+ return SR_ERR_BUG;
}
if (!ctx->ftdic) {
sr_err("la8: %s: ctx->ftdic was NULL", __func__);
- return SR_ERR_ARG;
+ return SR_ERR_BUG;
}
ctx->divcount = samplerate_to_divcount(ctx->cur_samplerate);
* flowcontrol: 1 = rts/cts, 2 = xon/xoff
* parity: 0 = none, 1 = even, 2 = odd
*/
-SR_PRIV int serial_set_params(int fd, int speed, int bits, int parity,
+SR_PRIV int serial_set_params(int fd, int baudrate, int bits, int parity,
int stopbits, int flowcontrol)
{
#ifdef _WIN32
return SR_ERR;
}
- /* TODO: Rename 'speed' to 'baudrate'. */
- switch(speed) {
+ switch (baudrate) {
/* TODO: Support for higher baud rates. */
case 115200:
dcb.BaudRate = CBR_115200;
struct termios term;
speed_t baud;
- switch (speed) {
+ switch (baudrate) {
case 9600:
baud = B9600;
break;
memset(buf, 0xff, size);
break;
default:
- /* TODO: Error handling. */
+ sr_err("demo: %s: unknown pattern %d", __func__,
+ mydata->sample_generator);
break;
}
}
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("fx2lafw: %s: sdi was NULL", __func__);
- return SR_ERR; /* TODO: SR_ERR_ARG? */
+ return SR_ERR_BUG;
}
/* TODO */
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("mso19: %s: sdi was NULL", __func__);
- return SR_ERR; /* TODO: SR_ERR_ARG? */
+ return SR_ERR_BUG;
}
/* TODO */
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("ols: %s: sdi was NULL", __func__);
- return SR_ERR; /* TODO: SR_ERR_ARG? */
+ return SR_ERR_BUG;
}
ctx = sdi->priv;
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
sr_err("logic: %s: sdi was NULL", __func__);
- return SR_ERR; /* TODO: SR_ERR_ARG? */
+ return SR_ERR_BUG;
}
/* TODO */
if (!session) {
sr_err("session: %s: session was NULL", __func__);
- return SR_ERR; /* TODO: SR_ERR_BUG? */
+ return SR_ERR_BUG;
}
if ((ret = dev->driver->dev_open(dev->driver_index)) != SR_OK) {
* Add a datafeed callback to the current session.
*
* @param cb Function to call when a chunk of data is received.
+ * Must not be NULL.
*
* @return SR_OK upon success, SR_ERR_BUG if no session exists.
*/
return SR_ERR_BUG;
}
- /* TODO: Is 'cb' allowed to be NULL? */
+ if (!cb) {
+ sr_err("session: %s: cb was NULL", __func__);
+ return SR_ERR_ARG;
+ }
session->datafeed_callbacks =
g_slist_append(session->datafeed_callbacks, cb);
if (!session) {
sr_err("session: %s: session was NULL; a session must be "
"created first, before starting it.", __func__);
- return SR_ERR; /* TODO: SR_ERR_BUG? */
+ return SR_ERR_BUG;
}
if (!session->devs) {
/* TODO: Actually the case? */
sr_err("session: %s: session->devs was NULL; a session "
"cannot be started without devices.", __func__);
- return SR_ERR; /* TODO: SR_ERR_BUG? */
+ return SR_ERR_BUG;
}
/* TODO: Check driver_index validity? */
* @param fd TODO.
* @param events TODO.
* @param timeout TODO.
- * @param cb TODO.
- * @param cb_data TODO.
+ * @param cb Callback function to add. Must not be NULL.
+ * @param cb_data Data for the callback function. Can be NULL.
*
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or
* SR_ERR_MALLOC upon memory allocation errors.
if (!sources) {
sr_err("session: %s: sources was NULL", __func__);
- return SR_ERR_BUG; /* TODO: Other? */
+ return SR_ERR_BUG;
}
/* TODO: Check if 'fd' valid. */
/**
* TODO.
- *
*/
static int hw_cleanup(void)
{
SR_PRIV int serial_read(int fd, void *buf, size_t count);
SR_PRIV void *serial_backup_params(int fd);
SR_PRIV void serial_restore_params(int fd, void *backup);
-SR_PRIV int serial_set_params(int fd, int speed, int bits, int parity,
+SR_PRIV int serial_set_params(int fd, int baudrate, int bits, int parity,
int stopbits, int flowcontrol);
/*--- hardware/common/ezusb.c -----------------------------------------------*/