2 * linux/drivers/video/fb_sys_read.c - Generic file operations where
3 * framebuffer is in system RAM
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file COPYING in the main directory of this archive
13 #include <linux/module.h>
14 #include <linux/uaccess.h>
16 ssize_t fb_sys_read(struct fb_info *info, char __user *buf, size_t count,
19 unsigned long p = *ppos;
22 unsigned long total_size, c;
25 if (!info->screen_buffer)
28 total_size = info->screen_size;
31 total_size = info->fix.smem_len;
36 if (count >= total_size)
39 if (count + p > total_size)
40 count = total_size - p;
42 src = info->screen_buffer + p;
44 if (info->fbops->fb_sync)
45 info->fbops->fb_sync(info);
47 c = copy_to_user(buf, src, count);
54 return ret ? ret : err;
56 EXPORT_SYMBOL_GPL(fb_sys_read);
58 ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
59 size_t count, loff_t *ppos)
61 unsigned long p = *ppos;
64 unsigned long total_size, c;
67 if (!info->screen_buffer)
70 total_size = info->screen_size;
73 total_size = info->fix.smem_len;
78 if (count > total_size) {
83 if (count + p > total_size) {
87 count = total_size - p;
90 dst = info->screen_buffer + p;
92 if (info->fbops->fb_sync)
93 info->fbops->fb_sync(info);
95 c = copy_from_user(dst, buf, count);
102 return ret ? ret : err;
104 EXPORT_SYMBOL_GPL(fb_sys_write);
107 MODULE_DESCRIPTION("Generic file read (fb in system RAM)");
108 MODULE_LICENSE("GPL");