summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Zhang <[email protected]>2022-05-24 21:05:49 +0800
committerGitHub <[email protected]>2022-05-24 16:05:49 +0300
commitd722c3fff7387476afae96e0afb5f005ba39b37a (patch)
tree732bb2f5d24c05da2e8be04a8d91fd8ac3a35cc1
parent628d25cb87eebc488e9f43d2d396cba8819dce72 (diff)
Compatibility with old vanilla kernels (#88)
-rw-r--r--kvmd/apps/otg/__init__.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/kvmd/apps/otg/__init__.py b/kvmd/apps/otg/__init__.py
index cbf7a197..bff089f8 100644
--- a/kvmd/apps/otg/__init__.py
+++ b/kvmd/apps/otg/__init__.py
@@ -78,8 +78,11 @@ def _unlink(path: str, optional: bool=False) -> None:
os.unlink(path)
-def _write(path: str, value: Union[str, int]) -> None:
+def _write(path: str, value: Union[str, int], optional: bool=False) -> None:
get_logger().info("WRITE --- %s", path)
+ if optional and not os.access(path, os.F_OK):
+ get_logger().info("SKIP ---- %s", path)
+ return
with open(path, "w") as param_file:
param_file.write(str(value))
@@ -158,9 +161,9 @@ class _GadgetConfig:
func = f"hid.usb{self.__hid_instance}"
func_path = join(self.__gadget_path, "functions", func)
_mkdir(func_path)
- _write(join(func_path, "no_out_endpoint"), "1")
+ _write(join(func_path, "no_out_endpoint"), "1", optional=True)
if remote_wakeup:
- _write(join(func_path, "wakeup_on_write"), "1")
+ _write(join(func_path, "wakeup_on_write"), "1", optional=True)
_write(join(func_path, "protocol"), hid.protocol)
_write(join(func_path, "subclass"), hid.subclass)
_write(join(func_path, "report_length"), hid.report_length)