drivers/platform/chrome/cros_ec_sensorhub_ring.c
Source file repositories/reference/linux-study-clean/drivers/platform/chrome/cros_ec_sensorhub_ring.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/chrome/cros_ec_sensorhub_ring.c- Extension
.c- Size
- 32455 bytes
- Lines
- 1090
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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.
- 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/delay.hlinux/device.hlinux/iio/iio.hlinux/kernel.hlinux/module.hlinux/platform_data/cros_ec_commands.hlinux/platform_data/cros_ec_proto.hlinux/platform_data/cros_ec_sensorhub.hlinux/platform_device.hlinux/sort.hlinux/slab.hcros_ec_sensorhub_trace.h
Detected Declarations
function cros_sensorhub_send_samplefunction cros_ec_sensorhub_register_push_datafunction cros_ec_sensorhub_unregister_push_datafunction cros_ec_sensorhub_ring_fifo_enablefunction cros_ec_sensor_ring_median_swapfunction Ofunction ec_irq_handlerfunction cros_ec_sensor_ring_ts_filterfunction cros_ec_sensor_ring_fix_overflowfunction cros_ec_sensor_ring_check_for_past_timestampfunction cros_ec_sensor_ring_process_eventfunction interruptfunction for_each_set_bitfunction ringbufferfunction for_each_set_bitfunction cros_ec_sensorhub_ring_handlerfunction cros_ec_sensorhub_eventfunction cros_ec_sensorhub_ring_allocatefunction cros_ec_sensorhub_ring_addfunction cros_ec_sensorhub_ring_removeexport cros_ec_sensorhub_register_push_dataexport cros_ec_sensorhub_unregister_push_data
Annotated Snippet
if (sensorhub->tight_timestamps) {
cros_ec_sensor_ring_ts_filter_update(
&sensorhub->filter, b, c);
*current_timestamp = cros_ec_sensor_ring_ts_filter(
&sensorhub->filter, a);
} else {
s64 new_timestamp;
/*
* Disable filtering since we might add more jitter
* if b is in a random point in time.
*/
new_timestamp = c - b * 1000 + a * 1000;
/*
* The timestamp can be stale if we had to use the fifo
* info timestamp.
*/
if (new_timestamp - *current_timestamp > 0)
*current_timestamp = new_timestamp;
}
trace_cros_ec_sensorhub_timestamp(in->timestamp,
fifo_info->timestamp,
fifo_timestamp,
*current_timestamp,
now);
}
if (in->flags & MOTIONSENSE_SENSOR_FLAG_ODR) {
if (sensorhub->tight_timestamps) {
sensorhub->batch_state[in->sensor_num].last_len = 0;
sensorhub->batch_state[in->sensor_num].penul_len = 0;
}
/*
* ODR change is only useful for the sensor_ring, it does not
* convey information to clients.
*/
return false;
}
if (in->flags & MOTIONSENSE_SENSOR_FLAG_FLUSH) {
out->sensor_id = in->sensor_num;
out->timestamp = *current_timestamp;
out->flag = in->flags;
if (sensorhub->tight_timestamps)
sensorhub->batch_state[out->sensor_id].last_len = 0;
/*
* No other payload information provided with
* flush ack.
*/
return true;
}
if (in->flags & MOTIONSENSE_SENSOR_FLAG_TIMESTAMP)
/* If we just have a timestamp, skip this entry. */
return false;
/* Regular sample */
out->sensor_id = in->sensor_num;
trace_cros_ec_sensorhub_data(in->sensor_num,
fifo_info->timestamp,
fifo_timestamp,
*current_timestamp,
now);
if (*current_timestamp - now > 0) {
/*
* This fix is needed to overcome the timestamp filter putting
* events in the future.
*/
sensorhub->future_timestamp_total_ns +=
*current_timestamp - now;
if (++sensorhub->future_timestamp_count ==
FUTURE_TS_ANALYTICS_COUNT_MAX) {
s64 avg = div_s64(sensorhub->future_timestamp_total_ns,
sensorhub->future_timestamp_count);
dev_warn_ratelimited(sensorhub->dev,
"100 timestamps in the future, %lldns shaved on average\n",
avg);
sensorhub->future_timestamp_count = 0;
sensorhub->future_timestamp_total_ns = 0;
}
out->timestamp = now;
} else {
out->timestamp = *current_timestamp;
}
out->flag = in->flags;
for (axis = 0; axis < 3; axis++)
out->vector[axis] = in->data[axis];
Annotation
- Immediate include surface: `linux/delay.h`, `linux/device.h`, `linux/iio/iio.h`, `linux/kernel.h`, `linux/module.h`, `linux/platform_data/cros_ec_commands.h`, `linux/platform_data/cros_ec_proto.h`, `linux/platform_data/cros_ec_sensorhub.h`.
- Detected declarations: `function cros_sensorhub_send_sample`, `function cros_ec_sensorhub_register_push_data`, `function cros_ec_sensorhub_unregister_push_data`, `function cros_ec_sensorhub_ring_fifo_enable`, `function cros_ec_sensor_ring_median_swap`, `function O`, `function ec_irq_handler`, `function cros_ec_sensor_ring_ts_filter`, `function cros_ec_sensor_ring_fix_overflow`, `function cros_ec_sensor_ring_check_for_past_timestamp`.
- Atlas domain: Driver Families / drivers/platform.
- 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.