diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-07-16 09:58:45 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-09-03 22:52:46 -0400 |
commit | 5d30b4274f1f3315f48ad4b2a9a41abc94d11d16 (patch) | |
tree | 3acf57ad91649fea243704d1ffc6d370c35024dc | |
parent | badcf2b7b816130a60152d9f5a06705176596925 (diff) |
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>
-rw-r--r-- | drivers/dma/coh901318.c | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c index 9bfaddd57ef1..31011d2a26fc 100644 --- a/drivers/dma/coh901318.c +++ b/drivers/dma/coh901318.c | |||
@@ -1339,15 +1339,14 @@ static int coh901318_debugfs_read(struct file *file, char __user *buf, | |||
1339 | { | 1339 | { |
1340 | u64 started_channels = debugfs_dma_base->pm.started_channels; | 1340 | u64 started_channels = debugfs_dma_base->pm.started_channels; |
1341 | int pool_count = debugfs_dma_base->pool.debugfs_pool_counter; | 1341 | int pool_count = debugfs_dma_base->pool.debugfs_pool_counter; |
1342 | int i; | ||
1343 | int ret = 0; | ||
1344 | char *dev_buf; | 1342 | char *dev_buf; |
1345 | char *tmp; | 1343 | char *tmp; |
1346 | int dev_size; | 1344 | int ret; |
1345 | int i; | ||
1347 | 1346 | ||
1348 | dev_buf = kmalloc(4*1024, GFP_KERNEL); | 1347 | dev_buf = kmalloc(4*1024, GFP_KERNEL); |
1349 | if (dev_buf == NULL) | 1348 | if (dev_buf == NULL) |
1350 | goto err_kmalloc; | 1349 | return -ENOMEM; |
1351 | tmp = dev_buf; | 1350 | tmp = dev_buf; |
1352 | 1351 | ||
1353 | tmp += sprintf(tmp, "DMA -- enabled dma channels\n"); | 1352 | tmp += sprintf(tmp, "DMA -- enabled dma channels\n"); |
@@ -1357,26 +1356,11 @@ static int coh901318_debugfs_read(struct file *file, char __user *buf, | |||
1357 | tmp += sprintf(tmp, "channel %d\n", i); | 1356 | tmp += sprintf(tmp, "channel %d\n", i); |
1358 | 1357 | ||
1359 | tmp += sprintf(tmp, "Pool alloc nbr %d\n", pool_count); | 1358 | tmp += sprintf(tmp, "Pool alloc nbr %d\n", pool_count); |
1360 | dev_size = tmp - dev_buf; | ||
1361 | |||
1362 | /* No more to read if offset != 0 */ | ||
1363 | if (*f_pos > dev_size) | ||
1364 | goto out; | ||
1365 | 1359 | ||
1366 | if (count > dev_size - *f_pos) | 1360 | ret = simple_read_from_buffer(buf, count, f_pos, dev_buf, |
1367 | count = dev_size - *f_pos; | 1361 | tmp - dev_buf); |
1368 | |||
1369 | if (copy_to_user(buf, dev_buf + *f_pos, count)) | ||
1370 | ret = -EINVAL; | ||
1371 | ret = count; | ||
1372 | *f_pos += count; | ||
1373 | |||
1374 | out: | ||
1375 | kfree(dev_buf); | 1362 | kfree(dev_buf); |
1376 | return ret; | 1363 | return ret; |
1377 | |||
1378 | err_kmalloc: | ||
1379 | return 0; | ||
1380 | } | 1364 | } |
1381 | 1365 | ||
1382 | static const struct file_operations coh901318_debugfs_status_operations = { | 1366 | static const struct file_operations coh901318_debugfs_status_operations = { |