Commit dec3735e authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] bunch of ->open() killed.

Quite a few drivers don't need ->open() anymore - all it did was checking
that minor is good (== gendisk exists).  That is handled by generic code
now...
parent 5682bcc6
......@@ -1021,8 +1021,6 @@ static int stram_open( struct inode *inode, struct file *filp )
printk( KERN_NOTICE "Only kernel can open ST-RAM device\n" );
return( -EPERM );
}
if (MINOR(inode->i_rdev) != STRAM_MINOR)
return( -ENXIO );
if (refcnt)
return( -EBUSY );
++refcnt;
......
......@@ -648,14 +648,10 @@ static int ubd_open_dev(struct ubd *dev)
static int ubd_open(struct inode *inode, struct file *filp)
{
struct ubd *dev;
int n, offset, err;
int n = DEVICE_NR(inode->i_rdev);
struct ubd *dev = &ubd_dev[n];
int err;
n = DEVICE_NR(inode->i_rdev);
dev = &ubd_dev[n];
if(n > MAX_DEV)
return -ENODEV;
offset = n << UBD_SHIFT;
if(dev->is_dir == 1)
return(0);
......@@ -680,16 +676,9 @@ static int ubd_open(struct inode *inode, struct file *filp)
static int ubd_release(struct inode * inode, struct file * file)
{
int n, offset;
n = DEVICE_NR(inode->i_rdev);
offset = n << UBD_SHIFT;
if(n > MAX_DEV)
return -ENODEV;
int n = DEVICE_NR(inode->i_rdev);
if(--ubd_dev[n].count == 0)
ubd_close(&ubd_dev[n]);
return(0);
}
......
......@@ -1470,9 +1470,6 @@ static int floppy_open(struct inode *inode, struct file *filp)
int drive = minor(inode->i_rdev) & 3;
int old_dev;
if ((minor(inode->i_rdev) >> 2) > NUM_DISK_TYPES)
return -ENXIO;
old_dev = fd_device[drive];
if (fd_ref[drive])
......
......@@ -1186,14 +1186,6 @@ static int mfm_ioctl(struct inode *inode, struct file *file, u_int cmd, u_long a
return 0;
}
static int mfm_open(struct inode *inode, struct file *file)
{
int dev = DEVICE_NR(minor(inode->i_rdev));
if (dev >= mfm_drives)
return -ENODEV;
return 0;
}
/*
* This is to handle various kernel command line parameters
* specific to this driver.
......@@ -1239,7 +1231,6 @@ void xd_set_geometry(struct block_device *bdev, unsigned char secsptrack,
static struct block_device_operations mfm_fops =
{
.owner = THIS_MODULE,
.open = mfm_open,
.ioctl = mfm_ioctl,
};
......
......@@ -1086,8 +1086,6 @@ static int acsi_ioctl( struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg )
{
int dev = DEVICE_NR(inode->i_rdev);
if (dev >= NDevices)
return -EINVAL;
switch (cmd) {
case HDIO_GETGEO:
/* HDIO_GETGEO is supported more for getting the partition's
......@@ -1130,13 +1128,8 @@ static int acsi_ioctl( struct inode *inode, struct file *file,
static int acsi_open( struct inode * inode, struct file * filp )
{
int device;
struct acsi_info_struct *aip;
device = DEVICE_NR(inode->i_rdev);
if (device >= NDevices)
return -ENXIO;
aip = &acsi_info[device];
int device = DEVICE_NR(inode->i_rdev);
struct acsi_info_struct *aip = &acsi_info[device];
if (access_count[device] == 0 && aip->removable) {
#if 0
......
......@@ -1607,9 +1607,6 @@ static int floppy_open(struct inode *inode, struct file *filp)
if (!kdev_same(old_dev, inode->i_rdev))
return -EBUSY;
if (unit[drive].type->code == FD_NODRIVE)
return -ENODEV;
if (filp && filp->f_mode & 3) {
check_disk_change(inode->i_bdev);
if (filp->f_mode & 2 ) {
......@@ -1683,11 +1680,6 @@ static int amiga_floppy_change(kdev_t dev)
int changed;
static int first_time = 1;
if (major(dev) != MAJOR_NR) {
printk(KERN_CRIT "floppy_change: not a floppy\n");
return 0;
}
if (first_time)
changed = first_time--;
else {
......
......@@ -1358,12 +1358,6 @@ static int fd_device[4] = { 0,0,0,0 };
static int check_floppy_change (kdev_t dev)
{
unsigned int drive = minor(dev) & 0x03;
if (major(dev) != MAJOR_NR) {
printk(KERN_ERR "floppy_changed: not a floppy\n");
return 0;
}
if (test_bit (drive, &fake_change)) {
/* simulated change (e.g. after formatting) */
return 1;
......@@ -1855,17 +1849,11 @@ static void __init config_types( void )
static int floppy_open( struct inode *inode, struct file *filp )
{
int drive, type;
int old_dev;
int drive = minor(inode->i_rdev) & 3;
int type = minor(inode->i_rdev) >> 2;
int old_dev = fd_device[drive];
drive = minor(inode->i_rdev) & 3;
type = minor(inode->i_rdev) >> 2;
DPRINT(("fd_open: type=%d\n",type));
if (drive >= FD_MAX_UNITS || type > NUM_DISK_MINORS)
return -ENXIO;
old_dev = fd_device[drive];
if (fd_ref[drive] && old_dev != minor(inode->i_rdev))
return -EBUSY;
......
......@@ -350,9 +350,6 @@ static int pd_open(struct inode *inode, struct file *file)
int unit = DEVICE_NR(inode->i_rdev);
struct pd_unit *disk = pd + unit;
if (unit >= PD_UNITS || !disk->present)
return -ENODEV;
disk->access++;
if (disk->removable) {
......
......@@ -331,9 +331,6 @@ static int pf_open(struct inode *inode, struct file *file)
int unit = DEVICE_NR(inode->i_rdev);
struct pf_unit *pf = units + unit;
if ((unit >= PF_UNITS) || (!pf->present))
return -ENODEV;
pf_identify(pf);
if (pf->media_status == PF_NM)
......
......@@ -89,9 +89,6 @@ static void (*current_int_handler) (u_int) = NULL;
static void ps2esdi_normal_interrupt_handler(u_int);
static void ps2esdi_initial_reset_int_handler(u_int);
static void ps2esdi_geometry_int_handler(u_int);
static int ps2esdi_open(struct inode *inode, struct file *file);
static int ps2esdi_ioctl(struct inode *inode, struct file *file,
u_int cmd, u_long arg);
......@@ -141,7 +138,6 @@ static struct ps2esdi_i_struct ps2esdi_info[MAX_HD] =
static struct block_device_operations ps2esdi_fops =
{
.owner = THIS_MODULE,
.open = ps2esdi_open,
.ioctl = ps2esdi_ioctl,
};
......@@ -1075,15 +1071,6 @@ static void dump_cmd_complete_status(u_int int_ret_code)
}
static int ps2esdi_open(struct inode *inode, struct file *file)
{
int dev = DEVICE_NR(inode->i_rdev);
if (dev >= ps2esdi_drives)
return -ENODEV;
return 0;
}
static int ps2esdi_ioctl(struct inode *inode,
struct file *file, u_int cmd, u_long arg)
{
......
......@@ -864,18 +864,6 @@ static int mm_check_change(kdev_t i_rdev)
return 0;
}
/*
-----------------------------------------------------------------------------------
-- mm_open
-----------------------------------------------------------------------------------
*/
static int mm_open(struct inode *i, struct file *filp)
{
if (DEVICE_NR(i->i_rdev) >= num_cards)
return -ENXIO;
return 0;
}
/*
-----------------------------------------------------------------------------------
-- mm_fops
......@@ -883,7 +871,6 @@ static int mm_open(struct inode *i, struct file *filp)
*/
static struct block_device_operations mm_fops = {
owner: THIS_MODULE,
open: mm_open,
ioctl: mm_ioctl,
revalidate: mm_revalidate,
check_media_change: mm_check_change,
......
......@@ -130,7 +130,6 @@ static struct gendisk *xd_gendisk[2];
static struct block_device_operations xd_fops = {
owner: THIS_MODULE,
open: xd_open,
ioctl: xd_ioctl,
};
static DECLARE_WAIT_QUEUE_HEAD(xd_wait_int);
......@@ -283,15 +282,6 @@ static u_char __init xd_detect (u_char *controller, unsigned int *address)
return (found);
}
/* xd_open: open a device */
static int xd_open (struct inode *inode,struct file *file)
{
int dev = DEVICE_NR(inode->i_rdev);
if (dev >= xd_drives)
return -ENXIO;
return 0;
}
/* do_xd_request: handle an incoming request */
static void do_xd_request (request_queue_t * q)
{
......@@ -336,8 +326,6 @@ static void do_xd_request (request_queue_t * q)
static int xd_ioctl (struct inode *inode,struct file *file,u_int cmd,u_long arg)
{
int dev = DEVICE_NR(inode->i_rdev);
if (dev >= xd_drives) return -EINVAL;
switch (cmd) {
case HDIO_GETGEO:
{
......
......@@ -677,21 +677,11 @@ static int hd_ioctl(struct inode * inode, struct file * file,
}
}
static int hd_open(struct inode * inode, struct file * filp)
{
int target = DEVICE_NR(inode->i_rdev);
if (target >= NR_HD)
return -ENODEV;
return 0;
}
/*
* Releasing a block device means we sync() it, so that it can safely
* be forgotten about...
*/
extern struct block_device_operations hd_fops;
static void hd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
void (*handler)(void) = do_hd;
......@@ -705,7 +695,6 @@ static void hd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
}
static struct block_device_operations hd_fops = {
.open = hd_open,
.ioctl = hd_ioctl,
};
......
......@@ -2110,8 +2110,6 @@ dasd_open(struct inode *inp, struct file *filp)
dasd_device_t *device;
int rc;
if ((!inp) || kdev_none(inp->i_rdev))
return -EINVAL;
if (dasd_probeonly) {
MESSAGE(KERN_INFO,
"No access to device (%d:%d) due to probeonly mode",
......@@ -2154,8 +2152,6 @@ dasd_release(struct inode *inp, struct file *filp)
dasd_devmap_t *devmap;
dasd_device_t *device;
if ((!inp) || kdev_none(inp->i_rdev))
return -EINVAL;
devmap = dasd_devmap_from_kdev(inp->i_rdev);
device = (devmap != NULL) ?
dasd_get_device(devmap) : ERR_PTR(-ENODEV);
......
......@@ -324,24 +324,12 @@ static int xpram_make_request(request_queue_t *q, struct bio *bio)
return 0;
}
/*
* The file operations
*/
static int xpram_open (struct inode *inode, struct file *filp)
{
if (minor(inode->i_rdev) >= xpram_devs)
return -ENODEV;
return 0;
}
static int xpram_ioctl (struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
struct hd_geometry *geo;
unsigned long size;
int idx = minor(inode->i_rdev);
if (idx >= xpram_devs)
return -ENODEV;
if (cmd != HDIO_GETGEO)
return -EINVAL;
/*
......@@ -350,8 +338,6 @@ static int xpram_ioctl (struct inode *inode, struct file *filp,
* whatever cylinders. Tell also that data starts at sector. 4.
*/
geo = (struct hd_geometry *) arg;
if (geo == NULL)
return -EINVAL;
size = (xpram_pages * 8) & ~0x3f;
put_user(size >> 6, &geo->cylinders);
put_user(4, &geo->heads);
......@@ -364,7 +350,6 @@ static struct block_device_operations xpram_devops =
{
owner: THIS_MODULE,
ioctl: xpram_ioctl,
open: xpram_open,
};
/*
......
......@@ -104,7 +104,6 @@ static void jsf_outl(unsigned long addr, __u32 data)
struct jsfd_part {
unsigned long dbase;
unsigned long dsize;
int refcnt;
};
struct jsflash {
......@@ -454,54 +453,12 @@ static int jsf_open(struct inode * inode, struct file * filp)
return 0; /* XXX What security? */
}
static int jsfd_open(struct inode *inode, struct file *file)
{
struct jsfd_part *jdp;
int dev;
if (!inode)
return -EINVAL;
dev = MINOR(inode->i_rdev);
if (dev >= JSF_MAX || (dev & JSF_PART_MASK) >= JSF_NPART) {
printk(KERN_ALERT "jsfd_open: illegal minor %d\n", dev);
return -ENODEV;
}
jdp = &jsf0.dv[dev];
jdp->refcnt++;
return 0;
}
static int jsf_release(struct inode *inode, struct file *file)
{
jsf0.busy = 0;
return 0;
}
static int jsfd_release(struct inode *inode, struct file *file)
{
struct jsfd_part *jdp;
int dev;
if (!inode)
return -ENODEV;
dev = MINOR(inode->i_rdev);
if (dev >= JSF_MAX || (dev & JSF_PART_MASK) >= JSF_NPART) {
printk(KERN_ALERT "jsfd_release: illegal minor %d\n", dev);
return -ENODEV;
}
jdp = &jsf0.dv[dev];
if (jdp->refcnt <= 0) {
printk(KERN_ALERT "jsfd_release: bad ref on minor %d\n", dev);
} else {
--jdp->refcnt;
}
/* N.B. Doesn't lo->file need an fput?? */
return 0;
}
static struct file_operations jsf_fops = {
.owner = THIS_MODULE,
.llseek = jsf_lseek,
......@@ -517,8 +474,6 @@ static struct miscdevice jsf_dev = { JSF_MINOR, "jsflash", &jsf_fops };
static struct block_device_operations jsfd_fops = {
.owner = THIS_MODULE,
.open = jsfd_open,
.release = jsfd_release,
};
static int jsflash_init(void)
......@@ -642,8 +597,6 @@ static int jsfd_init(void)
jsf = &jsf0; /* actually, &jsfv[i >> JSF_PART_BITS] */
jdp = &jsf->dv[i&JSF_PART_MASK];
jdp->refcnt = 0;
disk->major = JSFD_MAJOR;
disk->first_minor = i;
sprintf(disk->disk_name, "jsfd%d", i);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment