Skip to content

Commit

Permalink
Use cached context version if available
Browse files Browse the repository at this point in the history
If the backend initialized the private iio_context fields .major, .minor
and .git_tag, use them instead of issuing a call to the backend's
.get_version() callback.

Signed-off-by: Paul Cercueil <[email protected]>
  • Loading branch information
pcercuei committed Jul 12, 2021
1 parent 47982e5 commit 3260cc8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions context.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,17 @@ int iio_context_init(struct iio_context *ctx)
int iio_context_get_version(const struct iio_context *ctx,
unsigned int *major, unsigned int *minor, char git_tag[8])
{
if (ctx->git_tag) {
if (major)
*major = ctx->major;
if (minor)
*minor = ctx->minor;
if (git_tag)
iio_strlcpy(git_tag, ctx->git_tag, 8);

return 0;
}

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

Expand Down

0 comments on commit 3260cc8

Please sign in to comment.