drivers/iio/common/ssp_sensors/ssp_iio.c
Source file repositories/reference/linux-study-clean/drivers/iio/common/ssp_sensors/ssp_iio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/common/ssp_sensors/ssp_iio.c- Extension
.c- Size
- 2624 bytes
- Lines
- 98
- 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.
- 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/iio/common/ssp_sensors.hlinux/iio/buffer.hlinux/iio/kfifo_buf.hlinux/module.hlinux/slab.hlinux/unaligned.hlinux/units.hssp_iio_sensor.h
Detected Declarations
function Copyrightfunction ssp_common_buffer_postdisablefunction ssp_common_process_data
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2014, Samsung Electronics Co. Ltd. All Rights Reserved.
*/
#include <linux/iio/common/ssp_sensors.h>
#include <linux/iio/buffer.h>
#include <linux/iio/kfifo_buf.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/unaligned.h>
#include <linux/units.h>
#include "ssp_iio_sensor.h"
/**
* ssp_common_buffer_postenable() - generic postenable callback for ssp buffer
*
* @indio_dev: iio device
*
* Returns 0 or negative value in case of error
*/
int ssp_common_buffer_postenable(struct iio_dev *indio_dev)
{
struct ssp_sensor_data *spd = iio_priv(indio_dev);
struct ssp_data *data = dev_get_drvdata(indio_dev->dev.parent->parent);
/* the allocation is made in post because scan size is known in this
* moment
* */
spd->buffer = kmalloc(indio_dev->scan_bytes, GFP_KERNEL | GFP_DMA);
if (!spd->buffer)
return -ENOMEM;
return ssp_enable_sensor(data, spd->type,
ssp_get_sensor_delay(data, spd->type));
}
EXPORT_SYMBOL_NS(ssp_common_buffer_postenable, "IIO_SSP_SENSORS");
/**
* ssp_common_buffer_postdisable() - generic postdisable callback for ssp buffer
*
* @indio_dev: iio device
*
* Returns 0 or negative value in case of error
*/
int ssp_common_buffer_postdisable(struct iio_dev *indio_dev)
{
int ret;
struct ssp_sensor_data *spd = iio_priv(indio_dev);
struct ssp_data *data = dev_get_drvdata(indio_dev->dev.parent->parent);
ret = ssp_disable_sensor(data, spd->type);
if (ret < 0)
return ret;
kfree(spd->buffer);
return ret;
}
EXPORT_SYMBOL_NS(ssp_common_buffer_postdisable, "IIO_SSP_SENSORS");
/**
* ssp_common_process_data() - Common process data callback for ssp sensors
*
* @indio_dev: iio device
* @buf: source buffer
* @len: sensor data length
* @timestamp: system timestamp
*
* Returns 0 or negative value in case of error
*/
int ssp_common_process_data(struct iio_dev *indio_dev, void *buf,
unsigned int len, int64_t timestamp)
{
int64_t calculated_time;
struct ssp_sensor_data *spd = iio_priv(indio_dev);
if (indio_dev->scan_bytes == 0)
return 0;
/*
* it always sends full set of samples, remember about available masks
*/
memcpy(spd->buffer, buf, len);
calculated_time = timestamp +
(int64_t)get_unaligned_le32(buf + len) * MEGA;
return iio_push_to_buffers_with_timestamp(indio_dev, spd->buffer,
calculated_time);
Annotation
- Immediate include surface: `linux/iio/common/ssp_sensors.h`, `linux/iio/buffer.h`, `linux/iio/kfifo_buf.h`, `linux/module.h`, `linux/slab.h`, `linux/unaligned.h`, `linux/units.h`, `ssp_iio_sensor.h`.
- Detected declarations: `function Copyright`, `function ssp_common_buffer_postdisable`, `function ssp_common_process_data`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: integration implementation candidate.
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.