whack-a-mole: don't open-code iminor/imajor
several instances creeped back into the tree... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
9652c73246
commit
6f24784f00
|
@ -27,11 +27,10 @@ static int openCnt;
|
|||
|
||||
static int gio_open(struct inode *inode, struct file *filp)
|
||||
{
|
||||
int minor;
|
||||
int minor = iminor(inode);
|
||||
int ret = -ENOENT;
|
||||
|
||||
preempt_disable();
|
||||
minor = MINOR(inode->i_rdev);
|
||||
if (minor < DEVCOUNT) {
|
||||
if (openCnt > 0) {
|
||||
ret = -EALREADY;
|
||||
|
@ -46,9 +45,8 @@ static int gio_open(struct inode *inode, struct file *filp)
|
|||
|
||||
static int gio_close(struct inode *inode, struct file *filp)
|
||||
{
|
||||
int minor;
|
||||
int minor = iminor(inode);
|
||||
|
||||
minor = MINOR(inode->i_rdev);
|
||||
if (minor < DEVCOUNT) {
|
||||
openCnt--;
|
||||
}
|
||||
|
|
|
@ -663,7 +663,7 @@ static inline int is_loop_device(struct file *file)
|
|||
{
|
||||
struct inode *i = file->f_mapping->host;
|
||||
|
||||
return i && S_ISBLK(i->i_mode) && MAJOR(i->i_rdev) == LOOP_MAJOR;
|
||||
return i && S_ISBLK(i->i_mode) && imajor(i) == LOOP_MAJOR;
|
||||
}
|
||||
|
||||
static int loop_validate_file(struct file *file, struct block_device *bdev)
|
||||
|
|
|
@ -480,7 +480,7 @@ static void dax_free_inode(struct inode *inode)
|
|||
kfree(dax_dev->host);
|
||||
dax_dev->host = NULL;
|
||||
if (inode->i_rdev)
|
||||
ida_simple_remove(&dax_minor_ida, MINOR(inode->i_rdev));
|
||||
ida_simple_remove(&dax_minor_ida, iminor(inode));
|
||||
kmem_cache_free(dax_cache, dax_dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -783,7 +783,7 @@ static long wdt_unlocked_ioctl(struct file *file, unsigned int cmd,
|
|||
*/
|
||||
static int wdt_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
if (MINOR(inode->i_rdev) == WATCHDOG_MINOR) {
|
||||
if (iminor(inode) == WATCHDOG_MINOR) {
|
||||
mutex_lock(&m41t80_rtc_mutex);
|
||||
if (test_and_set_bit(0, &wdt_is_open)) {
|
||||
mutex_unlock(&m41t80_rtc_mutex);
|
||||
|
@ -807,7 +807,7 @@ static int wdt_open(struct inode *inode, struct file *file)
|
|||
*/
|
||||
static int wdt_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
if (MINOR(inode->i_rdev) == WATCHDOG_MINOR)
|
||||
if (iminor(inode) == WATCHDOG_MINOR)
|
||||
clear_bit(0, &wdt_is_open);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -681,7 +681,7 @@ static int ur_open(struct inode *inode, struct file *file)
|
|||
* We treat the minor number as the devno of the ur device
|
||||
* to find in the driver tree.
|
||||
*/
|
||||
devno = MINOR(file_inode(file)->i_rdev);
|
||||
devno = iminor(file_inode(file));
|
||||
|
||||
urd = urdev_get_from_devno(devno);
|
||||
if (!urd) {
|
||||
|
|
|
@ -175,7 +175,7 @@ static ssize_t buffer_from_user(unsigned int minor, const char __user *buf,
|
|||
static ssize_t vme_user_read(struct file *file, char __user *buf, size_t count,
|
||||
loff_t *ppos)
|
||||
{
|
||||
unsigned int minor = MINOR(file_inode(file)->i_rdev);
|
||||
unsigned int minor = iminor(file_inode(file));
|
||||
ssize_t retval;
|
||||
size_t image_size;
|
||||
|
||||
|
@ -218,7 +218,7 @@ static ssize_t vme_user_read(struct file *file, char __user *buf, size_t count,
|
|||
static ssize_t vme_user_write(struct file *file, const char __user *buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
unsigned int minor = MINOR(file_inode(file)->i_rdev);
|
||||
unsigned int minor = iminor(file_inode(file));
|
||||
ssize_t retval;
|
||||
size_t image_size;
|
||||
|
||||
|
@ -260,7 +260,7 @@ static ssize_t vme_user_write(struct file *file, const char __user *buf,
|
|||
|
||||
static loff_t vme_user_llseek(struct file *file, loff_t off, int whence)
|
||||
{
|
||||
unsigned int minor = MINOR(file_inode(file)->i_rdev);
|
||||
unsigned int minor = iminor(file_inode(file));
|
||||
size_t image_size;
|
||||
loff_t res;
|
||||
|
||||
|
@ -294,7 +294,7 @@ static int vme_user_ioctl(struct inode *inode, struct file *file,
|
|||
struct vme_slave slave;
|
||||
struct vme_irq_id irq_req;
|
||||
unsigned long copied;
|
||||
unsigned int minor = MINOR(inode->i_rdev);
|
||||
unsigned int minor = iminor(inode);
|
||||
int retval;
|
||||
dma_addr_t pci_addr;
|
||||
void __user *argp = (void __user *)arg;
|
||||
|
@ -412,7 +412,7 @@ vme_user_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
|||
{
|
||||
int ret;
|
||||
struct inode *inode = file_inode(file);
|
||||
unsigned int minor = MINOR(inode->i_rdev);
|
||||
unsigned int minor = iminor(inode);
|
||||
|
||||
mutex_lock(&image[minor].mutex);
|
||||
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)
|
|||
|
||||
static int vme_user_mmap(struct file *file, struct vm_area_struct *vma)
|
||||
{
|
||||
unsigned int minor = MINOR(file_inode(file)->i_rdev);
|
||||
unsigned int minor = iminor(file_inode(file));
|
||||
|
||||
if (type[minor] == MASTER_MINOR)
|
||||
return vme_user_master_mmap(minor, vma);
|
||||
|
|
|
@ -490,8 +490,8 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_inode *ip,
|
|||
di = (struct gfs2_dinode *)dibh->b_data;
|
||||
gfs2_dinode_out(ip, di);
|
||||
|
||||
di->di_major = cpu_to_be32(MAJOR(ip->i_inode.i_rdev));
|
||||
di->di_minor = cpu_to_be32(MINOR(ip->i_inode.i_rdev));
|
||||
di->di_major = cpu_to_be32(imajor(&ip->i_inode));
|
||||
di->di_minor = cpu_to_be32(iminor(&ip->i_inode));
|
||||
di->__pad1 = 0;
|
||||
di->__pad2 = 0;
|
||||
di->__pad3 = 0;
|
||||
|
|
Loading…
Reference in New Issue