File: //lib/python3.9/site-packages/tuned/plugins/__pycache__/plugin_usb.cpython-39.opt-1.pyc
a
Y��d� � @ sP d dl mZ d dlT ddlZddlmZ ddlZej� � Z
G dd� dej�ZdS )� )�base)�*� N)�commandsc @ sj e Zd ZdZdd� Zdd� Zedd� �Zdd � Zd
d� Z dd
� Z
eddd�dd� �Ze
d�ddd��ZdS )� USBPlugina�
`usb`::
Sets autosuspend timeout of USB devices to the value specified by the
[option]`autosuspend` option in seconds. If the [option]`devices`
option is specified, the [option]`autosuspend` option applies to only
the USB devices specified, otherwise it applies to all USB devices.
+
The value `0` means that autosuspend is disabled.
+
.To turn off USB autosuspend for USB devices `1-1` and `1-2`
====
----
[usb]
devices=1-1,1-2
autosuspend=0
----
====
c C sJ d| _ t� | _t� | _| j�d��dd�D ]}| j�|j� q*t � | _
d S )NT�usbZDEVTYPEZ
usb_device)Z_devices_supported�setZ
_free_devicesZ_assigned_devices�_hardware_inventoryZget_devicesZmatch_property�addZsys_namer �_cmd��self�device� r �</usr/lib/python3.9/site-packages/tuned/plugins/plugin_usb.py�
_init_devices s zUSBPlugin._init_devicesc s � fdd�|D �S )Nc s g | ]}� j �d |��qS )r )r Z
get_device)�.0�x�r
r r �
<listcomp>) � z1USBPlugin._get_device_objects.<locals>.<listcomp>r )r
Zdevicesr r r �_get_device_objects( s zUSBPlugin._get_device_objectsc C s dd iS )N�autosuspendr r r r r �_get_config_options+ s �zUSBPlugin._get_config_optionsc C s d|_ d|_d S )NTF)Z_has_static_tuningZ_has_dynamic_tuning�r
�instancer r r �_instance_init1 s zUSBPlugin._instance_initc C s d S )Nr r r r r �_instance_cleanup5 s zUSBPlugin._instance_cleanupc C s d| S )Nz)/sys/bus/usb/devices/%s/power/autosuspendr r r r r �_autosuspend_sysfile8 s zUSBPlugin._autosuspend_sysfiler T)Z
per_devicec C sB | � |�}|d u rd S |rdnd}|s>| �|�}| j�||� |S )N�1�0)Z_option_boolr r Z
write_to_file)r
�valuer Zsim�enable�val�sys_filer r r �_set_autosuspend; s
zUSBPlugin._set_autosuspendFc C s | � |�}| jj||d��� S )N)Zno_error)r r Z read_file�strip)r
r Zignore_missingr$ r r r �_get_autosuspendG s
zUSBPlugin._get_autosuspendN)F)�__name__�
__module__�__qualname__�__doc__r r �classmethodr r r r Zcommand_setr% Zcommand_getr'