Skip to content

Commit

Permalink
serial: hook serial_get_description() routine to backend ops
Browse files Browse the repository at this point in the history
The serial_get_description() function has been created with the idea of
hooking it into the backend ops.
This change does that, with a bit of polishing.
It's also needed inside serial_create_context().

Signed-off-by: Alexandru Ardelean <[email protected]>
  • Loading branch information
commodo committed Oct 15, 2020
1 parent 134567b commit a59a233
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static int serial_get_version(const struct iio_context *ctx,
major, minor, git_tag);
}

static char * serial_get_description(struct sp_port *port)
static char * __serial_get_description(struct sp_port *port)
{
char *description, *name, *desc;
size_t desc_len;
Expand All @@ -135,6 +135,13 @@ static char * serial_get_description(struct sp_port *port)
return description;
}

static char * serial_get_description(const struct iio_context *ctx)
{
struct iio_context_pdata *pdata = iio_context_get_pdata(ctx);

return __serial_get_description(pdata->port);
}

static int serial_open(const struct iio_device *dev,
size_t samples_count, bool cyclic)
{
Expand Down Expand Up @@ -347,6 +354,7 @@ static const struct iio_backend_ops serial_ops = {
.write_channel_attr = serial_write_chn_attr,
.set_kernel_buffers_count = serial_set_kernel_buffers_count,
.shutdown = serial_shutdown,
.get_description = serial_get_description,
.set_timeout = serial_set_timeout,
};

Expand Down Expand Up @@ -422,7 +430,7 @@ static struct iio_context * serial_create_context(const char *port_name,
/* Empty the buffers */
sp_flush(port, SP_BUF_BOTH);

description = serial_get_description(port);
description = __serial_get_description(port);
if (!description)
goto err_close_port;

Expand Down

0 comments on commit a59a233

Please sign in to comment.