From 04dd17822334871b23ea2862f7798fb0e0007777 Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Sat, 11 May 2024 08:53:19 +0000 Subject: [PATCH] change otg to host mode --- kernel/tools/power/cpupower/lib/cpufreq.c | 78 ++++++++++++++++++++++++++++++++++---- 1 files changed, 69 insertions(+), 9 deletions(-) diff --git a/kernel/tools/power/cpupower/lib/cpufreq.c b/kernel/tools/power/cpupower/lib/cpufreq.c index 0c0f3e3..c3b56db 100644 --- a/kernel/tools/power/cpupower/lib/cpufreq.c +++ b/kernel/tools/power/cpupower/lib/cpufreq.c @@ -1,7 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * (C) 2004-2009 Dominik Brodowski <linux@dominikbrodowski.de> - * - * Licensed under the terms of the GNU GPL License version 2. */ @@ -286,7 +285,7 @@ } else { first = malloc(sizeof(*first)); if (!first) - goto error_out; + return NULL; current = first; } current->first = first; @@ -344,7 +343,7 @@ unsigned int len; len = sysfs_cpufreq_read_file(cpu, "scaling_available_frequencies", - linebuf, sizeof(linebuf)); + linebuf, sizeof(linebuf)); if (len == 0) return NULL; @@ -363,7 +362,7 @@ } else { first = malloc(sizeof(*first)); if (!first) - goto error_out; + return NULL; current = first; } current->first = first; @@ -389,8 +388,64 @@ return NULL; } -void cpufreq_put_available_frequencies(struct cpufreq_available_frequencies - *any) { +struct cpufreq_available_frequencies +*cpufreq_get_boost_frequencies(unsigned int cpu) +{ + struct cpufreq_available_frequencies *first = NULL; + struct cpufreq_available_frequencies *current = NULL; + char one_value[SYSFS_PATH_MAX]; + char linebuf[MAX_LINE_LEN]; + unsigned int pos, i; + unsigned int len; + + len = sysfs_cpufreq_read_file(cpu, "scaling_boost_frequencies", + linebuf, sizeof(linebuf)); + if (len == 0) + return NULL; + + pos = 0; + for (i = 0; i < len; i++) { + if (linebuf[i] == ' ' || linebuf[i] == '\n') { + if (i - pos < 2) + continue; + if (i - pos >= SYSFS_PATH_MAX) + goto error_out; + if (current) { + current->next = malloc(sizeof(*current)); + if (!current->next) + goto error_out; + current = current->next; + } else { + first = malloc(sizeof(*first)); + if (!first) + return NULL; + current = first; + } + current->first = first; + current->next = NULL; + + memcpy(one_value, linebuf + pos, i - pos); + one_value[i - pos] = '\0'; + if (sscanf(one_value, "%lu", ¤t->frequency) != 1) + goto error_out; + + pos = i + 1; + } + } + + return first; + + error_out: + while (first) { + current = first->next; + free(first); + first = current; + } + return NULL; +} + +void cpufreq_put_available_frequencies(struct cpufreq_available_frequencies *any) +{ struct cpufreq_available_frequencies *tmp, *next; if (!any) @@ -402,6 +457,11 @@ free(tmp); tmp = next; } +} + +void cpufreq_put_boost_frequencies(struct cpufreq_available_frequencies *any) +{ + cpufreq_put_available_frequencies(any); } static struct cpufreq_affected_cpus *sysfs_get_cpu_list(unsigned int cpu, @@ -433,7 +493,7 @@ } else { first = malloc(sizeof(*first)); if (!first) - goto error_out; + return NULL; current = first; } current->first = first; @@ -666,7 +726,7 @@ } else { first = malloc(sizeof(*first)); if (!first) - goto error_out; + return NULL; current = first; } current->first = first; -- Gitblit v1.6.2