summaryrefslogtreecommitdiff
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
parented93f1f4d30031b90c45469b2a6651fdce826f33 (diff)
simplified find_udc()
-rw-r--r--kvmd/apps/otg/__init__.py2
-rw-r--r--kvmd/plugins/ugpio/otgbind.py2
-rw-r--r--kvmd/usb.py9
3 files changed, 5 insertions, 8 deletions
diff --git a/kvmd/apps/otg/__init__.py b/kvmd/apps/otg/__init__.py
index 11fa83a3..428f20ab 100644
--- a/kvmd/apps/otg/__init__.py
+++ b/kvmd/apps/otg/__init__.py
@@ -186,7 +186,7 @@ def _cmd_start(config: Section) -> None: # pylint: disable=too-many-statements
_check_config(config)
- udc = usb.find_udc(config.otg.udc)[0]
+ udc = usb.find_udc(config.otg.udc)
logger.info("Using UDC %s", udc)
logger.info("Creating gadget %r ...", config.otg.gadget)
diff --git a/kvmd/plugins/ugpio/otgbind.py b/kvmd/plugins/ugpio/otgbind.py
index 978a0154..43fc32fe 100644
--- a/kvmd/plugins/ugpio/otgbind.py
+++ b/kvmd/plugins/ugpio/otgbind.py
@@ -60,7 +60,7 @@ class Plugin(BaseUserGpioDriver):
return str
def prepare(self) -> None:
- self.__udc = usb.find_udc(self.__udc)[0]
+ self.__udc = usb.find_udc(self.__udc)
get_logger().info("Using UDC %s", self.__udc)
async def run(self) -> None:
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)