aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-12-05 21:39:06 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2015-12-09 13:00:45 -0500
commitb808b1d632f6915e4d6b1badb927b2c970ad11bb (patch)
treeb3c85ccbb0a685d4beae45598518307624ccb6ac /drivers/char
parente1a63bbc40c00d5198b1c1d133b139e962f5e872 (diff)
don't open-code generic_file_llseek_size()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/generic_nvram.c21
-rw-r--r--drivers/char/mbcs.c28
-rw-r--r--drivers/char/nvram.c18
3 files changed, 9 insertions, 58 deletions
diff --git a/drivers/char/generic_nvram.c b/drivers/char/generic_nvram.c
index 6c4f4b5a9dd3..073db9558379 100644
--- a/drivers/char/generic_nvram.c
+++ b/drivers/char/generic_nvram.c
@@ -20,6 +20,7 @@
20#include <linux/fcntl.h> 20#include <linux/fcntl.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/mutex.h> 22#include <linux/mutex.h>
23#include <linux/pagemap.h>
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24#include <asm/nvram.h> 25#include <asm/nvram.h>
25#ifdef CONFIG_PPC_PMAC 26#ifdef CONFIG_PPC_PMAC
@@ -33,24 +34,8 @@ static ssize_t nvram_len;
33 34
34static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) 35static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
35{ 36{
36 switch (origin) { 37 return generic_file_llseek_size(file, offset, origin,
37 case 0: 38 MAX_LFS_FILESIZE, nvram_len);
38 break;
39 case 1:
40 offset += file->f_pos;
41 break;
42 case 2:
43 offset += nvram_len;
44 break;
45 default:
46 offset = -1;
47 }
48 if (offset < 0)
49 return -EINVAL;
50
51 file->f_pos = offset;
52
53 return file->f_pos;
54} 39}
55 40
56static ssize_t read_nvram(struct file *file, char __user *buf, 41static ssize_t read_nvram(struct file *file, char __user *buf,
diff --git a/drivers/char/mbcs.c b/drivers/char/mbcs.c
index e5d3e3f7a49b..67d426470e53 100644
--- a/drivers/char/mbcs.c
+++ b/drivers/char/mbcs.c
@@ -26,6 +26,7 @@
26#include <linux/uio.h> 26#include <linux/uio.h>
27#include <linux/mutex.h> 27#include <linux/mutex.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/pagemap.h>
29#include <asm/io.h> 30#include <asm/io.h>
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
31#include <asm/pgtable.h> 32#include <asm/pgtable.h>
@@ -451,31 +452,8 @@ mbcs_sram_write(struct file * fp, const char __user *buf, size_t len, loff_t * o
451 452
452static loff_t mbcs_sram_llseek(struct file * filp, loff_t off, int whence) 453static loff_t mbcs_sram_llseek(struct file * filp, loff_t off, int whence)
453{ 454{
454 loff_t newpos; 455 return generic_file_llseek_size(filp, off, whence, MAX_LFS_FILESIZE,
455 456 MBCS_SRAM_SIZE);
456 switch (whence) {
457 case SEEK_SET:
458 newpos = off;
459 break;
460
461 case SEEK_CUR:
462 newpos = filp->f_pos + off;
463 break;
464
465 case SEEK_END:
466 newpos = MBCS_SRAM_SIZE + off;
467 break;
468
469 default: /* can't happen */
470 return -EINVAL;
471 }
472
473 if (newpos < 0)
474 return -EINVAL;
475
476 filp->f_pos = newpos;
477
478 return newpos;
479} 457}
480 458
481static uint64_t mbcs_pioaddr(struct mbcs_soft *soft, uint64_t offset) 459static uint64_t mbcs_pioaddr(struct mbcs_soft *soft, uint64_t offset)
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
index 97c2d8d433d6..01292328a456 100644
--- a/drivers/char/nvram.c
+++ b/drivers/char/nvram.c
@@ -110,6 +110,7 @@
110#include <linux/io.h> 110#include <linux/io.h>
111#include <linux/uaccess.h> 111#include <linux/uaccess.h>
112#include <linux/mutex.h> 112#include <linux/mutex.h>
113#include <linux/pagemap.h>
113 114
114 115
115static DEFINE_MUTEX(nvram_mutex); 116static DEFINE_MUTEX(nvram_mutex);
@@ -213,21 +214,8 @@ void nvram_set_checksum(void)
213 214
214static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) 215static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
215{ 216{
216 switch (origin) { 217 return generic_file_llseek_size(file, offset, origin, MAX_LFS_FILESIZE,
217 case 0: 218 NVRAM_BYTES);
218 /* nothing to do */
219 break;
220 case 1:
221 offset += file->f_pos;
222 break;
223 case 2:
224 offset += NVRAM_BYTES;
225 break;
226 default:
227 return -EINVAL;
228 }
229
230 return (offset >= 0) ? (file->f_pos = offset) : -EINVAL;
231} 219}
232 220
233static ssize_t nvram_read(struct file *file, char __user *buf, 221static ssize_t nvram_read(struct file *file, char __user *buf,