Skip to content

Commit 6f24784

Browse files
author
Al Viro
committed
whack-a-mole: don't open-code iminor/imajor
several instances creeped back into the tree... Signed-off-by: Al Viro <[email protected]>
1 parent 9652c73 commit 6f24784

File tree

7 files changed

+15
-17
lines changed

7 files changed

+15
-17
lines changed

arch/sh/boards/mach-landisk/gio.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ static int openCnt;
2727

2828
static int gio_open(struct inode *inode, struct file *filp)
2929
{
30-
int minor;
30+
int minor = iminor(inode);
3131
int ret = -ENOENT;
3232

3333
preempt_disable();
34-
minor = MINOR(inode->i_rdev);
3534
if (minor < DEVCOUNT) {
3635
if (openCnt > 0) {
3736
ret = -EALREADY;
@@ -46,9 +45,8 @@ static int gio_open(struct inode *inode, struct file *filp)
4645

4746
static int gio_close(struct inode *inode, struct file *filp)
4847
{
49-
int minor;
48+
int minor = iminor(inode);
5049

51-
minor = MINOR(inode->i_rdev);
5250
if (minor < DEVCOUNT) {
5351
openCnt--;
5452
}

drivers/block/loop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ static inline int is_loop_device(struct file *file)
663663
{
664664
struct inode *i = file->f_mapping->host;
665665

666-
return i && S_ISBLK(i->i_mode) && MAJOR(i->i_rdev) == LOOP_MAJOR;
666+
return i && S_ISBLK(i->i_mode) && imajor(i) == LOOP_MAJOR;
667667
}
668668

669669
static int loop_validate_file(struct file *file, struct block_device *bdev)

drivers/dax/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ static void dax_free_inode(struct inode *inode)
480480
kfree(dax_dev->host);
481481
dax_dev->host = NULL;
482482
if (inode->i_rdev)
483-
ida_simple_remove(&dax_minor_ida, MINOR(inode->i_rdev));
483+
ida_simple_remove(&dax_minor_ida, iminor(inode));
484484
kmem_cache_free(dax_cache, dax_dev);
485485
}
486486

drivers/rtc/rtc-m41t80.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ static long wdt_unlocked_ioctl(struct file *file, unsigned int cmd,
783783
*/
784784
static int wdt_open(struct inode *inode, struct file *file)
785785
{
786-
if (MINOR(inode->i_rdev) == WATCHDOG_MINOR) {
786+
if (iminor(inode) == WATCHDOG_MINOR) {
787787
mutex_lock(&m41t80_rtc_mutex);
788788
if (test_and_set_bit(0, &wdt_is_open)) {
789789
mutex_unlock(&m41t80_rtc_mutex);
@@ -807,7 +807,7 @@ static int wdt_open(struct inode *inode, struct file *file)
807807
*/
808808
static int wdt_release(struct inode *inode, struct file *file)
809809
{
810-
if (MINOR(inode->i_rdev) == WATCHDOG_MINOR)
810+
if (iminor(inode) == WATCHDOG_MINOR)
811811
clear_bit(0, &wdt_is_open);
812812
return 0;
813813
}

drivers/s390/char/vmur.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ static int ur_open(struct inode *inode, struct file *file)
681681
* We treat the minor number as the devno of the ur device
682682
* to find in the driver tree.
683683
*/
684-
devno = MINOR(file_inode(file)->i_rdev);
684+
devno = iminor(file_inode(file));
685685

686686
urd = urdev_get_from_devno(devno);
687687
if (!urd) {

drivers/staging/vme/devices/vme_user.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ static ssize_t buffer_from_user(unsigned int minor, const char __user *buf,
175175
static ssize_t vme_user_read(struct file *file, char __user *buf, size_t count,
176176
loff_t *ppos)
177177
{
178-
unsigned int minor = MINOR(file_inode(file)->i_rdev);
178+
unsigned int minor = iminor(file_inode(file));
179179
ssize_t retval;
180180
size_t image_size;
181181

@@ -218,7 +218,7 @@ static ssize_t vme_user_read(struct file *file, char __user *buf, size_t count,
218218
static ssize_t vme_user_write(struct file *file, const char __user *buf,
219219
size_t count, loff_t *ppos)
220220
{
221-
unsigned int minor = MINOR(file_inode(file)->i_rdev);
221+
unsigned int minor = iminor(file_inode(file));
222222
ssize_t retval;
223223
size_t image_size;
224224

@@ -260,7 +260,7 @@ static ssize_t vme_user_write(struct file *file, const char __user *buf,
260260

261261
static loff_t vme_user_llseek(struct file *file, loff_t off, int whence)
262262
{
263-
unsigned int minor = MINOR(file_inode(file)->i_rdev);
263+
unsigned int minor = iminor(file_inode(file));
264264
size_t image_size;
265265
loff_t res;
266266

@@ -294,7 +294,7 @@ static int vme_user_ioctl(struct inode *inode, struct file *file,
294294
struct vme_slave slave;
295295
struct vme_irq_id irq_req;
296296
unsigned long copied;
297-
unsigned int minor = MINOR(inode->i_rdev);
297+
unsigned int minor = iminor(inode);
298298
int retval;
299299
dma_addr_t pci_addr;
300300
void __user *argp = (void __user *)arg;
@@ -412,7 +412,7 @@ vme_user_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
412412
{
413413
int ret;
414414
struct inode *inode = file_inode(file);
415-
unsigned int minor = MINOR(inode->i_rdev);
415+
unsigned int minor = iminor(inode);
416416

417417
mutex_lock(&image[minor].mutex);
418418
ret = vme_user_ioctl(inode, file, cmd, arg);
@@ -481,7 +481,7 @@ static int vme_user_master_mmap(unsigned int minor, struct vm_area_struct *vma)
481481

482482
static int vme_user_mmap(struct file *file, struct vm_area_struct *vma)
483483
{
484-
unsigned int minor = MINOR(file_inode(file)->i_rdev);
484+
unsigned int minor = iminor(file_inode(file));
485485

486486
if (type[minor] == MASTER_MINOR)
487487
return vme_user_master_mmap(minor, vma);

fs/gfs2/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,8 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_inode *ip,
490490
di = (struct gfs2_dinode *)dibh->b_data;
491491
gfs2_dinode_out(ip, di);
492492

493-
di->di_major = cpu_to_be32(MAJOR(ip->i_inode.i_rdev));
494-
di->di_minor = cpu_to_be32(MINOR(ip->i_inode.i_rdev));
493+
di->di_major = cpu_to_be32(imajor(&ip->i_inode));
494+
di->di_minor = cpu_to_be32(iminor(&ip->i_inode));
495495
di->__pad1 = 0;
496496
di->__pad2 = 0;
497497
di->__pad3 = 0;

0 commit comments

Comments
 (0)