Skip to content

Commit

Permalink
cpufreq: format.sh cpufreq.c
Browse files Browse the repository at this point in the history
Signed-off-by: tiozhang <zyhtheonly@yeah.net>
  • Loading branch information
zzzyhtheonly committed Apr 20, 2023
1 parent df1e14c commit 9d0ca86
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,17 @@
#endif
#define MAX_AVAIL_FREQS "MaxAvailableFreqs"

static int max_avail_freqs = 20; // default MAX_AVAIL_FREQS
static int max_avail_freqs = 20; // default MAX_AVAIL_FREQS
static const char *config_keys[] = {MAX_AVAIL_FREQS};
static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);

static int cpufreq_config(char const *key, char const *value)
{
if (strcasecmp(key, "MaxAvailableFreqs") == 0)
{
static int cpufreq_config(char const *key, char const *value) {
if (strcasecmp(key, "MaxAvailableFreqs") == 0) {
int freqs = strtol(value, NULL, 0);
if (freqs == 0)
return -1;
max_avail_freqs = freqs;
}
else
} else
return -1;

return 0;
Expand All @@ -66,7 +63,8 @@ static void cpufreq_stats_init(void) {
if (cpu_data == NULL)
return;
for (int i = 0; i < num_cpu; i++) {
cpu_data[i].time_state = calloc(max_avail_freqs, sizeof(value_to_rate_state_t));
cpu_data[i].time_state =
calloc(max_avail_freqs, sizeof(value_to_rate_state_t));
if (cpu_data[i].time_state == NULL)
return;
}
Expand Down Expand Up @@ -273,6 +271,7 @@ static int cpufreq_read(void) {

void module_register(void) {
plugin_register_init("cpufreq", cpufreq_init);
plugin_register_config("cpufreq", cpufreq_config, config_keys, config_keys_num);
plugin_register_config("cpufreq", cpufreq_config, config_keys,
config_keys_num);
plugin_register_read("cpufreq", cpufreq_read);
}

0 comments on commit 9d0ca86

Please sign in to comment.