drivers/iio/common/hid-sensors/hid-sensor-trigger.c
Source file repositories/reference/linux-study-clean/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/common/hid-sensors/hid-sensor-trigger.c- Extension
.c- Size
- 9543 bytes
- Lines
- 339
- Domain
- Driver Families
- Bucket
- drivers/iio
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/platform_device.hlinux/module.hlinux/delay.hlinux/hid-sensor-hub.hlinux/workqueue.hlinux/iio/iio.hlinux/iio/trigger.hlinux/iio/triggered_buffer.hlinux/iio/trigger_consumer.hlinux/iio/sysfs.hlinux/iio/kfifo_buf.hhid-sensor-trigger.h
Detected Declarations
function Copyrightfunction _hid_sensor_get_report_latencyfunction _hid_sensor_get_fifo_statefunction _hid_sensor_power_statefunction hid_sensor_power_statefunction hid_sensor_set_power_workfunction buffer_postenablefunction buffer_predisablefunction hid_sensor_remove_triggerfunction hid_sensor_setup_triggerfunction hid_sensor_suspendfunction hid_sensor_resumefunction hid_sensor_runtime_resume
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* HID Sensors Driver
* Copyright (c) 2012, Intel Corporation.
*/
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/hid-sensor-hub.h>
#include <linux/workqueue.h>
#include <linux/iio/iio.h>
#include <linux/iio/trigger.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/kfifo_buf.h>
#include "hid-sensor-trigger.h"
static ssize_t _hid_sensor_set_report_latency(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
int integer, fract, ret;
int latency;
ret = iio_str_to_fixpoint(buf, 100000, &integer, &fract);
if (ret)
return ret;
latency = integer * 1000 + fract / 1000;
ret = hid_sensor_set_report_latency(attrb, latency);
if (ret < 0)
return ret;
attrb->latency_ms = hid_sensor_get_report_latency(attrb);
return len;
}
static ssize_t _hid_sensor_get_report_latency(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
int latency;
latency = hid_sensor_get_report_latency(attrb);
if (latency < 0)
return latency;
return sprintf(buf, "%d.%06u\n", latency / 1000, (latency % 1000) * 1000);
}
static ssize_t _hid_sensor_get_fifo_state(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
int latency;
latency = hid_sensor_get_report_latency(attrb);
if (latency < 0)
return latency;
return sprintf(buf, "%d\n", !!latency);
}
static IIO_DEVICE_ATTR(hwfifo_timeout, 0644,
_hid_sensor_get_report_latency,
_hid_sensor_set_report_latency, 0);
static IIO_DEVICE_ATTR(hwfifo_enabled, 0444,
_hid_sensor_get_fifo_state, NULL, 0);
static const struct iio_dev_attr *hid_sensor_fifo_attributes[] = {
&iio_dev_attr_hwfifo_timeout,
&iio_dev_attr_hwfifo_enabled,
NULL,
};
static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state)
{
int state_val;
int report_val;
s32 poll_value = 0;
Annotation
- Immediate include surface: `linux/device.h`, `linux/platform_device.h`, `linux/module.h`, `linux/delay.h`, `linux/hid-sensor-hub.h`, `linux/workqueue.h`, `linux/iio/iio.h`, `linux/iio/trigger.h`.
- Detected declarations: `function Copyright`, `function _hid_sensor_get_report_latency`, `function _hid_sensor_get_fifo_state`, `function _hid_sensor_power_state`, `function hid_sensor_power_state`, `function hid_sensor_set_power_work`, `function buffer_postenable`, `function buffer_predisable`, `function hid_sensor_remove_trigger`, `function hid_sensor_setup_trigger`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: integration 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.