Skip to content

Commit

Permalink
backends: Remove .get_version() callbacks
Browse files Browse the repository at this point in the history
As the context's library version is now transfered as part of the XML
string, there is nothing to be done in the .get_version() backend
callbacks, and therefore these can be removed.

Signed-off-by: Paul Cercueil <[email protected]>
  • Loading branch information
pcercuei committed Jul 12, 2021
1 parent 3260cc8 commit 48e5852
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 93 deletions.
3 changes: 0 additions & 3 deletions context.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,6 @@ int iio_context_get_version(const struct iio_context *ctx,
return 0;
}

if (ctx->ops->get_version)
return ctx->ops->get_version(ctx, major, minor, git_tag);

iio_library_get_version(major, minor, git_tag);
return 0;
}
Expand Down
3 changes: 0 additions & 3 deletions iio-backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ struct iio_backend_ops {

char * (*get_description)(const struct iio_context *ctx);

int (*get_version)(const struct iio_context *ctx, unsigned int *major,
unsigned int *minor, char git_tag[8]);

int (*set_timeout)(struct iio_context *ctx, unsigned int timeout);
};

Expand Down
52 changes: 0 additions & 52 deletions iiod-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,58 +177,6 @@ void iiod_client_destroy(struct iiod_client *client)
free(client);
}

int iiod_client_get_version(struct iiod_client *client,
struct iiod_client_pdata *desc,
unsigned int *major, unsigned int *minor,
char *git_tag)
{
struct iio_context_pdata *pdata = client->pdata;
const struct iiod_client_ops *ops = client->ops;
char buf[256], *ptr = buf, *end;
long maj, min;
int ret;

iio_mutex_lock(client->lock);

ret = (int) ops->write(pdata, desc, "VERSION\r\n", sizeof("VERSION\r\n") - 1);
if (ret < 0) {
iio_mutex_unlock(client->lock);
return ret;
}

ret = (int) ops->read_line(pdata, desc, buf, sizeof(buf));
iio_mutex_unlock(client->lock);

if (ret < 0)
return ret;

errno = 0;
maj = strtol(ptr, &end, 10);
if (ptr == end || errno == ERANGE)
return -EIO;

ptr = end + 1;
errno = 0;
min = strtol(ptr, &end, 10);
if (ptr == end || errno == ERANGE)
return -EIO;

ptr = end + 1;
if (buf + ret < ptr + 8)
return -EIO;

/* Strip the \n */
ptr[buf + ret - ptr - 1] = '\0';

if (major)
*major = (unsigned int) maj;
if (minor)
*minor = (unsigned int) min;
if (git_tag)
iio_strlcpy(git_tag, ptr, 8);
return 0;
}

int iiod_client_get_trigger(struct iiod_client *client,
struct iiod_client_pdata *desc,
const struct iio_device *dev,
Expand Down
5 changes: 0 additions & 5 deletions iiod-client.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ struct iiod_client * iiod_client_new(struct iio_context_pdata *pdata,
const struct iiod_client_ops *ops);
void iiod_client_destroy(struct iiod_client *client);

int iiod_client_get_version(struct iiod_client *client,
struct iiod_client_pdata *desc,
unsigned int *major, unsigned int *minor,
char *git_tag);

int iiod_client_get_trigger(struct iiod_client *client,
struct iiod_client_pdata *desc,
const struct iio_device *dev,
Expand Down
10 changes: 0 additions & 10 deletions network.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,15 +856,6 @@ static void network_shutdown(struct iio_context *ctx)
freeaddrinfo(pdata->addrinfo);
}

static int network_get_version(const struct iio_context *ctx,
unsigned int *major, unsigned int *minor, char git_tag[8])
{
struct iio_context_pdata *pdata = iio_context_get_pdata(ctx);

return iiod_client_get_version(pdata->iiod_client,
&pdata->io_ctx, major, minor, git_tag);
}

static unsigned int calculate_remote_timeout(unsigned int timeout)
{
/* XXX(pcercuei): We currently hardcode timeout / 2 for the backend used
Expand Down Expand Up @@ -927,7 +918,6 @@ static const struct iio_backend_ops network_ops = {
.set_trigger = network_set_trigger,
.shutdown = network_shutdown,
.get_description = network_get_description,
.get_version = network_get_version,
.set_timeout = network_set_timeout,
.set_kernel_buffers_count = network_set_kernel_buffers_count,

Expand Down
10 changes: 0 additions & 10 deletions serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,6 @@ static inline int libserialport_to_errno(enum sp_return ret)
}
}

static int serial_get_version(const struct iio_context *ctx,
unsigned int *major, unsigned int *minor, char git_tag[8])
{
struct iio_context_pdata *pdata = iio_context_get_pdata(ctx);

return iiod_client_get_version(pdata->iiod_client, NULL,
major, minor, git_tag);
}

static char * __serial_get_description(struct sp_port *port)
{
char *description, *name, *desc;
Expand Down Expand Up @@ -356,7 +347,6 @@ static int serial_set_timeout(struct iio_context *ctx, unsigned int timeout)
}

static const struct iio_backend_ops serial_ops = {
.get_version = serial_get_version,
.open = serial_open,
.close = serial_close,
.read = serial_read,
Expand Down
10 changes: 0 additions & 10 deletions usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,6 @@ static void usb_io_context_exit(struct iiod_client_pdata *io_ctx)
}
}

static int usb_get_version(const struct iio_context *ctx,
unsigned int *major, unsigned int *minor, char git_tag[8])
{
struct iio_context_pdata *pdata = iio_context_get_pdata(ctx);

return iiod_client_get_version(pdata->iiod_client,
&pdata->io_ctx, major, minor, git_tag);
}

static unsigned int usb_calculate_remote_timeout(unsigned int timeout)
{
/* XXX(pcercuei): We currently hardcode timeout / 2 for the backend used
Expand Down Expand Up @@ -539,7 +530,6 @@ static void usb_cancel(const struct iio_device *dev)
}

static const struct iio_backend_ops usb_ops = {
.get_version = usb_get_version,
.open = usb_open,
.close = usb_close,
.read = usb_read,
Expand Down

0 comments on commit 48e5852

Please sign in to comment.