1
0
Fork 0

create usb plugin, remove autosuspend from cpu plugin

This commit is contained in:
Jan Vcelak 2012-05-04 12:02:59 +02:00
parent 17bf48d7c6
commit 8efa8c964c
2 changed files with 44 additions and 26 deletions

View file

@ -37,9 +37,6 @@ class CPULatencyPlugin(tuned.plugins.Plugin):
self.register_command("cpu_multicore_powersave",
self._set_cpu_multicore_powersave,
self._revert_cpu_multicore_powersave)
self.register_command("enable_usb_autosupend",
self._set_enable_usb_autosupend,
self._revert_enable_usb_autosupend)
@classmethod
def _get_default_options(cls):
@ -50,7 +47,6 @@ class CPULatencyPlugin(tuned.plugins.Plugin):
"latency" : None,
"cpu_governor" : None,
"cpu_multicore_powersave" : None,
"enable_usb_autosupend" : None,
}
def cleanup(self):
@ -121,25 +117,3 @@ class CPULatencyPlugin(tuned.plugins.Plugin):
@command_revert("cpu", "cpu_multicore_powersave")
def _revert_cpu_multicore_powersave(self, value):
tuned.utils.commands.execute(["cpupower", "set", "-m", value])
#TODO: Move USB to different plugin, I'm just not sure which one...
@command("cpu", "enable_usb_autosupend")
def _set_enable_usb_autosupend(self, value):
old_value = {}
if value == "1" or value == "true":
value = "1"
elif value == "0" or value == "false":
value = "0"
else:
log.warn("Incorrect enable_bluetooth value.")
return
for sys_file in glob.glob("/sys/bus/usb/devices/*/power/autosuspend"):
old_value[sys_file] = tuned.utils.commands.read_file(sys_file)
tuned.utils.commands.write_to_file(sys_file, value)
return old_value
@command_revert("cpu", "enable_usb_autosupend")
def _revert_enable_usb_autosupend(self, values):
for sys_file, value in values.iteritems():
tuned.utils.commands.write_to_file(sys_file, value)

View file

@ -0,0 +1,44 @@
import tuned.plugins
import tuned.log
class USBPlugin(tuned.plugins.Plugin):
"""
"""
def __init__(self, devices, options):
super(self.__class__, self).__init__(devices, options)
self.register_command("enable_usb_autosupend",
self._set_enable_usb_autosupend,
self._revert_enable_usb_autosupend)
@classmethod
def _get_default_options(cls):
return {
"enable_usb_autosuspend": None,
}
def update_tuning(self):
# FIXME: can we drop this method?
pass
@command("usb", "enable_usb_autosupend")
def _set_enable_usb_autosupend(self, value):
old_value = {}
if value == "1" or value == "true":
value = "1"
elif value == "0" or value == "false":
value = "0"
else:
log.warn("Incorrect enable_usb_autosuspend value.")
return
for sys_file in glob.glob("/sys/bus/usb/devices/*/power/autosuspend"):
old_value[sys_file] = tuned.utils.commands.read_file(sys_file)
tuned.utils.commands.write_to_file(sys_file, value)
return old_value
@command_revert("usb", "enable_usb_autosupend")
def _revert_enable_usb_autosupend(self, values):
for sys_file, value in values.iteritems():
tuned.utils.commands.write_to_file(sys_file, value)