Commit f82525e6 authored by Uwe Hermann's avatar Uwe Hermann

beaglelogic: Minor whitespace and consistency fixes.

parent 00f2e9bc
......@@ -93,7 +93,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
}
/* Probe for /dev/beaglelogic if not connecting via TCP */
if (conn == NULL) {
if (!conn) {
if (!g_file_test(BEAGLELOGIC_DEV_NODE, G_FILE_TEST_EXISTS))
return NULL;
} else {
......@@ -110,10 +110,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
}
}
if (maxch > 8)
maxch = NUM_CHANNELS;
else
maxch = 8;
maxch = (maxch > 8) ? NUM_CHANNELS : 8;
sdi = g_new0(struct sr_dev_inst, 1);
sdi->status = SR_ST_INACTIVE;
......@@ -122,7 +119,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
devc = beaglelogic_devc_alloc();
if (conn == NULL) {
if (!conn) {
devc->beaglelogic = &beaglelogic_native_ops;
sr_info("BeagleLogic device found at "BEAGLELOGIC_DEV_NODE);
} else {
......@@ -141,6 +138,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
sr_info("BeagleLogic device found at %s : %s",
devc->address, devc->port);
}
/* Fill the channels */
for (i = 0; i < maxch; i++)
sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
......@@ -149,6 +147,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
sdi->priv = devc;
return std_scan_complete(di, g_slist_append(NULL, sdi));
err_free:
g_free(sdi->model);
g_free(sdi->version);
......@@ -337,9 +336,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
devc->beaglelogic->set_sampleunit(devc);
/* If continuous sampling, set the limit_samples to max possible value */
if (devc->triggerflags == BL_TRIGGERFLAGS_CONTINUOUS) {
if (devc->triggerflags == BL_TRIGGERFLAGS_CONTINUOUS)
devc->limit_samples = (uint64_t)-1;
}
/* Configure triggers & send header packet */
if ((trigger = sr_session_trigger_get(sdi->session))) {
......
......@@ -23,7 +23,8 @@
static int beaglelogic_open_nonblock(struct dev_context *devc)
{
devc->fd = open(BEAGLELOGIC_DEV_NODE, O_RDONLY | O_NONBLOCK);
return (devc->fd == -1 ? SR_ERR : SR_OK);
return ((devc->fd == -1) ? SR_ERR : SR_OK);
}
static int beaglelogic_close(struct dev_context *devc)
......@@ -45,8 +46,10 @@ static int beaglelogic_set_buffersize(struct dev_context *devc)
static int beaglelogic_get_samplerate(struct dev_context *devc)
{
uint32_t arg, err;
err = ioctl(devc->fd, IOCTL_BL_GET_SAMPLE_RATE, &arg);
devc->cur_samplerate = arg;
return err;
}
......@@ -120,7 +123,8 @@ static int beaglelogic_mmap(struct dev_context *devc)
beaglelogic_get_buffersize(devc);
devc->sample_buf = mmap(NULL, devc->buffersize,
PROT_READ, MAP_SHARED, devc->fd, 0);
return (devc->sample_buf == MAP_FAILED ? -1 : SR_OK);
return ((devc->sample_buf == MAP_FAILED) ? -1 : SR_OK);
}
static int beaglelogic_munmap(struct dev_context *devc)
......
......@@ -116,6 +116,7 @@ static int beaglelogic_tcp_send_cmd(struct dev_context *devc,
}
sr_spew("Sent command: '%s'.", buf);
g_free(buf);
return SR_OK;
......@@ -152,14 +153,14 @@ SR_PRIV int beaglelogic_tcp_drain(struct dev_context *devc)
do {
ret = select(devc->socket + 1, &rset, NULL, NULL, &tv);
if (ret > 0) {
if (ret > 0)
len += beaglelogic_tcp_read_data(devc, buf, 1024);
}
} while (ret > 0);
sr_spew("Drained %d bytes of data.", len);
g_free(buf);
return SR_OK;
}
......@@ -171,9 +172,8 @@ static int beaglelogic_tcp_get_string(struct dev_context *devc, const char *cmd,
gint64 timeout;
if (cmd) {
if (beaglelogic_tcp_send_cmd(devc, cmd) != SR_OK) {
if (beaglelogic_tcp_send_cmd(devc, cmd) != SR_OK)
return SR_ERR;
}
}
timeout = g_get_monotonic_time() + devc->read_timeout;
......@@ -185,9 +185,8 @@ static int beaglelogic_tcp_get_string(struct dev_context *devc, const char *cmd,
return SR_ERR;
}
if (len > 0) {
if (len > 0)
g_string_set_size(response, len);
}
if (g_get_monotonic_time() > timeout) {
sr_err("Timed out waiting for response.");
......@@ -207,6 +206,7 @@ static int beaglelogic_tcp_get_string(struct dev_context *devc, const char *cmd,
response->str, response->len);
*tcp_resp = g_string_free(response, FALSE);
return SR_OK;
}
......@@ -242,6 +242,7 @@ SR_PRIV int beaglelogic_tcp_detect(struct dev_context *devc)
ret = SR_ERR;
g_free(resp);
return ret;
}
......@@ -277,14 +278,17 @@ static int beaglelogic_set_buffersize(struct dev_context *devc)
ret = SR_ERR;
g_free(resp);
return ret;
}
static int beaglelogic_get_samplerate(struct dev_context *devc)
{
int arg, err;
err = beaglelogic_tcp_get_int(devc, "samplerate", &arg);
devc->cur_samplerate = arg;
return err;
}
......@@ -302,6 +306,7 @@ static int beaglelogic_set_samplerate(struct dev_context *devc)
ret = SR_ERR;
g_free(resp);
return ret;
}
......@@ -324,6 +329,7 @@ static int beaglelogic_set_sampleunit(struct dev_context *devc)
ret = SR_ERR;
g_free(resp);
return ret;
}
......@@ -346,18 +352,21 @@ static int beaglelogic_set_triggerflags(struct dev_context *devc)
ret = SR_ERR;
g_free(resp);
return ret;
}
static int beaglelogic_get_lasterror(struct dev_context *devc)
{
devc->last_error = 0;
return SR_OK;
}
static int beaglelogic_start(struct dev_context *devc)
{
beaglelogic_tcp_drain(devc);
return beaglelogic_tcp_send_cmd(devc, "get");
}
......@@ -385,12 +394,14 @@ static int beaglelogic_set_bufunitsize(struct dev_context *devc)
ret = SR_ERR;
g_free(resp);
return ret;
}
static int dummy(struct dev_context *devc)
{
(void)devc;
return SR_ERR_NA;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment