drivers/video/fbdev/core/fb_sys_fops.c
Source file repositories/reference/linux-study-clean/drivers/video/fbdev/core/fb_sys_fops.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/fbdev/core/fb_sys_fops.c- Extension
.c- Size
- 2304 bytes
- Lines
- 117
- 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.
- 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 Copyrightfunction fb_sys_writeexport fb_sys_readexport fb_sys_write
Annotated Snippet
#include <linux/export.h>
#include <linux/fb.h>
#include <linux/module.h>
#include <linux/uaccess.h>
ssize_t fb_sys_read(struct fb_info *info, char __user *buf, size_t count,
loff_t *ppos)
{
unsigned long p = *ppos;
void *src;
int err = 0;
unsigned long total_size, c;
ssize_t ret;
if (!(info->flags & FBINFO_VIRTFB))
fb_warn_once(info, "Framebuffer is not in virtual address space.");
if (!info->screen_buffer)
return -ENODEV;
total_size = info->screen_size;
if (total_size == 0)
total_size = info->fix.smem_len;
if (p >= total_size)
return 0;
if (count >= total_size)
count = total_size;
if (count + p > total_size)
count = total_size - p;
src = info->screen_buffer + p;
if (info->fbops->fb_sync)
info->fbops->fb_sync(info);
c = copy_to_user(buf, src, count);
if (c)
err = -EFAULT;
ret = count - c;
*ppos += ret;
return ret ? ret : err;
}
EXPORT_SYMBOL_GPL(fb_sys_read);
ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
size_t count, loff_t *ppos)
{
unsigned long p = *ppos;
void *dst;
int err = 0;
unsigned long total_size, c;
size_t ret;
if (!(info->flags & FBINFO_VIRTFB))
fb_warn_once(info, "Framebuffer is not in virtual address space.");
if (!info->screen_buffer)
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;
}
dst = info->screen_buffer + p;
if (info->fbops->fb_sync)
info->fbops->fb_sync(info);
Annotation
- Immediate include surface: `linux/export.h`, `linux/fb.h`, `linux/module.h`, `linux/uaccess.h`.
- Detected declarations: `function Copyright`, `function fb_sys_write`, `export fb_sys_read`, `export fb_sys_write`.
- 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.