MCPcopy Create free account
hub / github.com/F-Stack/f-stack / cpufreq_levels_sysctl

Function cpufreq_levels_sysctl

freebsd/kern/kern_cpu.c:990–1029  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

988}
989
990static int
991cpufreq_levels_sysctl(SYSCTL_HANDLER_ARGS)
992{
993 struct cpufreq_softc *sc;
994 struct cf_level *levels;
995 struct cf_setting *set;
996 struct sbuf sb;
997 int count, error, i;
998
999 sc = oidp->oid_arg1;
1000 sbuf_new(&sb, NULL, 128, SBUF_AUTOEXTEND);
1001
1002 /* Get settings from the device and generate the output string. */
1003 count = CF_MAX_LEVELS;
1004 levels = sc->levels_buf;
1005 if (levels == NULL) {
1006 sbuf_delete(&sb);
1007 return (ENOMEM);
1008 }
1009 error = CPUFREQ_LEVELS(sc->dev, levels, &count);
1010 if (error) {
1011 if (error == E2BIG)
1012 printf("cpufreq: need to increase CF_MAX_LEVELS\n");
1013 goto out;
1014 }
1015 if (count) {
1016 for (i = 0; i < count; i++) {
1017 set = &levels[i].total_set;
1018 sbuf_printf(&sb, "%d/%d ", set->freq, set->power);
1019 }
1020 } else
1021 sbuf_cpy(&sb, "0");
1022 sbuf_trim(&sb);
1023 sbuf_finish(&sb);
1024 error = sysctl_handle_string(oidp, sbuf_data(&sb), sbuf_len(&sb), req);
1025
1026out:
1027 sbuf_delete(&sb);
1028 return (error);
1029}
1030
1031static int
1032cpufreq_settings_sysctl(SYSCTL_HANDLER_ARGS)

Callers

nothing calls this directly

Calls 10

sbuf_newFunction · 0.85
sbuf_deleteFunction · 0.85
sbuf_printfFunction · 0.85
sbuf_cpyFunction · 0.85
sbuf_trimFunction · 0.85
sbuf_finishFunction · 0.85
sysctl_handle_stringFunction · 0.85
sbuf_dataFunction · 0.85
sbuf_lenFunction · 0.85
printfFunction · 0.70

Tested by

no test coverage detected