drivers/hid/hid-sensor-custom.c
Source file repositories/reference/linux-study-clean/drivers/hid/hid-sensor-custom.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/hid-sensor-custom.c- Extension
.c- Size
- 29599 bytes
- Lines
- 1075
- Domain
- Driver Families
- Bucket
- drivers/hid
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/ctype.hlinux/dmi.hlinux/kernel.hlinux/module.hlinux/init.hlinux/miscdevice.hlinux/kfifo.hlinux/sched.hlinux/wait.hlinux/poll.hlinux/bsearch.hlinux/platform_device.hlinux/hid-sensor-hub.h
Detected Declarations
struct hid_sensor_custom_fieldstruct hid_sensor_customstruct hid_sensor_samplestruct hid_sensor_custom_matchstruct hid_sensor_custom_propertiesfunction usage_id_cmpfunction enable_sensor_showfunction set_power_report_statefunction enable_sensor_storefunction show_valuefunction store_valuefunction hid_sensor_capture_samplefunction hid_sensor_send_eventfunction hid_sensor_custom_add_fieldfunction hid_sensor_custom_add_fieldsfunction list_for_each_entryfunction hid_sensor_custom_add_attributesfunction hid_sensor_custom_remove_attributesfunction hid_sensor_custom_readfunction hid_sensor_custom_releasefunction hid_sensor_custom_openfunction hid_sensor_custom_pollfunction hid_sensor_custom_dev_if_addfunction hid_sensor_custom_dev_if_removefunction hid_sensor_custom_prop_match_strfunction hid_sensor_custom_get_propfunction hid_sensor_custom_do_matchfunction hid_sensor_custom_properties_getfunction hid_sensor_custom_get_knownfunction hid_sensor_register_platform_devicefunction hid_sensor_custom_probefunction hid_sensor_custom_remove
Annotated Snippet
static const struct file_operations hid_sensor_custom_fops = {
.open = hid_sensor_custom_open,
.read = hid_sensor_custom_read,
.release = hid_sensor_custom_release,
.poll = hid_sensor_custom_poll,
.llseek = noop_llseek,
};
static int hid_sensor_custom_dev_if_add(struct hid_sensor_custom *sensor_inst)
{
int ret;
ret = kfifo_alloc(&sensor_inst->data_fifo, HID_CUSTOM_FIFO_SIZE,
GFP_KERNEL);
if (ret)
return ret;
init_waitqueue_head(&sensor_inst->wait);
sensor_inst->custom_dev.minor = MISC_DYNAMIC_MINOR;
sensor_inst->custom_dev.name = dev_name(&sensor_inst->pdev->dev);
sensor_inst->custom_dev.fops = &hid_sensor_custom_fops;
ret = misc_register(&sensor_inst->custom_dev);
if (ret) {
kfifo_free(&sensor_inst->data_fifo);
return ret;
}
return 0;
}
static void hid_sensor_custom_dev_if_remove(struct hid_sensor_custom
*sensor_inst)
{
wake_up(&sensor_inst->wait);
misc_deregister(&sensor_inst->custom_dev);
kfifo_free(&sensor_inst->data_fifo);
}
/*
* Match a known custom sensor.
* tag and luid is mandatory.
*/
struct hid_sensor_custom_match {
const char *tag;
const char *luid;
const char *model;
const char *manufacturer;
bool check_dmi;
struct dmi_system_id dmi;
};
/*
* Custom sensor properties used for matching.
*/
struct hid_sensor_custom_properties {
u16 serial_num[HID_CUSTOM_MAX_FEATURE_BYTES];
u16 model[HID_CUSTOM_MAX_FEATURE_BYTES];
u16 manufacturer[HID_CUSTOM_MAX_FEATURE_BYTES];
};
static const struct hid_sensor_custom_match hid_sensor_custom_known_table[] = {
/*
* Intel Integrated Sensor Hub (ISH)
*/
{ /* Intel ISH hinge */
.tag = "INT",
.luid = "020B000000000000",
.manufacturer = "INTEL",
},
/*
* Lenovo Intelligent Sensing Solution (LISS)
*/
{ /* ambient light */
.tag = "LISS",
.luid = "0041010200000082",
.model = "STK3X3X Sensor",
.manufacturer = "Vendor 258",
.check_dmi = true,
.dmi.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
}
},
{ /* human presence */
.tag = "LISS",
.luid = "0226000171AC0081",
.model = "VL53L1_HOD Sensor",
.manufacturer = "ST_MICRO",
.check_dmi = true,
.dmi.matches = {
Annotation
- Immediate include surface: `linux/ctype.h`, `linux/dmi.h`, `linux/kernel.h`, `linux/module.h`, `linux/init.h`, `linux/miscdevice.h`, `linux/kfifo.h`, `linux/sched.h`.
- Detected declarations: `struct hid_sensor_custom_field`, `struct hid_sensor_custom`, `struct hid_sensor_sample`, `struct hid_sensor_custom_match`, `struct hid_sensor_custom_properties`, `function usage_id_cmp`, `function enable_sensor_show`, `function set_power_report_state`, `function enable_sensor_store`, `function show_value`.
- Atlas domain: Driver Families / drivers/hid.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.