X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fdevice.c;h=dd34f79600dd4fe81797fad4b4b9a8cc3db46196;hb=1e7659609bddd40471faf9a8e81ee7554d77dce9;hp=fe3e231616e67c13989be8340cb74dcddd7195ae;hpb=c1aae90038456a61d0f9313d34e6107c3440d3e7;p=libsigrok.git diff --git a/src/device.c b/src/device.c index fe3e2316..dd34f796 100644 --- a/src/device.c +++ b/src/device.c @@ -133,6 +133,25 @@ SR_API int sr_dev_channel_enable(struct sr_channel *channel, return SR_OK; } +/* Returns the next enabled channel, wrapping around if necessary. */ +SR_PRIV struct sr_channel *sr_next_enabled_channel(const struct sr_dev_inst *sdi, + struct sr_channel *cur_channel) +{ + struct sr_channel *next_channel; + GSList *l; + + next_channel = cur_channel; + do { + l = g_slist_find(sdi->channels, next_channel); + if (l && l->next) + next_channel = l->next->data; + else + next_channel = sdi->channels->data; + } while (!next_channel->enabled); + + return next_channel; +} + /** * Determine whether the specified device instance has the specified * capability.