From 7e39ecf14203eb592e0c1d208b12304371781780 Mon Sep 17 00:00:00 2001 From: sergei Trofimov Date: Mon, 30 Apr 2018 15:40:15 +0100 Subject: [PATCH] cpufreq: add missing get_driver() method Add a method to read the name of the driver for cpufreq policy for a cpu. --- devlib/module/cpufreq.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/devlib/module/cpufreq.py b/devlib/module/cpufreq.py index 5071e1b..d72b7c4 100644 --- a/devlib/module/cpufreq.py +++ b/devlib/module/cpufreq.py @@ -442,6 +442,18 @@ class CpufreqModule(Module): return [int(c) for c in self.target.read_value(sysfile).split()] + @memoized + def get_driver(self, cpu): + """ + Get the name of the driver used by this cpufreq policy. + """ + if isinstance(cpu, int): + cpu = 'cpu{}'.format(cpu) + + sysfile = '/sys/devices/system/cpu/{}/cpufreq/scaling_driver'.format(cpu) + + return self.target.read_value(sysfile).strip() + def iter_domains(self): """ Iterate over the frequency domains in the system