From 984ae4fa376c84915fcf468d901bf35418ec7ef9 Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Thu, 31 Mar 2022 14:38:00 +0300 Subject: disable only if enabled --- kvmd/apps/otgconf/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'kvmd/apps/otgconf') diff --git a/kvmd/apps/otgconf/__init__.py b/kvmd/apps/otgconf/__init__.py index 97d822fa..5e765a99 100644 --- a/kvmd/apps/otgconf/__init__.py +++ b/kvmd/apps/otgconf/__init__.py @@ -52,8 +52,9 @@ def _udc_stopped(gadget: str, udc: str) -> Generator[None, None, None]: udc_path = os.path.join(f"{env.SYSFS_PREFIX}/sys/kernel/config/usb_gadget", gadget, "UDC") with open(udc_path) as udc_file: enabled = bool(udc_file.read().strip()) - with open(udc_path, "w") as udc_file: - udc_file.write("\n") + if enabled: + with open(udc_path, "w") as udc_file: + udc_file.write("\n") try: yield finally: -- cgit v1.2.3