tools/testing/selftests/hid/tests/base_device.py
Source file repositories/reference/linux-study-clean/tools/testing/selftests/hid/tests/base_device.py
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/hid/tests/base_device.py- Extension
.py- Size
- 14014 bytes
- Lines
- 449
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/bin/env python3
# SPDX-License-Identifier: GPL-2.0
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017 Benjamin Tissoires <benjamin.tissoires@gmail.com>
# Copyright (c) 2017 Red Hat, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import dataclasses
import fcntl
import functools
import libevdev
import os
import threading
try:
import pyudev
except ImportError:
raise ImportError("UHID is not supported due to missing pyudev dependency")
import logging
import hidtools.hid as hid
from hidtools.uhid import UHIDDevice
from hidtools.util import BusType
from pathlib import Path
from typing import Any, ClassVar, Dict, List, Optional, Tuple, Type, Union
logger = logging.getLogger("hidtools.device.base_device")
class SysfsFile(object):
def __init__(self, path):
self.path = path
def __set_value(self, value):
with open(self.path, "w") as f:
return f.write(f"{value}\n")
def __get_value(self):
with open(self.path) as f:
return f.read().strip()
@property
def int_value(self) -> int:
return int(self.__get_value())
@int_value.setter
def int_value(self, v: int) -> None:
self.__set_value(v)
@property
def str_value(self) -> str:
return self.__get_value()
@str_value.setter
def str_value(self, v: str) -> None:
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.