a h@sXddlmZddlTddlZddlmZddlZddlZej Z Gdddej Z dS))base)*N)commandsc@sjeZdZdZddZddZeddZdd Zd d Z d d Z e dddddZ e ddddZdS) USBPlugina 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. .Turn off USB autosuspend for USB devices `1-1` and `1-2` ==== ---- [usb] devices=1-1,1-2 autosuspend=0 ---- ==== cCsJd|_t|_t|_|jdddD]}|j|jq*t |_ dS)NTusbZDEVTYPEZ usb_device) Z_devices_supportedsetZ _free_devicesZ_assigned_devices_hardware_inventoryZ get_devicesZmatch_propertyaddZsys_namer_cmdselfdevicer(z1USBPlugin._get_device_objects..r)r Zdevicesrrr_get_device_objects'szUSBPlugin._get_device_objectscCsddiS)N autosuspendrrrrr_get_config_options*szUSBPlugin._get_config_optionscCsd|_d|_dS)NTF)Z_has_static_tuningZ_has_dynamic_tuningr instancerrr_instance_init0szUSBPlugin._instance_initcCsdS)Nrrrrr_instance_cleanup4szUSBPlugin._instance_cleanupcCsd|S)Nz)/sys/bus/usb/devices/%s/power/autosuspendrr rrr_autosuspend_sysfile7szUSBPlugin._autosuspend_sysfilerT)Z per_devicec CsR||}|durdS|rdnd}|sN||}|jj|||rFtjgndd|S)N10FZno_error)Z _option_boolrr Z write_to_fileerrnoENOENT) r valuerrZsimremoveenablevalsys_filerrr_set_autosuspend:s    zUSBPlugin._set_autosuspendFcCs||}|jj||dS)Nr!)rr Z read_filestrip)r rrZignore_missingr(rrr_get_autosuspendGs zUSBPlugin._get_autosuspendN)F)__name__ __module__ __qualname____doc__rr classmethodrrrrZ command_setr)Z command_getr+rrrrr s    r)rZ decoratorsZ tuned.logsZtunedZtuned.utils.commandsrglobr"ZlogsgetlogZPluginrrrrrs