summaryrefslogtreecommitdiff
path: root/kvmd/apps/otgmsd
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-03-31 16:17:52 +0300
committerMaxim Devaev <[email protected]>2022-03-31 16:17:52 +0300
commitb775239d7265a1bcbb6e32f06546e53d389802d6 (patch)
tree98c7112425e79e0075c5e3859567b085bf9bab17 /kvmd/apps/otgmsd
parentab09f88d80ac67c76f012b2fcb853f2d69ab6b7d (diff)
refactoring
Diffstat (limited to 'kvmd/apps/otgmsd')
-rw-r--r--kvmd/apps/otgmsd/__init__.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/kvmd/apps/otgmsd/__init__.py b/kvmd/apps/otgmsd/__init__.py
index f87d5985..5187a72d 100644
--- a/kvmd/apps/otgmsd/__init__.py
+++ b/kvmd/apps/otgmsd/__init__.py
@@ -34,29 +34,24 @@ from ...validators.basic import valid_bool
from ...validators.basic import valid_int_f0
from ...validators.os import valid_abs_file
-from ... import env
+from ... import usb
from .. import init
# =====
-def _make_param_path(gadget: str, instance: int, param: str) -> str:
- return os.path.join(
- f"{env.SYSFS_PREFIX}/sys/kernel/config/usb_gadget",
- gadget,
- f"functions/mass_storage.usb{instance}/lun.0",
- param,
- )
+def _get_param_path(gadget: str, instance: int, param: str) -> str:
+ return usb.get_gadget_path(gadget, usb.G_FUNCTIONS, f"mass_storage.usb{instance}/lun.0", param)
def _get_param(gadget: str, instance: int, param: str) -> str:
- with open(_make_param_path(gadget, instance, param)) as param_file:
+ with open(_get_param_path(gadget, instance, param)) as param_file:
return param_file.read().strip()
def _set_param(gadget: str, instance: int, param: str, value: str) -> None:
try:
- with open(_make_param_path(gadget, instance, param), "w") as param_file:
+ with open(_get_param_path(gadget, instance, param), "w") as param_file:
param_file.write(value + "\n")
except OSError as err:
if err.errno == errno.EBUSY: