drivers/video/fbdev/core/fb_io_fops.c
Source file repositories/reference/linux-study-clean/drivers/video/fbdev/core/fb_io_fops.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/fbdev/core/fb_io_fops.c- Extension
.c- Size
- 3526 bytes
- Lines
- 174
- Domain
- Driver Families
- Bucket
- drivers/video
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/export.hlinux/fb.hlinux/module.hlinux/uaccess.h
Detected Declarations
function fb_io_readfunction fb_io_writefunction fb_io_mmapexport fb_io_readexport fb_io_writeexport fb_io_mmap
Annotated Snippet
if (trailing == c) {
err = -EFAULT;
break;
}
c -= trailing;
*ppos += c;
buf += c;
cnt += c;
count -= c;
}
kfree(buffer);
return cnt ? cnt : err;
}
EXPORT_SYMBOL(fb_io_read);
ssize_t fb_io_write(struct fb_info *info, const char __user *buf, size_t count, loff_t *ppos)
{
unsigned long p = *ppos;
u8 *buffer, *src;
u8 __iomem *dst;
int c, cnt = 0, err = 0;
unsigned long total_size, trailing;
if (info->flags & FBINFO_VIRTFB)
fb_warn_once(info, "Framebuffer is not in I/O address space.");
if (!info->screen_base)
return -ENODEV;
total_size = info->screen_size;
if (total_size == 0)
total_size = info->fix.smem_len;
if (p > total_size)
return -EFBIG;
if (count > total_size) {
err = -EFBIG;
count = total_size;
}
if (count + p > total_size) {
if (!err)
err = -ENOSPC;
count = total_size - p;
}
buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count,
GFP_KERNEL);
if (!buffer)
return -ENOMEM;
dst = (u8 __iomem *) (info->screen_base + p);
if (info->fbops->fb_sync)
info->fbops->fb_sync(info);
while (count) {
c = (count > PAGE_SIZE) ? PAGE_SIZE : count;
src = buffer;
trailing = copy_from_user(src, buf, c);
if (trailing == c) {
err = -EFAULT;
break;
}
c -= trailing;
fb_memcpy_toio(dst, src, c);
dst += c;
src += c;
*ppos += c;
buf += c;
cnt += c;
count -= c;
}
kfree(buffer);
return (cnt) ? cnt : err;
}
EXPORT_SYMBOL(fb_io_write);
int fb_io_mmap(struct fb_info *info, struct vm_area_struct *vma)
{
Annotation
- Immediate include surface: `linux/export.h`, `linux/fb.h`, `linux/module.h`, `linux/uaccess.h`.
- Detected declarations: `function fb_io_read`, `function fb_io_write`, `function fb_io_mmap`, `export fb_io_read`, `export fb_io_write`, `export fb_io_mmap`.
- Atlas domain: Driver Families / drivers/video.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.