disable only if enabled

This commit is contained in:
Maxim Devaev
2022-03-31 14:38:00 +03:00
parent 5d1788cb44
commit 984ae4fa37

View File

@@ -52,6 +52,7 @@ 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())
if enabled:
with open(udc_path, "w") as udc_file:
udc_file.write("\n")
try: