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