aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/bsg.c7
-rw-r--r--block/cmd-filter.c2
-rw-r--r--block/scsi_ioctl.c5
-rw-r--r--drivers/block/amiflop.c4
-rw-r--r--drivers/block/ataflop.c4
-rw-r--r--drivers/block/floppy.c4
-rw-r--r--drivers/block/paride/pf.c2
-rw-r--r--drivers/block/paride/pt.c2
-rw-r--r--drivers/block/pktcdvd.c2
-rw-r--r--drivers/block/swim3.c4
-rw-r--r--drivers/char/nvram.c6
-rw-r--r--drivers/ide/ide-floppy_ioctl.c2
-rw-r--r--drivers/ide/ide-gd.c2
-rw-r--r--drivers/md/dm-ioctl.c4
-rw-r--r--drivers/md/dm-table.c12
-rw-r--r--drivers/mtd/mtdchar.c10
-rw-r--r--drivers/parisc/eisa_eeprom.c2
-rw-r--r--fs/block_dev.c10
-rw-r--r--fs/fifo.c6
-rw-r--r--fs/file_table.c4
-rw-r--r--fs/hostfs/hostfs_kern.c5
-rw-r--r--fs/locks.c3
-rw-r--r--fs/open.c2
-rw-r--r--fs/proc/base.c4
-rw-r--r--fs/reiserfs/journal.c2
-rw-r--r--include/linux/blkdev.h3
-rw-r--r--include/linux/device-mapper.h8
-rw-r--r--include/linux/file.h4
-rw-r--r--include/linux/fs.h16
-rw-r--r--include/linux/fsnotify.h2
-rw-r--r--include/linux/types.h1
-rw-r--r--ipc/shm.c2
-rw-r--r--sound/core/oss/pcm_oss.c2
-rw-r--r--sound/oss/au1550_ac97.c2
-rw-r--r--sound/oss/dmasound/dmasound.h4
-rw-r--r--sound/oss/dmasound/dmasound_atari.c4
-rw-r--r--sound/oss/dmasound/dmasound_core.c10
-rw-r--r--sound/oss/msnd.h2
-rw-r--r--sound/oss/sound_config.h20
-rw-r--r--sound/oss/swarm_cs4297a.c2
-rw-r--r--sound/oss/vwsnd.c2
41 files changed, 96 insertions, 98 deletions
diff --git a/block/bsg.c b/block/bsg.c
index 034112bfe1f3..2d36b127f384 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -173,7 +173,7 @@ unlock:
173 173
174static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq, 174static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
175 struct sg_io_v4 *hdr, struct bsg_device *bd, 175 struct sg_io_v4 *hdr, struct bsg_device *bd,
176 int has_write_perm) 176 fmode_t has_write_perm)
177{ 177{
178 if (hdr->request_len > BLK_MAX_CDB) { 178 if (hdr->request_len > BLK_MAX_CDB) {
179 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL); 179 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
@@ -242,7 +242,7 @@ bsg_validate_sgv4_hdr(struct request_queue *q, struct sg_io_v4 *hdr, int *rw)
242 * map sg_io_v4 to a request. 242 * map sg_io_v4 to a request.
243 */ 243 */
244static struct request * 244static struct request *
245bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, int has_write_perm) 245bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm)
246{ 246{
247 struct request_queue *q = bd->queue; 247 struct request_queue *q = bd->queue;
248 struct request *rq, *next_rq = NULL; 248 struct request *rq, *next_rq = NULL;
@@ -601,7 +601,8 @@ bsg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
601} 601}
602 602
603static int __bsg_write(struct bsg_device *bd, const char __user *buf, 603static int __bsg_write(struct bsg_device *bd, const char __user *buf,
604 size_t count, ssize_t *bytes_written, int has_write_perm) 604 size_t count, ssize_t *bytes_written,
605 fmode_t has_write_perm)
605{ 606{
606 struct bsg_command *bc; 607 struct bsg_command *bc;
607 struct request *rq; 608 struct request *rq;
diff --git a/block/cmd-filter.c b/block/cmd-filter.c
index e669aed4c6bc..504b275e1b90 100644
--- a/block/cmd-filter.c
+++ b/block/cmd-filter.c
@@ -27,7 +27,7 @@
27#include <linux/cdrom.h> 27#include <linux/cdrom.h>
28 28
29int blk_verify_command(struct blk_cmd_filter *filter, 29int blk_verify_command(struct blk_cmd_filter *filter,
30 unsigned char *cmd, int has_write_perm) 30 unsigned char *cmd, fmode_t has_write_perm)
31{ 31{
32 /* root can do any command. */ 32 /* root can do any command. */
33 if (capable(CAP_SYS_RAWIO)) 33 if (capable(CAP_SYS_RAWIO))
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index c34272a348fe..c525905f9d35 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -384,7 +384,8 @@ int sg_scsi_ioctl(struct file *file, struct request_queue *q,
384 struct gendisk *disk, struct scsi_ioctl_command __user *sic) 384 struct gendisk *disk, struct scsi_ioctl_command __user *sic)
385{ 385{
386 struct request *rq; 386 struct request *rq;
387 int err, write_perm = 0; 387 int err;
388 fmode_t write_perm = 0;
388 unsigned int in_len, out_len, bytes, opcode, cmdlen; 389 unsigned int in_len, out_len, bytes, opcode, cmdlen;
389 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE]; 390 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
390 391
@@ -428,7 +429,7 @@ int sg_scsi_ioctl(struct file *file, struct request_queue *q,
428 429
429 /* scsi_ioctl passes NULL */ 430 /* scsi_ioctl passes NULL */
430 if (file && (file->f_mode & FMODE_WRITE)) 431 if (file && (file->f_mode & FMODE_WRITE))
431 write_perm = 1; 432 write_perm = FMODE_WRITE;
432 433
433 err = blk_verify_command(&q->cmd_filter, rq->cmd, write_perm); 434 err = blk_verify_command(&q->cmd_filter, rq->cmd, write_perm);
434 if (err) 435 if (err)
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 7516baff3bb9..d19c5a939fe8 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -1560,9 +1560,9 @@ static int floppy_open(struct inode *inode, struct file *filp)
1560 if (fd_ref[drive] && old_dev != system) 1560 if (fd_ref[drive] && old_dev != system)
1561 return -EBUSY; 1561 return -EBUSY;
1562 1562
1563 if (filp && filp->f_mode & 3) { 1563 if (filp && filp->f_mode & (FMODE_READ|FMODE_WRITE)) {
1564 check_disk_change(inode->i_bdev); 1564 check_disk_change(inode->i_bdev);
1565 if (filp->f_mode & 2 ) { 1565 if (filp->f_mode & FMODE_WRITE ) {
1566 int wrprot; 1566 int wrprot;
1567 1567
1568 get_fdc(drive); 1568 get_fdc(drive);
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index 432cf4018291..e1db285b72cd 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -1826,9 +1826,9 @@ static int floppy_open( struct inode *inode, struct file *filp )
1826 if (filp->f_flags & O_NDELAY) 1826 if (filp->f_flags & O_NDELAY)
1827 return 0; 1827 return 0;
1828 1828
1829 if (filp->f_mode & 3) { 1829 if (filp->f_mode & (FMODE_READ|FMODE_WRITE)) {
1830 check_disk_change(inode->i_bdev); 1830 check_disk_change(inode->i_bdev);
1831 if (filp->f_mode & 2) { 1831 if (filp->f_mode & FMODE_WRITE) {
1832 if (p->wpstat) { 1832 if (p->wpstat) {
1833 if (p->ref < 0) 1833 if (p->ref < 0)
1834 p->ref = 0; 1834 p->ref = 0;
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 2cea27aba9a0..ae3ef8945f3f 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3761,14 +3761,14 @@ static int floppy_open(struct inode *inode, struct file *filp)
3761 UFDCS->rawcmd = 2; 3761 UFDCS->rawcmd = 2;
3762 3762
3763 if (!(filp->f_flags & O_NDELAY)) { 3763 if (!(filp->f_flags & O_NDELAY)) {
3764 if (filp->f_mode & 3) { 3764 if (filp->f_mode & (FMODE_READ|FMODE_WRITE)) {
3765 UDRS->last_checked = 0; 3765 UDRS->last_checked = 0;
3766 check_disk_change(inode->i_bdev); 3766 check_disk_change(inode->i_bdev);
3767 if (UTESTF(FD_DISK_CHANGED)) 3767 if (UTESTF(FD_DISK_CHANGED))
3768 goto out; 3768 goto out;
3769 } 3769 }
3770 res = -EROFS; 3770 res = -EROFS;
3771 if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE))) 3771 if ((filp->f_mode & FMODE_WRITE) && !(UTESTF(FD_DISK_WRITABLE)))
3772 goto out; 3772 goto out;
3773 } 3773 }
3774 mutex_unlock(&open_lock); 3774 mutex_unlock(&open_lock);
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index e7fe6ca97dd8..a902d84fd330 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -305,7 +305,7 @@ static int pf_open(struct inode *inode, struct file *file)
305 if (pf->media_status == PF_NM) 305 if (pf->media_status == PF_NM)
306 return -ENODEV; 306 return -ENODEV;
307 307
308 if ((pf->media_status == PF_RO) && (file->f_mode & 2)) 308 if ((pf->media_status == PF_RO) && (file->f_mode & FMODE_WRITE))
309 return -EROFS; 309 return -EROFS;
310 310
311 pf->access++; 311 pf->access++;
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index 5ae229656eaa..1e4006e18f03 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -667,7 +667,7 @@ static int pt_open(struct inode *inode, struct file *file)
667 goto out; 667 goto out;
668 668
669 err = -EROFS; 669 err = -EROFS;
670 if ((!(tape->flags & PT_WRITE_OK)) && (file->f_mode & 2)) 670 if ((!(tape->flags & PT_WRITE_OK)) && (file->f_mode & FMODE_WRITE))
671 goto out; 671 goto out;
672 672
673 if (!(iminor(inode) & 128)) 673 if (!(iminor(inode) & 128))
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 195ca7c720f5..4d581e8ba9f6 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -2320,7 +2320,7 @@ static int pkt_open_write(struct pktcdvd_device *pd)
2320/* 2320/*
2321 * called at open time. 2321 * called at open time.
2322 */ 2322 */
2323static int pkt_open_dev(struct pktcdvd_device *pd, int write) 2323static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write)
2324{ 2324{
2325 int ret; 2325 int ret;
2326 long lba; 2326 long lba;
diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c
index 730ccea78e45..a53ca54bee12 100644
--- a/drivers/block/swim3.c
+++ b/drivers/block/swim3.c
@@ -908,13 +908,13 @@ static int floppy_open(struct inode *inode, struct file *filp)
908 return -EBUSY; 908 return -EBUSY;
909 909
910 if (err == 0 && (filp->f_flags & O_NDELAY) == 0 910 if (err == 0 && (filp->f_flags & O_NDELAY) == 0
911 && (filp->f_mode & 3)) { 911 && (filp->f_mode & (FMODE_READ|FMODE_WRITE))) {
912 check_disk_change(inode->i_bdev); 912 check_disk_change(inode->i_bdev);
913 if (fs->ejected) 913 if (fs->ejected)
914 err = -ENXIO; 914 err = -ENXIO;
915 } 915 }
916 916
917 if (err == 0 && (filp->f_mode & 2)) { 917 if (err == 0 && (filp->f_mode & FMODE_WRITE)) {
918 if (fs->write_prot < 0) 918 if (fs->write_prot < 0)
919 fs->write_prot = swim3_readbit(fs, WRITE_PROT); 919 fs->write_prot = swim3_readbit(fs, WRITE_PROT);
920 if (fs->write_prot) 920 if (fs->write_prot)
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
index 39f6357e3b5d..8054ee839b3c 100644
--- a/drivers/char/nvram.c
+++ b/drivers/char/nvram.c
@@ -338,7 +338,7 @@ nvram_open(struct inode *inode, struct file *file)
338 338
339 if ((nvram_open_cnt && (file->f_flags & O_EXCL)) || 339 if ((nvram_open_cnt && (file->f_flags & O_EXCL)) ||
340 (nvram_open_mode & NVRAM_EXCL) || 340 (nvram_open_mode & NVRAM_EXCL) ||
341 ((file->f_mode & 2) && (nvram_open_mode & NVRAM_WRITE))) { 341 ((file->f_mode & FMODE_WRITE) && (nvram_open_mode & NVRAM_WRITE))) {
342 spin_unlock(&nvram_state_lock); 342 spin_unlock(&nvram_state_lock);
343 unlock_kernel(); 343 unlock_kernel();
344 return -EBUSY; 344 return -EBUSY;
@@ -346,7 +346,7 @@ nvram_open(struct inode *inode, struct file *file)
346 346
347 if (file->f_flags & O_EXCL) 347 if (file->f_flags & O_EXCL)
348 nvram_open_mode |= NVRAM_EXCL; 348 nvram_open_mode |= NVRAM_EXCL;
349 if (file->f_mode & 2) 349 if (file->f_mode & FMODE_WRITE)
350 nvram_open_mode |= NVRAM_WRITE; 350 nvram_open_mode |= NVRAM_WRITE;
351 nvram_open_cnt++; 351 nvram_open_cnt++;
352 352
@@ -366,7 +366,7 @@ nvram_release(struct inode *inode, struct file *file)
366 /* if only one instance is open, clear the EXCL bit */ 366 /* if only one instance is open, clear the EXCL bit */
367 if (nvram_open_mode & NVRAM_EXCL) 367 if (nvram_open_mode & NVRAM_EXCL)
368 nvram_open_mode &= ~NVRAM_EXCL; 368 nvram_open_mode &= ~NVRAM_EXCL;
369 if (file->f_mode & 2) 369 if (file->f_mode & FMODE_WRITE)
370 nvram_open_mode &= ~NVRAM_WRITE; 370 nvram_open_mode &= ~NVRAM_WRITE;
371 371
372 spin_unlock(&nvram_state_lock); 372 spin_unlock(&nvram_state_lock);
diff --git a/drivers/ide/ide-floppy_ioctl.c b/drivers/ide/ide-floppy_ioctl.c
index 409e4c15f9b7..0d5f5054ab64 100644
--- a/drivers/ide/ide-floppy_ioctl.c
+++ b/drivers/ide/ide-floppy_ioctl.c
@@ -250,7 +250,7 @@ static int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file,
250 case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY: 250 case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY:
251 return ide_floppy_get_format_capacities(drive, argp); 251 return ide_floppy_get_format_capacities(drive, argp);
252 case IDEFLOPPY_IOCTL_FORMAT_START: 252 case IDEFLOPPY_IOCTL_FORMAT_START:
253 if (!(file->f_mode & 2)) 253 if (!(file->f_mode & FMODE_WRITE))
254 return -EPERM; 254 return -EPERM;
255 return ide_floppy_format_unit(drive, (int __user *)argp); 255 return ide_floppy_format_unit(drive, (int __user *)argp);
256 case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS: 256 case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS:
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
index d44898f46c33..d367473098f9 100644
--- a/drivers/ide/ide-gd.c
+++ b/drivers/ide/ide-gd.c
@@ -202,7 +202,7 @@ static int ide_gd_open(struct inode *inode, struct file *filp)
202 goto out_put_idkp; 202 goto out_put_idkp;
203 } 203 }
204 204
205 if ((drive->dev_flags & IDE_DFLAG_WP) && (filp->f_mode & 2)) { 205 if ((drive->dev_flags & IDE_DFLAG_WP) && (filp->f_mode & FMODE_WRITE)) {
206 ret = -EROFS; 206 ret = -EROFS;
207 goto out_put_idkp; 207 goto out_put_idkp;
208 } 208 }
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index dca401dc70a0..777c948180f9 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -988,9 +988,9 @@ static int dev_wait(struct dm_ioctl *param, size_t param_size)
988 return r; 988 return r;
989} 989}
990 990
991static inline int get_mode(struct dm_ioctl *param) 991static inline fmode_t get_mode(struct dm_ioctl *param)
992{ 992{
993 int mode = FMODE_READ | FMODE_WRITE; 993 fmode_t mode = FMODE_READ | FMODE_WRITE;
994 994
995 if (param->flags & DM_READONLY_FLAG) 995 if (param->flags & DM_READONLY_FLAG)
996 mode = FMODE_READ; 996 mode = FMODE_READ;
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index a740a6950f59..7c8671b06fe3 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -43,7 +43,7 @@ struct dm_table {
43 * device. This should be a combination of FMODE_READ 43 * device. This should be a combination of FMODE_READ
44 * and FMODE_WRITE. 44 * and FMODE_WRITE.
45 */ 45 */
46 int mode; 46 fmode_t mode;
47 47
48 /* a list of devices used by this table */ 48 /* a list of devices used by this table */
49 struct list_head devices; 49 struct list_head devices;
@@ -217,7 +217,7 @@ static int alloc_targets(struct dm_table *t, unsigned int num)
217 return 0; 217 return 0;
218} 218}
219 219
220int dm_table_create(struct dm_table **result, int mode, 220int dm_table_create(struct dm_table **result, fmode_t mode,
221 unsigned num_targets, struct mapped_device *md) 221 unsigned num_targets, struct mapped_device *md)
222{ 222{
223 struct dm_table *t = kzalloc(sizeof(*t), GFP_KERNEL); 223 struct dm_table *t = kzalloc(sizeof(*t), GFP_KERNEL);
@@ -395,7 +395,7 @@ static int check_device_area(struct dm_dev_internal *dd, sector_t start,
395 * careful to leave things as they were if we fail to reopen the 395 * careful to leave things as they were if we fail to reopen the
396 * device. 396 * device.
397 */ 397 */
398static int upgrade_mode(struct dm_dev_internal *dd, int new_mode, 398static int upgrade_mode(struct dm_dev_internal *dd, fmode_t new_mode,
399 struct mapped_device *md) 399 struct mapped_device *md)
400{ 400{
401 int r; 401 int r;
@@ -421,7 +421,7 @@ static int upgrade_mode(struct dm_dev_internal *dd, int new_mode,
421 */ 421 */
422static int __table_get_device(struct dm_table *t, struct dm_target *ti, 422static int __table_get_device(struct dm_table *t, struct dm_target *ti,
423 const char *path, sector_t start, sector_t len, 423 const char *path, sector_t start, sector_t len,
424 int mode, struct dm_dev **result) 424 fmode_t mode, struct dm_dev **result)
425{ 425{
426 int r; 426 int r;
427 dev_t uninitialized_var(dev); 427 dev_t uninitialized_var(dev);
@@ -537,7 +537,7 @@ void dm_set_device_limits(struct dm_target *ti, struct block_device *bdev)
537EXPORT_SYMBOL_GPL(dm_set_device_limits); 537EXPORT_SYMBOL_GPL(dm_set_device_limits);
538 538
539int dm_get_device(struct dm_target *ti, const char *path, sector_t start, 539int dm_get_device(struct dm_target *ti, const char *path, sector_t start,
540 sector_t len, int mode, struct dm_dev **result) 540 sector_t len, fmode_t mode, struct dm_dev **result)
541{ 541{
542 int r = __table_get_device(ti->table, ti, path, 542 int r = __table_get_device(ti->table, ti, path,
543 start, len, mode, result); 543 start, len, mode, result);
@@ -887,7 +887,7 @@ struct list_head *dm_table_get_devices(struct dm_table *t)
887 return &t->devices; 887 return &t->devices;
888} 888}
889 889
890int dm_table_get_mode(struct dm_table *t) 890fmode_t dm_table_get_mode(struct dm_table *t)
891{ 891{
892 return t->mode; 892 return t->mode;
893} 893}
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 963840e9b5bf..bcffeda2df3d 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -96,7 +96,7 @@ static int mtd_open(struct inode *inode, struct file *file)
96 return -ENODEV; 96 return -ENODEV;
97 97
98 /* You can't open the RO devices RW */ 98 /* You can't open the RO devices RW */
99 if ((file->f_mode & 2) && (minor & 1)) 99 if ((file->f_mode & FMODE_WRITE) && (minor & 1))
100 return -EACCES; 100 return -EACCES;
101 101
102 lock_kernel(); 102 lock_kernel();
@@ -114,7 +114,7 @@ static int mtd_open(struct inode *inode, struct file *file)
114 } 114 }
115 115
116 /* You can't open it RW if it's not a writeable device */ 116 /* You can't open it RW if it's not a writeable device */
117 if ((file->f_mode & 2) && !(mtd->flags & MTD_WRITEABLE)) { 117 if ((file->f_mode & FMODE_WRITE) && !(mtd->flags & MTD_WRITEABLE)) {
118 put_mtd_device(mtd); 118 put_mtd_device(mtd);
119 ret = -EACCES; 119 ret = -EACCES;
120 goto out; 120 goto out;
@@ -144,7 +144,7 @@ static int mtd_close(struct inode *inode, struct file *file)
144 DEBUG(MTD_DEBUG_LEVEL0, "MTD_close\n"); 144 DEBUG(MTD_DEBUG_LEVEL0, "MTD_close\n");
145 145
146 /* Only sync if opened RW */ 146 /* Only sync if opened RW */
147 if ((file->f_mode & 2) && mtd->sync) 147 if ((file->f_mode & FMODE_WRITE) && mtd->sync)
148 mtd->sync(mtd); 148 mtd->sync(mtd);
149 149
150 put_mtd_device(mtd); 150 put_mtd_device(mtd);
@@ -443,7 +443,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
443 { 443 {
444 struct erase_info *erase; 444 struct erase_info *erase;
445 445
446 if(!(file->f_mode & 2)) 446 if(!(file->f_mode & FMODE_WRITE))
447 return -EPERM; 447 return -EPERM;
448 448
449 erase=kzalloc(sizeof(struct erase_info),GFP_KERNEL); 449 erase=kzalloc(sizeof(struct erase_info),GFP_KERNEL);
@@ -497,7 +497,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
497 struct mtd_oob_buf __user *user_buf = argp; 497 struct mtd_oob_buf __user *user_buf = argp;
498 uint32_t retlen; 498 uint32_t retlen;
499 499
500 if(!(file->f_mode & 2)) 500 if(!(file->f_mode & FMODE_WRITE))
501 return -EPERM; 501 return -EPERM;
502 502
503 if (copy_from_user(&buf, argp, sizeof(struct mtd_oob_buf))) 503 if (copy_from_user(&buf, argp, sizeof(struct mtd_oob_buf)))
diff --git a/drivers/parisc/eisa_eeprom.c b/drivers/parisc/eisa_eeprom.c
index 5ac207932fd7..685d94e69d44 100644
--- a/drivers/parisc/eisa_eeprom.c
+++ b/drivers/parisc/eisa_eeprom.c
@@ -86,7 +86,7 @@ static int eisa_eeprom_open(struct inode *inode, struct file *file)
86{ 86{
87 cycle_kernel_lock(); 87 cycle_kernel_lock();
88 88
89 if (file->f_mode & 2) 89 if (file->f_mode & FMODE_WRITE)
90 return -EINVAL; 90 return -EINVAL;
91 91
92 return 0; 92 return 0;
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 218408eed1bb..8897f3b02e98 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -840,7 +840,7 @@ EXPORT_SYMBOL_GPL(bd_release_from_disk);
840 * to be used for internal purposes. If you ever need it - reconsider 840 * to be used for internal purposes. If you ever need it - reconsider
841 * your API. 841 * your API.
842 */ 842 */
843struct block_device *open_by_devnum(dev_t dev, unsigned mode) 843struct block_device *open_by_devnum(dev_t dev, fmode_t mode)
844{ 844{
845 struct block_device *bdev = bdget(dev); 845 struct block_device *bdev = bdget(dev);
846 int err = -ENOMEM; 846 int err = -ENOMEM;
@@ -975,7 +975,7 @@ void bd_set_size(struct block_device *bdev, loff_t size)
975} 975}
976EXPORT_SYMBOL(bd_set_size); 976EXPORT_SYMBOL(bd_set_size);
977 977
978static int __blkdev_get(struct block_device *bdev, mode_t mode, unsigned flags, 978static int __blkdev_get(struct block_device *bdev, fmode_t mode, unsigned flags,
979 int for_part); 979 int for_part);
980static int __blkdev_put(struct block_device *bdev, int for_part); 980static int __blkdev_put(struct block_device *bdev, int for_part);
981 981
@@ -1104,7 +1104,7 @@ static int do_open(struct block_device *bdev, struct file *file, int for_part)
1104 return ret; 1104 return ret;
1105} 1105}
1106 1106
1107static int __blkdev_get(struct block_device *bdev, mode_t mode, unsigned flags, 1107static int __blkdev_get(struct block_device *bdev, fmode_t mode, unsigned flags,
1108 int for_part) 1108 int for_part)
1109{ 1109{
1110 /* 1110 /*
@@ -1123,7 +1123,7 @@ static int __blkdev_get(struct block_device *bdev, mode_t mode, unsigned flags,
1123 return do_open(bdev, &fake_file, for_part); 1123 return do_open(bdev, &fake_file, for_part);
1124} 1124}
1125 1125
1126int blkdev_get(struct block_device *bdev, mode_t mode, unsigned flags) 1126int blkdev_get(struct block_device *bdev, fmode_t mode, unsigned flags)
1127{ 1127{
1128 return __blkdev_get(bdev, mode, flags, 0); 1128 return __blkdev_get(bdev, mode, flags, 0);
1129} 1129}
@@ -1315,7 +1315,7 @@ EXPORT_SYMBOL(lookup_bdev);
1315struct block_device *open_bdev_excl(const char *path, int flags, void *holder) 1315struct block_device *open_bdev_excl(const char *path, int flags, void *holder)
1316{ 1316{
1317 struct block_device *bdev; 1317 struct block_device *bdev;
1318 mode_t mode = FMODE_READ; 1318 fmode_t mode = FMODE_READ;
1319 int error = 0; 1319 int error = 0;
1320 1320
1321 bdev = lookup_bdev(path); 1321 bdev = lookup_bdev(path);
diff --git a/fs/fifo.c b/fs/fifo.c
index 987bf9411495..f8f97b8b6d44 100644
--- a/fs/fifo.c
+++ b/fs/fifo.c
@@ -51,7 +51,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
51 filp->f_mode &= (FMODE_READ | FMODE_WRITE); 51 filp->f_mode &= (FMODE_READ | FMODE_WRITE);
52 52
53 switch (filp->f_mode) { 53 switch (filp->f_mode) {
54 case 1: 54 case FMODE_READ:
55 /* 55 /*
56 * O_RDONLY 56 * O_RDONLY
57 * POSIX.1 says that O_NONBLOCK means return with the FIFO 57 * POSIX.1 says that O_NONBLOCK means return with the FIFO
@@ -76,7 +76,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
76 } 76 }
77 break; 77 break;
78 78
79 case 2: 79 case FMODE_WRITE:
80 /* 80 /*
81 * O_WRONLY 81 * O_WRONLY
82 * POSIX.1 says that O_NONBLOCK means return -1 with 82 * POSIX.1 says that O_NONBLOCK means return -1 with
@@ -98,7 +98,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
98 } 98 }
99 break; 99 break;
100 100
101 case 3: 101 case FMODE_READ | FMODE_WRITE:
102 /* 102 /*
103 * O_RDWR 103 * O_RDWR
104 * POSIX.1 leaves this case "undefined" when O_NONBLOCK is set. 104 * POSIX.1 leaves this case "undefined" when O_NONBLOCK is set.
diff --git a/fs/file_table.c b/fs/file_table.c
index f45a4493f9e7..efc06faede6c 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -161,7 +161,7 @@ EXPORT_SYMBOL(get_empty_filp);
161 * code should be moved into this function. 161 * code should be moved into this function.
162 */ 162 */
163struct file *alloc_file(struct vfsmount *mnt, struct dentry *dentry, 163struct file *alloc_file(struct vfsmount *mnt, struct dentry *dentry,
164 mode_t mode, const struct file_operations *fop) 164 fmode_t mode, const struct file_operations *fop)
165{ 165{
166 struct file *file; 166 struct file *file;
167 struct path; 167 struct path;
@@ -193,7 +193,7 @@ EXPORT_SYMBOL(alloc_file);
193 * of this should be moving to alloc_file(). 193 * of this should be moving to alloc_file().
194 */ 194 */
195int init_file(struct file *file, struct vfsmount *mnt, struct dentry *dentry, 195int init_file(struct file *file, struct vfsmount *mnt, struct dentry *dentry,
196 mode_t mode, const struct file_operations *fop) 196 fmode_t mode, const struct file_operations *fop)
197{ 197{
198 int error = 0; 198 int error = 0;
199 file->f_path.dentry = dentry; 199 file->f_path.dentry = dentry;
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index d6ecabf4d231..7f34f4385de0 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -20,7 +20,7 @@
20struct hostfs_inode_info { 20struct hostfs_inode_info {
21 char *host_filename; 21 char *host_filename;
22 int fd; 22 int fd;
23 int mode; 23 fmode_t mode;
24 struct inode vfs_inode; 24 struct inode vfs_inode;
25}; 25};
26 26
@@ -373,7 +373,8 @@ int hostfs_readdir(struct file *file, void *ent, filldir_t filldir)
373int hostfs_file_open(struct inode *ino, struct file *file) 373int hostfs_file_open(struct inode *ino, struct file *file)
374{ 374{
375 char *name; 375 char *name;
376 int mode = 0, r = 0, w = 0, fd; 376 fmode_t mode = 0;
377 int r = 0, w = 0, fd;
377 378
378 mode = file->f_mode & (FMODE_READ | FMODE_WRITE); 379 mode = file->f_mode & (FMODE_READ | FMODE_WRITE);
379 if ((mode & HOSTFS_I(ino)->mode) == mode) 380 if ((mode & HOSTFS_I(ino)->mode) == mode)
diff --git a/fs/locks.c b/fs/locks.c
index 5eb259e3cd38..20457486d6b2 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1580,7 +1580,8 @@ asmlinkage long sys_flock(unsigned int fd, unsigned int cmd)
1580 cmd &= ~LOCK_NB; 1580 cmd &= ~LOCK_NB;
1581 unlock = (cmd == LOCK_UN); 1581 unlock = (cmd == LOCK_UN);
1582 1582
1583 if (!unlock && !(cmd & LOCK_MAND) && !(filp->f_mode & 3)) 1583 if (!unlock && !(cmd & LOCK_MAND) &&
1584 !(filp->f_mode & (FMODE_READ|FMODE_WRITE)))
1584 goto out_putf; 1585 goto out_putf;
1585 1586
1586 error = flock_make_lock(filp, &lock, cmd); 1587 error = flock_make_lock(filp, &lock, cmd);
diff --git a/fs/open.c b/fs/open.c
index 5596049863bf..83cdb9dee0c1 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -798,7 +798,7 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
798 int error; 798 int error;
799 799
800 f->f_flags = flags; 800 f->f_flags = flags;
801 f->f_mode = ((flags+1) & O_ACCMODE) | FMODE_LSEEK | 801 f->f_mode = (__force fmode_t)((flags+1) & O_ACCMODE) | FMODE_LSEEK |
802 FMODE_PREAD | FMODE_PWRITE; 802 FMODE_PREAD | FMODE_PWRITE;
803 inode = dentry->d_inode; 803 inode = dentry->d_inode;
804 if (f->f_mode & FMODE_WRITE) { 804 if (f->f_mode & FMODE_WRITE) {
diff --git a/fs/proc/base.c b/fs/proc/base.c
index b5918ae8ca79..486cf3fe7139 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1712,9 +1712,9 @@ static struct dentry *proc_fd_instantiate(struct inode *dir,
1712 file = fcheck_files(files, fd); 1712 file = fcheck_files(files, fd);
1713 if (!file) 1713 if (!file)
1714 goto out_unlock; 1714 goto out_unlock;
1715 if (file->f_mode & 1) 1715 if (file->f_mode & FMODE_READ)
1716 inode->i_mode |= S_IRUSR | S_IXUSR; 1716 inode->i_mode |= S_IRUSR | S_IXUSR;
1717 if (file->f_mode & 2) 1717 if (file->f_mode & FMODE_WRITE)
1718 inode->i_mode |= S_IWUSR | S_IXUSR; 1718 inode->i_mode |= S_IWUSR | S_IXUSR;
1719 spin_unlock(&files->file_lock); 1719 spin_unlock(&files->file_lock);
1720 put_files_struct(files); 1720 put_files_struct(files);
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index c21df71943a6..b89d193a00d9 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -2593,7 +2593,7 @@ static int journal_init_dev(struct super_block *super,
2593{ 2593{
2594 int result; 2594 int result;
2595 dev_t jdev; 2595 dev_t jdev;
2596 int blkdev_mode = FMODE_READ | FMODE_WRITE; 2596 fmode_t blkdev_mode = FMODE_READ | FMODE_WRITE;
2597 char b[BDEVNAME_SIZE]; 2597 char b[BDEVNAME_SIZE];
2598 2598
2599 result = 0; 2599 result = 0;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index b4fe68fe3a57..a4413ec3cb3a 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -910,7 +910,8 @@ static inline int sb_issue_discard(struct super_block *sb,
910* command filter functions 910* command filter functions
911*/ 911*/
912extern int blk_verify_command(struct blk_cmd_filter *filter, 912extern int blk_verify_command(struct blk_cmd_filter *filter,
913 unsigned char *cmd, int has_write_perm); 913 unsigned char *cmd, fmode_t has_write_perm);
914extern void blk_unregister_filter(struct gendisk *disk);
914extern void blk_set_cmd_filter_defaults(struct blk_cmd_filter *filter); 915extern void blk_set_cmd_filter_defaults(struct blk_cmd_filter *filter);
915 916
916#define MAX_PHYS_SEGMENTS 128 917#define MAX_PHYS_SEGMENTS 128
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 08d783592b73..3f8d4e763672 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -85,7 +85,7 @@ void dm_set_device_limits(struct dm_target *ti, struct block_device *bdev);
85 85
86struct dm_dev { 86struct dm_dev {
87 struct block_device *bdev; 87 struct block_device *bdev;
88 int mode; 88 fmode_t mode;
89 char name[16]; 89 char name[16];
90}; 90};
91 91
@@ -95,7 +95,7 @@ struct dm_dev {
95 * FIXME: too many arguments. 95 * FIXME: too many arguments.
96 */ 96 */
97int dm_get_device(struct dm_target *ti, const char *path, sector_t start, 97int dm_get_device(struct dm_target *ti, const char *path, sector_t start,
98 sector_t len, int mode, struct dm_dev **result); 98 sector_t len, fmode_t mode, struct dm_dev **result);
99void dm_put_device(struct dm_target *ti, struct dm_dev *d); 99void dm_put_device(struct dm_target *ti, struct dm_dev *d);
100 100
101/* 101/*
@@ -223,7 +223,7 @@ int dm_set_geometry(struct mapped_device *md, struct hd_geometry *geo);
223/* 223/*
224 * First create an empty table. 224 * First create an empty table.
225 */ 225 */
226int dm_table_create(struct dm_table **result, int mode, 226int dm_table_create(struct dm_table **result, fmode_t mode,
227 unsigned num_targets, struct mapped_device *md); 227 unsigned num_targets, struct mapped_device *md);
228 228
229/* 229/*
@@ -254,7 +254,7 @@ void dm_table_put(struct dm_table *t);
254 */ 254 */
255sector_t dm_table_get_size(struct dm_table *t); 255sector_t dm_table_get_size(struct dm_table *t);
256unsigned int dm_table_get_num_targets(struct dm_table *t); 256unsigned int dm_table_get_num_targets(struct dm_table *t);
257int dm_table_get_mode(struct dm_table *t); 257fmode_t dm_table_get_mode(struct dm_table *t);
258struct mapped_device *dm_table_get_md(struct dm_table *t); 258struct mapped_device *dm_table_get_md(struct dm_table *t);
259 259
260/* 260/*
diff --git a/include/linux/file.h b/include/linux/file.h
index a20259e248a5..335a0a5c316e 100644
--- a/include/linux/file.h
+++ b/include/linux/file.h
@@ -19,10 +19,10 @@ struct file_operations;
19struct vfsmount; 19struct vfsmount;
20struct dentry; 20struct dentry;
21extern int init_file(struct file *, struct vfsmount *mnt, 21extern int init_file(struct file *, struct vfsmount *mnt,
22 struct dentry *dentry, mode_t mode, 22 struct dentry *dentry, fmode_t mode,
23 const struct file_operations *fop); 23 const struct file_operations *fop);
24extern struct file *alloc_file(struct vfsmount *, struct dentry *dentry, 24extern struct file *alloc_file(struct vfsmount *, struct dentry *dentry,
25 mode_t mode, const struct file_operations *fop); 25 fmode_t mode, const struct file_operations *fop);
26 26
27static inline void fput_light(struct file *file, int fput_needed) 27static inline void fput_light(struct file *file, int fput_needed)
28{ 28{
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a6a625be13fc..60a7a581ba91 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -63,18 +63,18 @@ extern int dir_notify_enable;
63#define MAY_ACCESS 16 63#define MAY_ACCESS 16
64#define MAY_OPEN 32 64#define MAY_OPEN 32
65 65
66#define FMODE_READ 1 66#define FMODE_READ ((__force fmode_t)1)
67#define FMODE_WRITE 2 67#define FMODE_WRITE ((__force fmode_t)2)
68 68
69/* Internal kernel extensions */ 69/* Internal kernel extensions */
70#define FMODE_LSEEK 4 70#define FMODE_LSEEK ((__force fmode_t)4)
71#define FMODE_PREAD 8 71#define FMODE_PREAD ((__force fmode_t)8)
72#define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */ 72#define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */
73 73
74/* File is being opened for execution. Primary users of this flag are 74/* File is being opened for execution. Primary users of this flag are
75 distributed filesystems that can use it to achieve correct ETXTBUSY 75 distributed filesystems that can use it to achieve correct ETXTBUSY
76 behavior for cross-node execution/opening_for_writing of files */ 76 behavior for cross-node execution/opening_for_writing of files */
77#define FMODE_EXEC 16 77#define FMODE_EXEC ((__force fmode_t)16)
78 78
79#define RW_MASK 1 79#define RW_MASK 1
80#define RWA_MASK 2 80#define RWA_MASK 2
@@ -825,7 +825,7 @@ struct file {
825 const struct file_operations *f_op; 825 const struct file_operations *f_op;
826 atomic_long_t f_count; 826 atomic_long_t f_count;
827 unsigned int f_flags; 827 unsigned int f_flags;
828 mode_t f_mode; 828 fmode_t f_mode;
829 loff_t f_pos; 829 loff_t f_pos;
830 struct fown_struct f_owner; 830 struct fown_struct f_owner;
831 unsigned int f_uid, f_gid; 831 unsigned int f_uid, f_gid;
@@ -1714,7 +1714,7 @@ extern struct block_device *bdget(dev_t);
1714extern void bd_set_size(struct block_device *, loff_t size); 1714extern void bd_set_size(struct block_device *, loff_t size);
1715extern void bd_forget(struct inode *inode); 1715extern void bd_forget(struct inode *inode);
1716extern void bdput(struct block_device *); 1716extern void bdput(struct block_device *);
1717extern struct block_device *open_by_devnum(dev_t, unsigned); 1717extern struct block_device *open_by_devnum(dev_t, fmode_t);
1718#else 1718#else
1719static inline void bd_forget(struct inode *inode) {} 1719static inline void bd_forget(struct inode *inode) {}
1720#endif 1720#endif
@@ -1729,7 +1729,7 @@ extern int blkdev_driver_ioctl(struct inode *inode, struct file *file,
1729 struct gendisk *disk, unsigned cmd, 1729 struct gendisk *disk, unsigned cmd,
1730 unsigned long arg); 1730 unsigned long arg);
1731extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long); 1731extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long);
1732extern int blkdev_get(struct block_device *, mode_t, unsigned); 1732extern int blkdev_get(struct block_device *, fmode_t, unsigned);
1733extern int blkdev_put(struct block_device *); 1733extern int blkdev_put(struct block_device *);
1734extern int bd_claim(struct block_device *, void *); 1734extern int bd_claim(struct block_device *, void *);
1735extern void bd_release(struct block_device *); 1735extern void bd_release(struct block_device *);
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index a89513188ce7..00fbd5b245c9 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -188,7 +188,7 @@ static inline void fsnotify_close(struct file *file)
188 struct dentry *dentry = file->f_path.dentry; 188 struct dentry *dentry = file->f_path.dentry;
189 struct inode *inode = dentry->d_inode; 189 struct inode *inode = dentry->d_inode;
190 const char *name = dentry->d_name.name; 190 const char *name = dentry->d_name.name;
191 mode_t mode = file->f_mode; 191 fmode_t mode = file->f_mode;
192 u32 mask = (mode & FMODE_WRITE) ? IN_CLOSE_WRITE : IN_CLOSE_NOWRITE; 192 u32 mask = (mode & FMODE_WRITE) ? IN_CLOSE_WRITE : IN_CLOSE_NOWRITE;
193 193
194 if (S_ISDIR(inode->i_mode)) 194 if (S_ISDIR(inode->i_mode))
diff --git a/include/linux/types.h b/include/linux/types.h
index f24f7beb47df..1d98330b1f2c 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -190,6 +190,7 @@ typedef __u32 __bitwise __wsum;
190 190
191#ifdef __KERNEL__ 191#ifdef __KERNEL__
192typedef unsigned __bitwise__ gfp_t; 192typedef unsigned __bitwise__ gfp_t;
193typedef unsigned __bitwise__ fmode_t;
193 194
194#ifdef CONFIG_PHYS_ADDR_T_64BIT 195#ifdef CONFIG_PHYS_ADDR_T_64BIT
195typedef u64 phys_addr_t; 196typedef u64 phys_addr_t;
diff --git a/ipc/shm.c b/ipc/shm.c
index 0add3fa5f547..867e5d6a55c2 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -817,7 +817,7 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
817 struct ipc_namespace *ns; 817 struct ipc_namespace *ns;
818 struct shm_file_data *sfd; 818 struct shm_file_data *sfd;
819 struct path path; 819 struct path path;
820 mode_t f_mode; 820 fmode_t f_mode;
821 821
822 err = -EINVAL; 822 err = -EINVAL;
823 if (shmid < 0) 823 if (shmid < 0)
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 1af62b8b86c6..e17836680f49 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -2283,7 +2283,7 @@ static int snd_pcm_oss_open_file(struct file *file,
2283 int idx, err; 2283 int idx, err;
2284 struct snd_pcm_oss_file *pcm_oss_file; 2284 struct snd_pcm_oss_file *pcm_oss_file;
2285 struct snd_pcm_substream *substream; 2285 struct snd_pcm_substream *substream;
2286 unsigned int f_mode = file->f_mode; 2286 fmode_t f_mode = file->f_mode;
2287 2287
2288 if (rpcm_oss_file) 2288 if (rpcm_oss_file)
2289 *rpcm_oss_file = NULL; 2289 *rpcm_oss_file = NULL;
diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c
index 23018a7c063a..81e1f443d094 100644
--- a/sound/oss/au1550_ac97.c
+++ b/sound/oss/au1550_ac97.c
@@ -93,7 +93,7 @@ static struct au1550_state {
93 spinlock_t lock; 93 spinlock_t lock;
94 struct mutex open_mutex; 94 struct mutex open_mutex;
95 struct mutex sem; 95 struct mutex sem;
96 mode_t open_mode; 96 fmode_t open_mode;
97 wait_queue_head_t open_wait; 97 wait_queue_head_t open_wait;
98 98
99 struct dmabuf { 99 struct dmabuf {
diff --git a/sound/oss/dmasound/dmasound.h b/sound/oss/dmasound/dmasound.h
index d978b0096564..1cb13fe56ec4 100644
--- a/sound/oss/dmasound/dmasound.h
+++ b/sound/oss/dmasound/dmasound.h
@@ -129,7 +129,7 @@ typedef struct {
129 int (*mixer_ioctl)(u_int, u_long); /* optional */ 129 int (*mixer_ioctl)(u_int, u_long); /* optional */
130 int (*write_sq_setup)(void); /* optional */ 130 int (*write_sq_setup)(void); /* optional */
131 int (*read_sq_setup)(void); /* optional */ 131 int (*read_sq_setup)(void); /* optional */
132 int (*sq_open)(mode_t); /* optional */ 132 int (*sq_open)(fmode_t); /* optional */
133 int (*state_info)(char *, size_t); /* optional */ 133 int (*state_info)(char *, size_t); /* optional */
134 void (*abort_read)(void); /* optional */ 134 void (*abort_read)(void); /* optional */
135 int min_dsp_speed; 135 int min_dsp_speed;
@@ -235,7 +235,7 @@ struct sound_queue {
235 */ 235 */
236 int active; 236 int active;
237 wait_queue_head_t action_queue, open_queue, sync_queue; 237 wait_queue_head_t action_queue, open_queue, sync_queue;
238 int open_mode; 238 fmode_t open_mode;
239 int busy, syncing, xruns, died; 239 int busy, syncing, xruns, died;
240}; 240};
241 241
diff --git a/sound/oss/dmasound/dmasound_atari.c b/sound/oss/dmasound/dmasound_atari.c
index 285239d64b82..4d45bd63718b 100644
--- a/sound/oss/dmasound/dmasound_atari.c
+++ b/sound/oss/dmasound/dmasound_atari.c
@@ -143,7 +143,7 @@ static int AtaMixerIoctl(u_int cmd, u_long arg);
143static int TTMixerIoctl(u_int cmd, u_long arg); 143static int TTMixerIoctl(u_int cmd, u_long arg);
144static int FalconMixerIoctl(u_int cmd, u_long arg); 144static int FalconMixerIoctl(u_int cmd, u_long arg);
145static int AtaWriteSqSetup(void); 145static int AtaWriteSqSetup(void);
146static int AtaSqOpen(mode_t mode); 146static int AtaSqOpen(fmode_t mode);
147static int TTStateInfo(char *buffer, size_t space); 147static int TTStateInfo(char *buffer, size_t space);
148static int FalconStateInfo(char *buffer, size_t space); 148static int FalconStateInfo(char *buffer, size_t space);
149 149
@@ -1461,7 +1461,7 @@ static int AtaWriteSqSetup(void)
1461 return 0 ; 1461 return 0 ;
1462} 1462}
1463 1463
1464static int AtaSqOpen(mode_t mode) 1464static int AtaSqOpen(fmode_t mode)
1465{ 1465{
1466 write_sq_ignore_int = 1; 1466 write_sq_ignore_int = 1;
1467 return 0 ; 1467 return 0 ;
diff --git a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c
index 95fc5c681755..b8239f3168fb 100644
--- a/sound/oss/dmasound/dmasound_core.c
+++ b/sound/oss/dmasound/dmasound_core.c
@@ -212,7 +212,7 @@ static int irq_installed;
212#endif /* MODULE */ 212#endif /* MODULE */
213 213
214/* control over who can modify resources shared between play/record */ 214/* control over who can modify resources shared between play/record */
215static mode_t shared_resource_owner; 215static fmode_t shared_resource_owner;
216static int shared_resources_initialised; 216static int shared_resources_initialised;
217 217
218 /* 218 /*
@@ -668,7 +668,7 @@ static inline void sq_init_waitqueue(struct sound_queue *sq)
668 668
669#if 0 /* blocking open() */ 669#if 0 /* blocking open() */
670static inline void sq_wake_up(struct sound_queue *sq, struct file *file, 670static inline void sq_wake_up(struct sound_queue *sq, struct file *file,
671 mode_t mode) 671 fmode_t mode)
672{ 672{
673 if (file->f_mode & mode) { 673 if (file->f_mode & mode) {
674 sq->busy = 0; /* CHECK: IS THIS OK??? */ 674 sq->busy = 0; /* CHECK: IS THIS OK??? */
@@ -677,7 +677,7 @@ static inline void sq_wake_up(struct sound_queue *sq, struct file *file,
677} 677}
678#endif 678#endif
679 679
680static int sq_open2(struct sound_queue *sq, struct file *file, mode_t mode, 680static int sq_open2(struct sound_queue *sq, struct file *file, fmode_t mode,
681 int numbufs, int bufsize) 681 int numbufs, int bufsize)
682{ 682{
683 int rc = 0; 683 int rc = 0;
@@ -891,10 +891,10 @@ static int sq_release(struct inode *inode, struct file *file)
891 is the owner - if we have problems. 891 is the owner - if we have problems.
892*/ 892*/
893 893
894static int shared_resources_are_mine(mode_t md) 894static int shared_resources_are_mine(fmode_t md)
895{ 895{
896 if (shared_resource_owner) 896 if (shared_resource_owner)
897 return (shared_resource_owner & md ) ; 897 return (shared_resource_owner & md) != 0;
898 else { 898 else {
899 shared_resource_owner = md ; 899 shared_resource_owner = md ;
900 return 1 ; 900 return 1 ;
diff --git a/sound/oss/msnd.h b/sound/oss/msnd.h
index 61b3955481c5..c8be47ec2b7e 100644
--- a/sound/oss/msnd.h
+++ b/sound/oss/msnd.h
@@ -211,7 +211,7 @@ typedef struct multisound_dev {
211 211
212 /* State variables */ 212 /* State variables */
213 enum { msndClassic, msndPinnacle } type; 213 enum { msndClassic, msndPinnacle } type;
214 mode_t mode; 214 fmode_t mode;
215 unsigned long flags; 215 unsigned long flags;
216#define F_RESETTING 0 216#define F_RESETTING 0
217#define F_HAVEDIGITAL 1 217#define F_HAVEDIGITAL 1
diff --git a/sound/oss/sound_config.h b/sound/oss/sound_config.h
index 1a00a3210616..55271fbe7f49 100644
--- a/sound/oss/sound_config.h
+++ b/sound/oss/sound_config.h
@@ -110,24 +110,16 @@ struct channel_info {
110#define OPEN_WRITE PCM_ENABLE_OUTPUT 110#define OPEN_WRITE PCM_ENABLE_OUTPUT
111#define OPEN_READWRITE (OPEN_READ|OPEN_WRITE) 111#define OPEN_READWRITE (OPEN_READ|OPEN_WRITE)
112 112
113#if OPEN_READ == FMODE_READ && OPEN_WRITE == FMODE_WRITE
114
115static inline int translate_mode(struct file *file)
116{
117 return file->f_mode;
118}
119
120#else
121
122static inline int translate_mode(struct file *file) 113static inline int translate_mode(struct file *file)
123{ 114{
124 return ((file->f_mode & FMODE_READ) ? OPEN_READ : 0) | 115 if (OPEN_READ == (__force int)FMODE_READ &&
125 ((file->f_mode & FMODE_WRITE) ? OPEN_WRITE : 0); 116 OPEN_WRITE == (__force int)FMODE_WRITE)
117 return (__force int)(file->f_mode & (FMODE_READ | FMODE_WRITE));
118 else
119 return ((file->f_mode & FMODE_READ) ? OPEN_READ : 0) |
120 ((file->f_mode & FMODE_WRITE) ? OPEN_WRITE : 0);
126} 121}
127 122
128#endif
129
130
131#include "sound_calls.h" 123#include "sound_calls.h"
132#include "dev_table.h" 124#include "dev_table.h"
133 125
diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
index 044453a4ee5b..41562ecde5bb 100644
--- a/sound/oss/swarm_cs4297a.c
+++ b/sound/oss/swarm_cs4297a.c
@@ -295,7 +295,7 @@ struct cs4297a_state {
295 struct mutex open_mutex; 295 struct mutex open_mutex;
296 struct mutex open_sem_adc; 296 struct mutex open_sem_adc;
297 struct mutex open_sem_dac; 297 struct mutex open_sem_dac;
298 mode_t open_mode; 298 fmode_t open_mode;
299 wait_queue_head_t open_wait; 299 wait_queue_head_t open_wait;
300 wait_queue_head_t open_wait_adc; 300 wait_queue_head_t open_wait_adc;
301 wait_queue_head_t open_wait_dac; 301 wait_queue_head_t open_wait_dac;
diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c
index dcbb3f739e61..78b8acc7c3b9 100644
--- a/sound/oss/vwsnd.c
+++ b/sound/oss/vwsnd.c
@@ -1509,7 +1509,7 @@ typedef struct vwsnd_dev {
1509 struct mutex open_mutex; 1509 struct mutex open_mutex;
1510 struct mutex io_mutex; 1510 struct mutex io_mutex;
1511 struct mutex mix_mutex; 1511 struct mutex mix_mutex;
1512 mode_t open_mode; 1512 fmode_t open_mode;
1513 wait_queue_head_t open_wait; 1513 wait_queue_head_t open_wait;
1514 1514
1515 lithium_t lith; 1515 lithium_t lith;