+ free_short_chan_name:
+ free(ch_name);
+
+ end:
+ return retval;
+}
+
+/* Return the power of two which is equal or higher to v */
+
+static unsigned int pow2_higher_or_eq(unsigned int v)
+{
+ int hb = fls(v);
+ int retval = 1<<(hb-1);
+
+ if(v-retval == 0)
+ return retval;
+ else
+ return retval<<1;
+}
+
+static int do_cmd_set_subbuf_size(const char *recvbuf, struct ustcomm_source *src)
+{
+ char *channel_slash_size;
+ char ch_name[256]="";
+ unsigned int size, power;
+ int retval = 0;
+ struct ust_trace *trace;
+ char trace_name[] = "auto";
+ int i;
+ int found = 0;
+
+ DBG("set_subbuf_size");
+
+ channel_slash_size = nth_token(recvbuf, 1);
+ sscanf(channel_slash_size, "%255[^/]/%u", ch_name, &size);
+
+ if(ch_name == NULL) {
+ ERR("cannot parse channel");
+ goto end;
+ }
+
+ power = pow2_higher_or_eq(size);
+ power = max_t(unsigned int, 2u, power);
+ if (power != size)
+ WARN("using the next power of two for buffer size = %u\n", power);
+
+ ltt_lock_traces();
+ trace = _ltt_trace_find_setup(trace_name);
+ if(trace == NULL) {
+ ERR("cannot find trace!");
+ retval = -1;
+ goto end;
+ }
+
+ for(i = 0; i < trace->nr_channels; i++) {
+ struct ust_channel *channel = &trace->channels[i];
+
+ if(!strcmp(trace->channels[i].channel_name, ch_name)) {
+
+ channel->subbuf_size = power;
+ DBG("the set_subbuf_size for the requested channel is %zd", channel->subbuf_size);
+
+ found = 1;
+ break;