drivers/iio/common/ssp_sensors/ssp_spi.c
Source file repositories/reference/linux-study-clean/drivers/iio/common/ssp_sensors/ssp_spi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/common/ssp_sensors/ssp_spi.c- Extension
.c- Size
- 13961 bytes
- Lines
- 602
- Domain
- Driver Families
- Bucket
- drivers/iio
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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
ssp.h
Detected Declarations
struct ssp_msg_headerstruct ssp_msgfunction ssp_fill_bufferfunction ssp_get_bufferfunction ssp_clean_msgfunction ssp_print_mcu_debugfunction ssp_check_linesfunction ssp_do_transferfunction ssp_spi_sync_commandfunction ssp_spi_syncfunction ssp_handle_big_datafunction ssp_parse_dataframefunction ssp_irq_msgfunction list_for_each_entry_safefunction ssp_clean_pending_listfunction ssp_commandfunction ssp_send_instructionfunction ssp_get_chipidfunction ssp_set_magnetic_matrixfunction ssp_get_sensor_scanning_infofunction ssp_get_firmware_rev
Annotated Snippet
struct ssp_msg_header {
u8 cmd;
__le16 length;
__le16 options;
__le32 data;
} __attribute__((__packed__));
struct ssp_msg {
u16 length;
u16 options;
struct list_head list;
struct completion *done;
struct ssp_msg_header *h;
char *buffer;
};
static const int ssp_offset_map[SSP_SENSOR_MAX] = {
[SSP_ACCELEROMETER_SENSOR] = SSP_ACCELEROMETER_SIZE +
SSP_TIME_SIZE,
[SSP_GYROSCOPE_SENSOR] = SSP_GYROSCOPE_SIZE +
SSP_TIME_SIZE,
[SSP_GEOMAGNETIC_UNCALIB_SENSOR] = SSP_UNIMPLEMENTED,
[SSP_GEOMAGNETIC_RAW] = SSP_UNIMPLEMENTED,
[SSP_GEOMAGNETIC_SENSOR] = SSP_UNIMPLEMENTED,
[SSP_PRESSURE_SENSOR] = SSP_UNIMPLEMENTED,
[SSP_GESTURE_SENSOR] = SSP_UNIMPLEMENTED,
[SSP_PROXIMITY_SENSOR] = SSP_UNIMPLEMENTED,
[SSP_TEMPERATURE_HUMIDITY_SENSOR] = SSP_UNIMPLEMENTED,
[SSP_LIGHT_SENSOR] = SSP_UNIMPLEMENTED,
[SSP_PROXIMITY_RAW] = SSP_UNIMPLEMENTED,
[SSP_ORIENTATION_SENSOR] = SSP_UNIMPLEMENTED,
[SSP_STEP_DETECTOR] = SSP_UNIMPLEMENTED,
[SSP_SIG_MOTION_SENSOR] = SSP_UNIMPLEMENTED,
[SSP_GYRO_UNCALIB_SENSOR] = SSP_UNIMPLEMENTED,
[SSP_GAME_ROTATION_VECTOR] = SSP_UNIMPLEMENTED,
[SSP_ROTATION_VECTOR] = SSP_UNIMPLEMENTED,
[SSP_STEP_COUNTER] = SSP_UNIMPLEMENTED,
[SSP_BIO_HRM_RAW] = SSP_BIO_HRM_RAW_SIZE +
SSP_TIME_SIZE,
[SSP_BIO_HRM_RAW_FAC] = SSP_BIO_HRM_RAW_FAC_SIZE +
SSP_TIME_SIZE,
[SSP_BIO_HRM_LIB] = SSP_BIO_HRM_LIB_SIZE +
SSP_TIME_SIZE,
};
#define SSP_HEADER_SIZE (sizeof(struct ssp_msg_header))
#define SSP_HEADER_SIZE_ALIGNED (ALIGN(SSP_HEADER_SIZE, 4))
static struct ssp_msg *ssp_create_msg(u8 cmd, u16 len, u16 opt, u32 data)
{
struct ssp_msg_header h;
struct ssp_msg *msg;
msg = kzalloc_obj(*msg);
if (!msg)
return NULL;
h.cmd = cmd;
h.length = cpu_to_le16(len);
h.options = cpu_to_le16(opt);
h.data = cpu_to_le32(data);
msg->buffer = kzalloc(SSP_HEADER_SIZE_ALIGNED + len,
GFP_KERNEL | GFP_DMA);
if (!msg->buffer) {
kfree(msg);
return NULL;
}
msg->length = len;
msg->options = opt;
memcpy(msg->buffer, &h, SSP_HEADER_SIZE);
return msg;
}
/*
* It is a bit heavy to do it this way but often the function is used to compose
* the message from smaller chunks which are placed on the stack. Often the
* chunks are small so memcpy should be optimized.
*/
static inline void ssp_fill_buffer(struct ssp_msg *m, unsigned int offset,
const void *src, unsigned int len)
{
memcpy(&m->buffer[SSP_HEADER_SIZE_ALIGNED + offset], src, len);
}
static inline void ssp_get_buffer(struct ssp_msg *m, unsigned int offset,
void *dest, unsigned int len)
Annotation
- Immediate include surface: `ssp.h`.
- Detected declarations: `struct ssp_msg_header`, `struct ssp_msg`, `function ssp_fill_buffer`, `function ssp_get_buffer`, `function ssp_clean_msg`, `function ssp_print_mcu_debug`, `function ssp_check_lines`, `function ssp_do_transfer`, `function ssp_spi_sync_command`, `function ssp_spi_sync`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source 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.