drivers/media/i2c/s5c73m3/s5c73m3-spi.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/s5c73m3/s5c73m3-spi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/s5c73m3/s5c73m3-spi.c- Extension
.c- Size
- 3153 bytes
- Lines
- 148
- Domain
- Driver Families
- Bucket
- drivers/media
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/sizes.hlinux/delay.hlinux/init.hlinux/media.hlinux/module.hlinux/slab.hlinux/spi/spi.hs5c73m3.h
Detected Declarations
enum spi_directionfunction spi_xmitfunction s5c73m3_spi_writefunction s5c73m3_spi_readfunction s5c73m3_spi_probefunction s5c73m3_register_spi_driverfunction s5c73m3_unregister_spi_driver
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Samsung LSI S5C73M3 8M pixel camera driver
*
* Copyright (C) 2012, Samsung Electronics, Co., Ltd.
* Sylwester Nawrocki <s.nawrocki@samsung.com>
* Andrzej Hajda <a.hajda@samsung.com>
*/
#include <linux/sizes.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/media.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/spi/spi.h>
#include "s5c73m3.h"
#define S5C73M3_SPI_DRV_NAME "S5C73M3-SPI"
static const struct of_device_id s5c73m3_spi_ids[] = {
{ .compatible = "samsung,s5c73m3" },
{ }
};
MODULE_DEVICE_TABLE(of, s5c73m3_spi_ids);
enum spi_direction {
SPI_DIR_RX,
SPI_DIR_TX
};
static int spi_xmit(struct spi_device *spi_dev, void *addr, const int len,
enum spi_direction dir)
{
struct spi_message msg;
int r;
struct spi_transfer xfer = {
.len = len,
};
if (dir == SPI_DIR_TX)
xfer.tx_buf = addr;
else
xfer.rx_buf = addr;
if (spi_dev == NULL) {
pr_err("SPI device is uninitialized\n");
return -ENODEV;
}
spi_message_init(&msg);
spi_message_add_tail(&xfer, &msg);
r = spi_sync(spi_dev, &msg);
if (r < 0)
dev_err(&spi_dev->dev, "%s spi_sync failed %d\n", __func__, r);
return r;
}
int s5c73m3_spi_write(struct s5c73m3 *state, const void *addr,
const unsigned int len, const unsigned int tx_size)
{
struct spi_device *spi_dev = state->spi_dev;
u32 count = len / tx_size;
u32 extra = len % tx_size;
unsigned int i, j = 0;
u8 padding[32];
int r = 0;
memset(padding, 0, sizeof(padding));
for (i = 0; i < count; i++) {
r = spi_xmit(spi_dev, (void *)addr + j, tx_size, SPI_DIR_TX);
if (r < 0)
return r;
j += tx_size;
}
if (extra > 0) {
r = spi_xmit(spi_dev, (void *)addr + j, extra, SPI_DIR_TX);
if (r < 0)
return r;
}
return spi_xmit(spi_dev, padding, sizeof(padding), SPI_DIR_TX);
}
int s5c73m3_spi_read(struct s5c73m3 *state, void *addr,
Annotation
- Immediate include surface: `linux/sizes.h`, `linux/delay.h`, `linux/init.h`, `linux/media.h`, `linux/module.h`, `linux/slab.h`, `linux/spi/spi.h`, `s5c73m3.h`.
- Detected declarations: `enum spi_direction`, `function spi_xmit`, `function s5c73m3_spi_write`, `function s5c73m3_spi_read`, `function s5c73m3_spi_probe`, `function s5c73m3_register_spi_driver`, `function s5c73m3_unregister_spi_driver`.
- Atlas domain: Driver Families / drivers/media.
- 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.