Skip to content

Commit

Permalink
const: constify remaining file_operations
Browse files Browse the repository at this point in the history
[[email protected]: fix KVM]
Signed-off-by: Alexey Dobriyan <[email protected]>
Acked-by: Mike Frysinger <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Alexey Dobriyan authored and torvalds committed Oct 1, 2009
1 parent 1c4115e commit 828c095
Show file tree
Hide file tree
Showing 57 changed files with 110 additions and 95 deletions.
2 changes: 1 addition & 1 deletion arch/arm/mach-ns9xxx/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ static int clk_debugfs_open(struct inode *inode, struct file *file)
return single_open(file, clk_debugfs_show, NULL);
}

static struct file_operations clk_debugfs_operations = {
static const struct file_operations clk_debugfs_operations = {
.open = clk_debugfs_open,
.read = seq_read,
.llseek = seq_lseek,
Expand Down
2 changes: 1 addition & 1 deletion arch/blackfin/mach-bf561/coreb.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ coreb_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned l
return ret;
}

static struct file_operations coreb_fops = {
static const struct file_operations coreb_fops = {
.owner = THIS_MODULE,
.ioctl = coreb_ioctl,
};
Expand Down
2 changes: 1 addition & 1 deletion arch/cris/arch-v10/drivers/sync_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ static unsigned sync_serial_prescale_shadow;

#define NUMBER_OF_PORTS 2

static struct file_operations sync_serial_fops = {
static const struct file_operations sync_serial_fops = {
.owner = THIS_MODULE,
.write = sync_serial_write,
.read = sync_serial_read,
Expand Down
2 changes: 1 addition & 1 deletion arch/cris/arch-v32/drivers/mach-fs/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ gpio_leds_ioctl(unsigned int cmd, unsigned long arg)
return 0;
}

struct file_operations gpio_fops = {
static const struct file_operations gpio_fops = {
.owner = THIS_MODULE,
.poll = gpio_poll,
.ioctl = gpio_ioctl,
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kvm/timing.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ static int kvmppc_exit_timing_open(struct inode *inode, struct file *file)
return single_open(file, kvmppc_exit_timing_show, inode->i_private);
}

static struct file_operations kvmppc_exit_timing_fops = {
static const struct file_operations kvmppc_exit_timing_fops = {
.owner = THIS_MODULE,
.open = kvmppc_exit_timing_open,
.read = seq_read,
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/cell/spufs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static int __fops ## _open(struct inode *inode, struct file *file) \
__simple_attr_check_format(__fmt, 0ull); \
return spufs_attr_open(inode, file, __get, __set, __fmt); \
} \
static struct file_operations __fops = { \
static const struct file_operations __fops = { \
.owner = THIS_MODULE, \
.open = __fops ## _open, \
.release = spufs_attr_release, \
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/pseries/dtl.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ static ssize_t dtl_file_read(struct file *filp, char __user *buf, size_t len,
return n_read * sizeof(struct dtl_entry);
}

static struct file_operations dtl_fops = {
static const struct file_operations dtl_fops = {
.open = dtl_file_open,
.release = dtl_file_release,
.read = dtl_file_read,
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/xen/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static int xen_array_release(struct inode *inode, struct file *file)
return 0;
}

static struct file_operations u32_array_fops = {
static const struct file_operations u32_array_fops = {
.owner = THIS_MODULE,
.open = u32_array_open,
.release= xen_array_release,
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ static int acpi_video_device_brightness_open_fs(struct inode *inode,
struct file *file);
static ssize_t acpi_video_device_write_brightness(struct file *file,
const char __user *buffer, size_t count, loff_t *data);
static struct file_operations acpi_video_device_brightness_fops = {
static const struct file_operations acpi_video_device_brightness_fops = {
.owner = THIS_MODULE,
.open = acpi_video_device_brightness_open_fs,
.read = seq_read,
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/cciss.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ cciss_proc_write(struct file *file, const char __user *buf,
return err;
}

static struct file_operations cciss_proc_fops = {
static const struct file_operations cciss_proc_fops = {
.owner = THIS_MODULE,
.open = cciss_seq_open,
.read = seq_read,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/apm-emulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ static int apm_open(struct inode * inode, struct file * filp)
return as ? 0 : -ENOMEM;
}

static struct file_operations apm_bios_fops = {
static const struct file_operations apm_bios_fops = {
.owner = THIS_MODULE,
.read = apm_read,
.poll = apm_poll,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/bfin-otp.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static long bfin_otp_ioctl(struct file *filp, unsigned cmd, unsigned long arg)
# define bfin_otp_ioctl NULL
#endif

static struct file_operations bfin_otp_fops = {
static const struct file_operations bfin_otp_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = bfin_otp_ioctl,
.read = bfin_otp_read,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/xilinx_hwicap/xilinx_hwicap.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ static int hwicap_release(struct inode *inode, struct file *file)
return status;
}

static struct file_operations hwicap_fops = {
static const struct file_operations hwicap_fops = {
.owner = THIS_MODULE,
.write = hwicap_write,
.read = hwicap_read,
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1487,7 +1487,7 @@ static int gpiolib_open(struct inode *inode, struct file *file)
return single_open(file, gpiolib_show, NULL);
}

static struct file_operations gpiolib_operations = {
static const struct file_operations gpiolib_operations = {
.open = gpiolib_open,
.read = seq_read,
.llseek = seq_lseek,
Expand Down
2 changes: 1 addition & 1 deletion drivers/hwmon/fschmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ static int watchdog_ioctl(struct inode *inode, struct file *filp,
return ret;
}

static struct file_operations watchdog_fops = {
static const struct file_operations watchdog_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.open = watchdog_open,
Expand Down
2 changes: 1 addition & 1 deletion drivers/lguest/lguest_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ static int close(struct inode *inode, struct file *file)
* uses: reading and writing a character device called /dev/lguest. All the
* work happens in the read(), write() and close() routines:
*/
static struct file_operations lguest_fops = {
static const struct file_operations lguest_fops = {
.owner = THIS_MODULE,
.release = close,
.write = write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/dvb-core/dmxdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait)
return mask;
}

static struct file_operations dvb_dvr_fops = {
static const struct file_operations dvb_dvr_fops = {
.owner = THIS_MODULE,
.read = dvb_dvr_read,
.write = dvb_dvr_write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/firewire/firedtv-ci.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static unsigned int fdtv_ca_io_poll(struct file *file, poll_table *wait)
return POLLIN;
}

static struct file_operations fdtv_ca_fops = {
static const struct file_operations fdtv_ca_fops = {
.owner = THIS_MODULE,
.ioctl = dvb_generic_ioctl,
.open = dvb_generic_open,
Expand Down
2 changes: 1 addition & 1 deletion drivers/misc/phantom.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ static unsigned int phantom_poll(struct file *file, poll_table *wait)
return mask;
}

static struct file_operations phantom_file_ops = {
static const struct file_operations phantom_file_ops = {
.open = phantom_open,
.release = phantom_release,
.unlocked_ioctl = phantom_ioctl,
Expand Down
3 changes: 1 addition & 2 deletions drivers/misc/sgi-gru/grufile.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ struct gru_stats_s gru_stats;
/* Guaranteed user available resources on each node */
static int max_user_cbrs, max_user_dsr_bytes;

static struct file_operations gru_fops;
static struct miscdevice gru_miscdev;


Expand Down Expand Up @@ -426,7 +425,7 @@ static void __exit gru_exit(void)
gru_proc_exit();
}

static struct file_operations gru_fops = {
static const struct file_operations gru_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = gru_file_unlocked_ioctl,
.mmap = gru_file_mmap,
Expand Down
2 changes: 1 addition & 1 deletion drivers/mmc/core/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ static int mmc_ext_csd_release(struct inode *inode, struct file *file)
return 0;
}

static struct file_operations mmc_dbg_ext_csd_fops = {
static const struct file_operations mmc_dbg_ext_csd_fops = {
.open = mmc_ext_csd_open,
.read = mmc_ext_csd_read,
.release = mmc_ext_csd_release,
Expand Down
2 changes: 1 addition & 1 deletion drivers/s390/cio/qdio_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static int qstat_seq_open(struct inode *inode, struct file *filp)
filp->f_path.dentry->d_inode->i_private);
}

static struct file_operations debugfs_fops = {
static const struct file_operations debugfs_fops = {
.owner = THIS_MODULE,
.open = qstat_seq_open,
.read = seq_read,
Expand Down
2 changes: 1 addition & 1 deletion drivers/s390/cio/qdio_perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static int qdio_perf_seq_open(struct inode *inode, struct file *filp)
return single_open(filp, qdio_perf_proc_show, NULL);
}

static struct file_operations qdio_perf_proc_fops = {
static const struct file_operations qdio_perf_proc_fops = {
.owner = THIS_MODULE,
.open = qdio_perf_seq_open,
.read = seq_read,
Expand Down
43 changes: 30 additions & 13 deletions drivers/scsi/sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@ static void sg_rq_end_io(struct request *rq, int uptodate)
}
}

static struct file_operations sg_fops = {
static const struct file_operations sg_fops = {
.owner = THIS_MODULE,
.read = sg_read,
.write = sg_write,
Expand Down Expand Up @@ -2194,33 +2194,44 @@ static int sg_proc_seq_show_int(struct seq_file *s, void *v);
static int sg_proc_single_open_adio(struct inode *inode, struct file *file);
static ssize_t sg_proc_write_adio(struct file *filp, const char __user *buffer,
size_t count, loff_t *off);
static struct file_operations adio_fops = {
/* .owner, .read and .llseek added in sg_proc_init() */
static const struct file_operations adio_fops = {
.owner = THIS_MODULE,
.open = sg_proc_single_open_adio,
.read = seq_read,
.llseek = seq_lseek,
.write = sg_proc_write_adio,
.release = single_release,
};

static int sg_proc_single_open_dressz(struct inode *inode, struct file *file);
static ssize_t sg_proc_write_dressz(struct file *filp,
const char __user *buffer, size_t count, loff_t *off);
static struct file_operations dressz_fops = {
static const struct file_operations dressz_fops = {
.owner = THIS_MODULE,
.open = sg_proc_single_open_dressz,
.read = seq_read,
.llseek = seq_lseek,
.write = sg_proc_write_dressz,
.release = single_release,
};

static int sg_proc_seq_show_version(struct seq_file *s, void *v);
static int sg_proc_single_open_version(struct inode *inode, struct file *file);
static struct file_operations version_fops = {
static const struct file_operations version_fops = {
.owner = THIS_MODULE,
.open = sg_proc_single_open_version,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

static int sg_proc_seq_show_devhdr(struct seq_file *s, void *v);
static int sg_proc_single_open_devhdr(struct inode *inode, struct file *file);
static struct file_operations devhdr_fops = {
static const struct file_operations devhdr_fops = {
.owner = THIS_MODULE,
.open = sg_proc_single_open_devhdr,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

Expand All @@ -2229,8 +2240,11 @@ static int sg_proc_open_dev(struct inode *inode, struct file *file);
static void * dev_seq_start(struct seq_file *s, loff_t *pos);
static void * dev_seq_next(struct seq_file *s, void *v, loff_t *pos);
static void dev_seq_stop(struct seq_file *s, void *v);
static struct file_operations dev_fops = {
static const struct file_operations dev_fops = {
.owner = THIS_MODULE,
.open = sg_proc_open_dev,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
static const struct seq_operations dev_seq_ops = {
Expand All @@ -2242,8 +2256,11 @@ static const struct seq_operations dev_seq_ops = {

static int sg_proc_seq_show_devstrs(struct seq_file *s, void *v);
static int sg_proc_open_devstrs(struct inode *inode, struct file *file);
static struct file_operations devstrs_fops = {
static const struct file_operations devstrs_fops = {
.owner = THIS_MODULE,
.open = sg_proc_open_devstrs,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
static const struct seq_operations devstrs_seq_ops = {
Expand All @@ -2255,8 +2272,11 @@ static const struct seq_operations devstrs_seq_ops = {

static int sg_proc_seq_show_debug(struct seq_file *s, void *v);
static int sg_proc_open_debug(struct inode *inode, struct file *file);
static struct file_operations debug_fops = {
static const struct file_operations debug_fops = {
.owner = THIS_MODULE,
.open = sg_proc_open_debug,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
static const struct seq_operations debug_seq_ops = {
Expand All @@ -2269,7 +2289,7 @@ static const struct seq_operations debug_seq_ops = {

struct sg_proc_leaf {
const char * name;
struct file_operations * fops;
const struct file_operations * fops;
};

static struct sg_proc_leaf sg_proc_leaf_arr[] = {
Expand All @@ -2295,9 +2315,6 @@ sg_proc_init(void)
for (k = 0; k < num_leaves; ++k) {
leaf = &sg_proc_leaf_arr[k];
mask = leaf->fops->write ? S_IRUGO | S_IWUSR : S_IRUGO;
leaf->fops->owner = THIS_MODULE;
leaf->fops->read = seq_read;
leaf->fops->llseek = seq_lseek;
proc_create(leaf->name, mask, sg_proc_sgp, leaf->fops);
}
return 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/spi/spidev.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ static int spidev_release(struct inode *inode, struct file *filp)
return status;
}

static struct file_operations spidev_fops = {
static const struct file_operations spidev_fops = {
.owner = THIS_MODULE,
/* REVISIT switch to aio primitives, so that userspace
* gets more complete API coverage. It'll simplify things
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/class/usbtmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ static long usbtmc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return retval;
}

static struct file_operations fops = {
static const struct file_operations fops = {
.owner = THIS_MODULE,
.read = usbtmc_read,
.write = usbtmc_write,
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/printer.c
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ printer_ioctl(struct file *fd, unsigned int code, unsigned long arg)
}

/* used after endpoint configuration */
static struct file_operations printer_io_operations = {
static const struct file_operations printer_io_operations = {
.owner = THIS_MODULE,
.open = printer_open,
.read = printer_read,
Expand Down
6 changes: 3 additions & 3 deletions drivers/usb/host/whci/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,23 @@ static int pzl_open(struct inode *inode, struct file *file)
return single_open(file, pzl_print, inode->i_private);
}

static struct file_operations di_fops = {
static const struct file_operations di_fops = {
.open = di_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.owner = THIS_MODULE,
};

static struct file_operations asl_fops = {
static const struct file_operations asl_fops = {
.open = asl_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.owner = THIS_MODULE,
};

static struct file_operations pzl_fops = {
static const struct file_operations pzl_fops = {
.open = pzl_open,
.read = seq_read,
.llseek = seq_lseek,
Expand Down
3 changes: 1 addition & 2 deletions drivers/usb/misc/rio500.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,7 @@ read_rio(struct file *file, char __user *buffer, size_t count, loff_t * ppos)
return read_count;
}

static struct
file_operations usb_rio_fops = {
static const struct file_operations usb_rio_fops = {
.owner = THIS_MODULE,
.read = read_rio,
.write = write_rio,
Expand Down
Loading

0 comments on commit 828c095

Please sign in to comment.