sr: Fix some TODOs, improve comments/docs.
This commit is contained in:
parent
b5118d6c01
commit
0abee5076f
|
@ -96,8 +96,7 @@ SR_API int sr_datastore_destroy(struct sr_datastore *ds)
|
|||
g_free(chunk->data);
|
||||
g_slist_free(ds->chunklist);
|
||||
g_free(ds);
|
||||
|
||||
/* TODO: Set ds = NULL? */
|
||||
ds = NULL;
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
|
4
device.c
4
device.c
|
@ -55,7 +55,7 @@ static GSList *devs = NULL;
|
|||
* 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)
|
||||
{
|
||||
|
@ -65,7 +65,7 @@ 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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -137,12 +137,12 @@ static int hw_dev_close(int dev_index)
|
|||
|
||||
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_*?
|
||||
|
|
|
@ -711,12 +711,12 @@ static int hw_dev_close(int dev_index)
|
|||
|
||||
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 */
|
||||
|
|
|
@ -551,12 +551,12 @@ static int hw_dev_open(int dev_index)
|
|||
|
||||
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,
|
||||
|
@ -633,12 +633,12 @@ static int hw_dev_close(int dev_index)
|
|||
|
||||
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.");
|
||||
|
@ -767,12 +767,12 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
|
|||
|
||||
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);
|
||||
|
@ -1021,17 +1021,17 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
|
|||
|
||||
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);
|
||||
|
|
|
@ -190,7 +190,7 @@ SR_PRIV void serial_restore_params(int fd, void *backup)
|
|||
* 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
|
||||
|
@ -201,8 +201,7 @@ SR_PRIV int serial_set_params(int fd, int speed, int bits, int parity,
|
|||
return SR_ERR;
|
||||
}
|
||||
|
||||
/* TODO: Rename 'speed' to 'baudrate'. */
|
||||
switch(speed) {
|
||||
switch (baudrate) {
|
||||
/* TODO: Support for higher baud rates. */
|
||||
case 115200:
|
||||
dcb.BaudRate = CBR_115200;
|
||||
|
@ -235,7 +234,7 @@ SR_PRIV int serial_set_params(int fd, int speed, int bits, int parity,
|
|||
struct termios term;
|
||||
speed_t baud;
|
||||
|
||||
switch (speed) {
|
||||
switch (baudrate) {
|
||||
case 9600:
|
||||
baud = B9600;
|
||||
break;
|
||||
|
|
|
@ -314,7 +314,8 @@ static void samples_generator(uint8_t *buf, uint64_t size, void *data)
|
|||
memset(buf, 0xff, size);
|
||||
break;
|
||||
default:
|
||||
/* TODO: Error handling. */
|
||||
sr_err("demo: %s: unknown pattern %d", __func__,
|
||||
mydata->sample_generator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -377,7 +377,7 @@ static int hw_dev_close(int dev_index)
|
|||
|
||||
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 */
|
||||
|
|
|
@ -593,7 +593,7 @@ static int hw_dev_close(int dev_index)
|
|||
|
||||
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 */
|
||||
|
|
|
@ -507,7 +507,7 @@ static int hw_dev_close(int dev_index)
|
|||
|
||||
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;
|
||||
|
|
|
@ -460,7 +460,7 @@ static int hw_dev_close(int dev_index)
|
|||
|
||||
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 */
|
||||
|
|
18
session.c
18
session.c
|
@ -140,7 +140,7 @@ SR_API int sr_session_dev_add(struct sr_dev *dev)
|
|||
|
||||
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) {
|
||||
|
@ -175,6 +175,7 @@ SR_API int sr_session_datafeed_callback_clear(void)
|
|||
* 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.
|
||||
*/
|
||||
|
@ -185,7 +186,10 @@ SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback_t cb)
|
|||
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);
|
||||
|
@ -259,14 +263,14 @@ SR_API int sr_session_start(void)
|
|||
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? */
|
||||
|
@ -463,8 +467,8 @@ SR_PRIV int sr_session_send(struct sr_dev *dev,
|
|||
* @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.
|
||||
|
@ -526,7 +530,7 @@ SR_API int sr_session_source_remove(int fd)
|
|||
|
||||
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. */
|
||||
|
|
|
@ -157,7 +157,6 @@ static int hw_init(const char *devinfo)
|
|||
|
||||
/**
|
||||
* TODO.
|
||||
*
|
||||
*/
|
||||
static int hw_cleanup(void)
|
||||
{
|
||||
|
|
|
@ -105,7 +105,7 @@ SR_PRIV int serial_write(int fd, const void *buf, size_t count);
|
|||
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 -----------------------------------------------*/
|
||||
|
|
Loading…
Reference in New Issue