xref: /linux/tools/power/cpupower/cpupower.sh (revision c89756bcf406af313d191cfe3709e7c175c5b0cd)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (C) 2012, Sébastien Luttringer
4# Copyright (C) 2024, Francesco Poli <invernomuto@paranoici.org>
5
6ESTATUS=0
7
8# apply CPU clock frequency options
9if test -n "$FREQ"
10then
11    cpupower frequency-set -f "$FREQ" > /dev/null || ESTATUS=1
12elif test -n "${GOVERNOR}${MIN_FREQ}${MAX_FREQ}"
13then
14    cpupower frequency-set \
15      ${GOVERNOR:+ -g "$GOVERNOR"} \
16      ${MIN_FREQ:+ -d "$MIN_FREQ"} ${MAX_FREQ:+ -u "$MAX_FREQ"} \
17      > /dev/null || ESTATUS=1
18fi
19
20# apply CPU policy options
21if test -n "$PERF_BIAS"
22then
23    cpupower set -b "$PERF_BIAS" > /dev/null || ESTATUS=1
24fi
25
26exit $ESTATUS
27