| 988 | } |
| 989 | |
| 990 | static int |
| 991 | cpufreq_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 | |
| 1026 | out: |
| 1027 | sbuf_delete(&sb); |
| 1028 | return (error); |
| 1029 | } |
| 1030 | |
| 1031 | static int |
| 1032 | cpufreq_settings_sysctl(SYSCTL_HANDLER_ARGS) |
nothing calls this directly
no test coverage detected