aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-01-12 20:11:47 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-12 20:11:47 -0500
commit33caf82acf4dc420bf0f0136b886f7b27ecf90c5 (patch)
treeb24b0b5c8f257ae7db3b8df939821a0856869895 /drivers/char
parentca9706a282943899981e83604f2ed13e88ce4239 (diff)
parentbbddca8e8fac07ece3938e03526b5d00fa791a4c (diff)
Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull misc vfs updates from Al Viro: "All kinds of stuff. That probably should've been 5 or 6 separate branches, but by the time I'd realized how large and mixed that bag had become it had been too close to -final to play with rebasing. Some fs/namei.c cleanups there, memdup_user_nul() introduction and switching open-coded instances, burying long-dead code, whack-a-mole of various kinds, several new helpers for ->llseek(), assorted cleanups and fixes from various people, etc. One piece probably deserves special mention - Neil's lookup_one_len_unlocked(). Similar to lookup_one_len(), but gets called without ->i_mutex and tries to avoid ever taking it. That, of course, means that it's not useful for any directory modifications, but things like getting inode attributes in nfds readdirplus are fine with that. I really should've asked for moratorium on lookup-related changes this cycle, but since I hadn't done that early enough... I *am* asking for that for the coming cycle, though - I'm going to try and get conversion of i_mutex to rwsem with ->lookup() done under lock taken shared. There will be a patch closer to the end of the window, along the lines of the one Linus had posted last May - mechanical conversion of ->i_mutex accesses to inode_lock()/inode_unlock()/inode_trylock()/ inode_is_locked()/inode_lock_nested(). To quote Linus back then: ----- | This is an automated patch using | | sed 's/mutex_lock(&\(.*\)->i_mutex)/inode_lock(\1)/' | sed 's/mutex_unlock(&\(.*\)->i_mutex)/inode_unlock(\1)/' | sed 's/mutex_lock_nested(&\(.*\)->i_mutex,[ ]*I_MUTEX_\([A-Z0-9_]*\))/inode_lock_nested(\1, I_MUTEX_\2)/' | sed 's/mutex_is_locked(&\(.*\)->i_mutex)/inode_is_locked(\1)/' | sed 's/mutex_trylock(&\(.*\)->i_mutex)/inode_trylock(\1)/' | | with a very few manual fixups ----- I'm going to send that once the ->i_mutex-affecting stuff in -next gets mostly merged (or when Linus says he's about to stop taking merges)" * 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (63 commits) nfsd: don't hold i_mutex over userspace upcalls fs:affs:Replace time_t with time64_t fs/9p: use fscache mutex rather than spinlock proc: add a reschedule point in proc_readfd_common() logfs: constify logfs_block_ops structures fcntl: allow to set O_DIRECT flag on pipe fs: __generic_file_splice_read retry lookup on AOP_TRUNCATED_PAGE fs: xattr: Use kvfree() [s390] page_to_phys() always returns a multiple of PAGE_SIZE nbd: use ->compat_ioctl() fs: use block_device name vsprintf helper lib/vsprintf: add %*pg format specifier fs: use gendisk->disk_name where possible poll: plug an unused argument to do_poll amdkfd: don't open-code memdup_user() cdrom: don't open-code memdup_user() rsxx: don't open-code memdup_user() mtip32xx: don't open-code memdup_user() [um] mconsole: don't open-code memdup_user_nul() [um] hostaudio: don't open-code memdup_user() ...
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
-rw-r--r--drivers/char/nwflash.c31
4 files changed, 10 insertions, 88 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,
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c
index e371480d3639..dbe598de9b74 100644
--- a/drivers/char/nwflash.c
+++ b/drivers/char/nwflash.c
@@ -277,36 +277,7 @@ static loff_t flash_llseek(struct file *file, loff_t offset, int orig)
277 printk(KERN_DEBUG "flash_llseek: offset=0x%X, orig=0x%X.\n", 277 printk(KERN_DEBUG "flash_llseek: offset=0x%X, orig=0x%X.\n",
278 (unsigned int) offset, orig); 278 (unsigned int) offset, orig);
279 279
280 switch (orig) { 280 ret = no_seek_end_llseek_size(file, offset, orig, gbFlashSize);
281 case 0:
282 if (offset < 0) {
283 ret = -EINVAL;
284 break;
285 }
286
287 if ((unsigned int) offset > gbFlashSize) {
288 ret = -EINVAL;
289 break;
290 }
291
292 file->f_pos = (unsigned int) offset;
293 ret = file->f_pos;
294 break;
295 case 1:
296 if ((file->f_pos + offset) > gbFlashSize) {
297 ret = -EINVAL;
298 break;
299 }
300 if ((file->f_pos + offset) < 0) {
301 ret = -EINVAL;
302 break;
303 }
304 file->f_pos += offset;
305 ret = file->f_pos;
306 break;
307 default:
308 ret = -EINVAL;
309 }
310 mutex_unlock(&flash_mutex); 281 mutex_unlock(&flash_mutex);
311 return ret; 282 return ret;
312} 283}