diff options
author | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2018-05-18 15:11:42 +0200 |
---|---|---|
committer | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2018-05-18 15:11:42 +0200 |
commit | 54b150fc32374921cb583d129c439b5704744dc4 (patch) | |
tree | 075d450fd6b5b22e9e44571e4d42abd7defa95b3 /surface.c | |
parent | 8ee913ba680dc520abcf08140436029e0e493220 (diff) |
Implement surface read
Diffstat (limited to 'surface.c')
-rw-r--r-- | surface.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -3,6 +3,7 @@ #include <linux/fs.h> #include <linux/dma-mapping.h> #include <linux/slab.h> +#include <asm/uaccess.h> #include "private_data.h" #include "harddoom.h" @@ -17,7 +18,22 @@ long surface_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ssize_t surface_read(struct file *filp, char __user *buf, size_t count, loff_t *offset) { - return -1; + struct surface_data *surface_data; + unsigned long not_written; + + surface_data = filp->private_data; + if (*offset >= surface_data->surface_size) { + return 0; + } + + if (*offset + count > surface_data->surface_size) { + count = surface_data->surface_size - *offset; + } + + not_written = copy_to_user(buf, surface_data->surface_cpu + *offset, + count); + + return count - not_written; } loff_t surface_llseek(struct file *filp, loff_t offset, int origin) |