+#define MAX_BYTES 100
+
+static ssize_t show_thresholds(struct cpuquiet_attribute *attr, char *buf)
+{
+ char buffer[MAX_BYTES];
+ unsigned int i;
+ int size = 0;
+ buffer[0] = 0;
+ for_each_possible_cpu(i) {
+ if (i == ARRAY_SIZE(nr_run_thresholds) - 1)
+ break;
+ if (size >= sizeof(buffer))
+ break;
+ size += snprintf(buffer + size, sizeof(buffer) - size,
+ "%u->%u core threshold: %u\n",
+ i + 1, i + 2, nr_run_thresholds[i]);
+ }
+ return snprintf(buf, sizeof(buffer), "%s", buffer);
+}
+
+static ssize_t store_thresholds(struct cpuquiet_attribute *attr,
+ const char *buf, size_t count)
+{
+ int ret, i = 0;
+ char *val, *str, input[MAX_BYTES];
+ unsigned int thresholds[NR_CPUS];
+
+ if (!count || count >= MAX_BYTES)
+ return -EINVAL;
+ strncpy(input, buf, count);
+ input[count] = '\0';
+ str = input;
+ memcpy(thresholds, nr_run_thresholds, sizeof(nr_run_thresholds));
+ while ((val = strsep(&str, " ")) != NULL) {
+ if (*val == '\0')
+ continue;
+ if (i == ARRAY_SIZE(nr_run_thresholds) - 1)
+ break;
+ ret = kstrtouint(val, 10, &thresholds[i]);
+ if (ret)
+ return -EINVAL;
+ i++;
+ }
+
+ memcpy(nr_run_thresholds, thresholds, sizeof(thresholds));
+ return count;
+}
+