summaryrefslogtreecommitdiff
path: root/kvmd/usb.py
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-03-31 03:37:04 +0300
committerMaxim Devaev <[email protected]>2022-03-31 03:37:04 +0300
commit94dca7d7c677b62b1e8645afcf721118c7a60833 (patch)
tree1809700273efa6db8cec9cbdd0532451aa985f5c /kvmd/usb.py
parented93f1f4d30031b90c45469b2a6651fdce826f33 (diff)
simplified find_udc()
Diffstat (limited to 'kvmd/usb.py')
-rw-r--r--kvmd/usb.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/kvmd/usb.py b/kvmd/usb.py
index 97c2ed2d..1f60ba75 100644
--- a/kvmd/usb.py
+++ b/kvmd/usb.py
@@ -22,15 +22,13 @@
import os
-from typing import Tuple
-
from .logging import get_logger
from . import env
# =====
-def find_udc(udc: str) -> Tuple[str, str]:
+def find_udc(udc: str) -> str:
path = f"{env.SYSFS_PREFIX}/sys/class/udc"
candidates = sorted(os.listdir(path))
if not udc:
@@ -39,8 +37,7 @@ def find_udc(udc: str) -> Tuple[str, str]:
udc = candidates[0]
elif udc not in candidates:
raise RuntimeError(f"Can't find selected UDC: {udc}")
- driver = os.path.basename(os.readlink(os.path.join(path, udc, "device/driver")))
- return (udc, driver) # (fe980000.usb, dwc2)
+ return udc # fe980000.usb
class UsbDeviceController:
@@ -49,7 +46,7 @@ class UsbDeviceController:
self.__state_path = ""
def find(self) -> None:
- udc = find_udc(self.__udc)[0]
+ udc = find_udc(self.__udc)
self.__state_path = os.path.join(f"{env.SYSFS_PREFIX}/sys/class/udc", udc, "state")
get_logger().info("Using UDC %s", udc)