Skip to content

Commit 3bc4768

Browse files
committedJun 18, 2024
T5949: Disable USB autosuspend
1 parent 2224890 commit 3bc4768

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% set autosuspend = "-1" %}
2+
{% if enable_usb_autosuspend is vyos_defined %}
3+
{% set autosuspend = "auto" %}
4+
{% endif %}
5+
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control", ATTR{power/control}="{{ autosuspend }}"

‎interface-definitions/system_option.xml.in

+6
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@
183183
</properties>
184184
<defaultValue>12-hour</defaultValue>
185185
</leafNode>
186+
<leafNode name="enable-usb-autosuspend">
187+
<properties>
188+
<help>Enable autosuspend for all USB devices</help>
189+
<valueless/>
190+
</properties>
191+
</leafNode>
186192
</children>
187193
</node>
188194
</children>

‎src/conf_mode/system_option.py

+5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
curlrc_config = r'/etc/curlrc'
3636
ssh_config = r'/etc/ssh/ssh_config.d/91-vyos-ssh-client-options.conf'
3737
systemd_action_file = '/lib/systemd/system/ctrl-alt-del.target'
38+
usb_autosuspend = r'/etc/udev/rules.d/40-usb-autosuspend.rules'
3839
time_format_to_locale = {
3940
'12-hour': 'en_US.UTF-8',
4041
'24-hour': 'en_GB.UTF-8'
@@ -85,6 +86,7 @@ def verify(options):
8586
def generate(options):
8687
render(curlrc_config, 'system/curlrc.j2', options)
8788
render(ssh_config, 'system/ssh_config.j2', options)
89+
render(usb_autosuspend, 'system/40_usb_autosuspend.j2', options)
8890

8991
cmdline_options = []
9092
if 'kernel' in options:
@@ -155,6 +157,9 @@ def apply(options):
155157
time_format = time_format_to_locale.get(options['time_format'])
156158
cmd(f'localectl set-locale LC_TIME={time_format}')
157159

160+
cmd('udevadm control --reload-rules')
161+
162+
158163
if __name__ == '__main__':
159164
try:
160165
c = get_config()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control", ATTR{power/control}="-1"

0 commit comments

Comments
 (0)