drivers/staging/fbtft/fbtft-bus.c
Source file repositories/reference/linux-study-clean/drivers/staging/fbtft/fbtft-bus.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/fbtft/fbtft-bus.c- Extension
.c- Size
- 7436 bytes
- Lines
- 235
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/errno.hlinux/gpio/consumer.hlinux/spi/spi.hfbtft.h
Detected Declarations
function fbtft_write_reg8_bus9function fbtft_write_vmem16_bus8function fbtft_write_vmem16_bus9function fbtft_write_vmem8_bus8function fbtft_write_vmem16_bus16export funcexport fbtft_write_reg8_bus9export fbtft_write_vmem16_bus8export fbtft_write_vmem16_bus9export fbtft_write_vmem8_bus8export fbtft_write_vmem16_bus16
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <linux/export.h>
#include <linux/errno.h>
#include <linux/gpio/consumer.h>
#include <linux/spi/spi.h>
#include "fbtft.h"
/*****************************************************************************
*
* void (*write_reg)(struct fbtft_par *par, int len, ...);
*
*****************************************************************************/
#define define_fbtft_write_reg(func, buffer_type, data_type, modifier) \
void func(struct fbtft_par *par, int len, ...) \
{ \
va_list args; \
int i, ret; \
int offset = 0; \
buffer_type *buf = (buffer_type *)par->buf; \
\
if (unlikely(par->debug & DEBUG_WRITE_REGISTER)) { \
va_start(args, len); \
for (i = 0; i < len; i++) { \
buf[i] = modifier((data_type)va_arg(args, \
unsigned int)); \
} \
va_end(args); \
fbtft_par_dbg_hex(DEBUG_WRITE_REGISTER, par, \
par->info->device, buffer_type, buf, len, \
"%s: ", __func__); \
} \
\
va_start(args, len); \
\
if (par->startbyte) { \
*(u8 *)par->buf = par->startbyte; \
buf = (buffer_type *)(par->buf + 1); \
offset = 1; \
} \
\
*buf = modifier((data_type)va_arg(args, unsigned int)); \
ret = fbtft_write_buf_dc(par, par->buf, sizeof(data_type) + offset, \
0); \
if (ret < 0) \
goto out; \
len--; \
\
if (par->startbyte) \
*(u8 *)par->buf = par->startbyte | 0x2; \
\
if (len) { \
i = len; \
while (i--) \
*buf++ = modifier((data_type)va_arg(args, \
unsigned int)); \
fbtft_write_buf_dc(par, par->buf, \
len * (sizeof(data_type) + offset), 1); \
} \
out: \
va_end(args); \
} \
EXPORT_SYMBOL(func);
define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8, )
define_fbtft_write_reg(fbtft_write_reg16_bus8, __be16, u16, cpu_to_be16)
define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, u16, )
void fbtft_write_reg8_bus9(struct fbtft_par *par, int len, ...)
{
va_list args;
int i, ret;
int pad = 0;
u16 *buf = (u16 *)par->buf;
if (unlikely(par->debug & DEBUG_WRITE_REGISTER)) {
va_start(args, len);
for (i = 0; i < len; i++)
*(((u8 *)buf) + i) = (u8)va_arg(args, unsigned int);
va_end(args);
fbtft_par_dbg_hex(DEBUG_WRITE_REGISTER, par,
par->info->device, u8, buf, len, "%s: ",
__func__);
}
if (len <= 0)
return;
if (par->spi && (par->spi->bits_per_word == 8)) {
/* we're emulating 9-bit, pad start of buffer with no-ops
* (assuming here that zero is a no-op)
Annotation
- Immediate include surface: `linux/export.h`, `linux/errno.h`, `linux/gpio/consumer.h`, `linux/spi/spi.h`, `fbtft.h`.
- Detected declarations: `function fbtft_write_reg8_bus9`, `function fbtft_write_vmem16_bus8`, `function fbtft_write_vmem16_bus9`, `function fbtft_write_vmem8_bus8`, `function fbtft_write_vmem16_bus16`, `export func`, `export fbtft_write_reg8_bus9`, `export fbtft_write_vmem16_bus8`, `export fbtft_write_vmem16_bus9`, `export fbtft_write_vmem8_bus8`.
- Atlas domain: Driver Families / drivers/staging.
- 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.