mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-05 20:04:19 +08:00
coh901318: don't open-code simple_read_from_buffer()
... and BTW, failing copy_to_user() means EFAULT, not EINVAL Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
badcf2b7b8
commit
5d30b4274f
@ -1339,15 +1339,14 @@ static int coh901318_debugfs_read(struct file *file, char __user *buf,
|
|||||||
{
|
{
|
||||||
u64 started_channels = debugfs_dma_base->pm.started_channels;
|
u64 started_channels = debugfs_dma_base->pm.started_channels;
|
||||||
int pool_count = debugfs_dma_base->pool.debugfs_pool_counter;
|
int pool_count = debugfs_dma_base->pool.debugfs_pool_counter;
|
||||||
int i;
|
|
||||||
int ret = 0;
|
|
||||||
char *dev_buf;
|
char *dev_buf;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
int dev_size;
|
int ret;
|
||||||
|
int i;
|
||||||
|
|
||||||
dev_buf = kmalloc(4*1024, GFP_KERNEL);
|
dev_buf = kmalloc(4*1024, GFP_KERNEL);
|
||||||
if (dev_buf == NULL)
|
if (dev_buf == NULL)
|
||||||
goto err_kmalloc;
|
return -ENOMEM;
|
||||||
tmp = dev_buf;
|
tmp = dev_buf;
|
||||||
|
|
||||||
tmp += sprintf(tmp, "DMA -- enabled dma channels\n");
|
tmp += sprintf(tmp, "DMA -- enabled dma channels\n");
|
||||||
@ -1357,26 +1356,11 @@ static int coh901318_debugfs_read(struct file *file, char __user *buf,
|
|||||||
tmp += sprintf(tmp, "channel %d\n", i);
|
tmp += sprintf(tmp, "channel %d\n", i);
|
||||||
|
|
||||||
tmp += sprintf(tmp, "Pool alloc nbr %d\n", pool_count);
|
tmp += sprintf(tmp, "Pool alloc nbr %d\n", pool_count);
|
||||||
dev_size = tmp - dev_buf;
|
|
||||||
|
|
||||||
/* No more to read if offset != 0 */
|
ret = simple_read_from_buffer(buf, count, f_pos, dev_buf,
|
||||||
if (*f_pos > dev_size)
|
tmp - dev_buf);
|
||||||
goto out;
|
|
||||||
|
|
||||||
if (count > dev_size - *f_pos)
|
|
||||||
count = dev_size - *f_pos;
|
|
||||||
|
|
||||||
if (copy_to_user(buf, dev_buf + *f_pos, count))
|
|
||||||
ret = -EINVAL;
|
|
||||||
ret = count;
|
|
||||||
*f_pos += count;
|
|
||||||
|
|
||||||
out:
|
|
||||||
kfree(dev_buf);
|
kfree(dev_buf);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
err_kmalloc:
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct file_operations coh901318_debugfs_status_operations = {
|
static const struct file_operations coh901318_debugfs_status_operations = {
|
||||||
|
Loading…
Reference in New Issue
Block a user