- device_new(plugin, i, num_probes, probe_type);
+/**
+ * Set the name of the specified channel in the specified device.
+ *
+ * If the channel already has a different name assigned to it, it will be
+ * removed, and the new name will be saved instead.
+ *
+ * @param sdi The device instance the channel is connected to.
+ * @param[in] channelnum The number of the channel whose name to set.
+ * Note that the channel numbers start at 0.
+ * @param[in] name The new name that the specified channel should get. A copy
+ * of the string is made.
+ *
+ * @return SR_OK on success, or SR_ERR_ARG on invalid arguments.
+ *
+ * @since 0.3.0
+ */
+SR_API int sr_dev_channel_name_set(const struct sr_dev_inst *sdi,
+ int channelnum, const char *name)
+{
+ GSList *l;
+ struct sr_channel *ch;
+ int ret;
+
+ if (!sdi) {
+ sr_err("%s: sdi was NULL", __func__);
+ return SR_ERR_ARG;
+ }
+
+ ret = SR_ERR_ARG;
+ for (l = sdi->channels; l; l = l->next) {
+ ch = l->data;
+ if (ch->index == channelnum) {
+ g_free(ch->name);
+ ch->name = g_strdup(name);
+ ret = SR_OK;
+ break;