Skip to content

Commit

Permalink
[PATCH] mark f_ops const in the inode
Browse files Browse the repository at this point in the history
Mark the f_ops members of inodes as const, as well as fix the
ripple-through this causes by places that copy this f_ops and then "do
stuff" with it.

Signed-off-by: Arjan van de Ven <[email protected]>
Signed-off-by: Alexey Dobriyan <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Arjan van de Ven authored and Linus Torvalds committed Mar 28, 2006
1 parent ec1b946 commit 99ac48f
Show file tree
Hide file tree
Showing 42 changed files with 75 additions and 74 deletions.
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/cell/spufs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ spufs_setattr(struct dentry *dentry, struct iattr *attr)

static int
spufs_new_file(struct super_block *sb, struct dentry *dentry,
struct file_operations *fops, int mode,
const struct file_operations *fops, int mode,
struct spu_context *ctx)
{
static struct inode_operations spufs_file_iops = {
Expand Down
2 changes: 1 addition & 1 deletion arch/ppc/kernel/ppc_htab.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static int ppc_htab_open(struct inode *inode, struct file *file)
return single_open(file, ppc_htab_show, NULL);
}

struct file_operations ppc_htab_operations = {
const struct file_operations ppc_htab_operations = {
.open = ppc_htab_open,
.read = seq_read,
.llseek = seq_lseek,
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/drm/drm_fops.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ int drm_stub_open(struct inode *inode, struct file *filp)
drm_device_t *dev = NULL;
int minor = iminor(inode);
int err = -ENODEV;
struct file_operations *old_fops;
const struct file_operations *old_fops;

DRM_DEBUG("\n");

Expand Down
2 changes: 1 addition & 1 deletion drivers/char/drm/i810_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static int i810_map_buffer(drm_buf_t * buf, struct file *filp)
drm_device_t *dev = priv->head->dev;
drm_i810_buf_priv_t *buf_priv = buf->dev_private;
drm_i810_private_t *dev_priv = dev->dev_private;
struct file_operations *old_fops;
const struct file_operations *old_fops;
int retcode = 0;

if (buf_priv->currently_mapped == I810_BUF_MAPPED)
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/drm/i830_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static int i830_map_buffer(drm_buf_t * buf, struct file *filp)
drm_device_t *dev = priv->head->dev;
drm_i830_buf_priv_t *buf_priv = buf->dev_private;
drm_i830_private_t *dev_priv = dev->dev_private;
struct file_operations *old_fops;
const struct file_operations *old_fops;
unsigned long virtual;
int retcode = 0;

Expand Down
2 changes: 1 addition & 1 deletion drivers/char/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ static const struct {
unsigned int minor;
char *name;
umode_t mode;
struct file_operations *fops;
const struct file_operations *fops;
} devlist[] = { /* list of minor devices */
{1, "mem", S_IRUSR | S_IWUSR | S_IRGRP, &mem_fops},
{2, "kmem", S_IRUSR | S_IWUSR | S_IRGRP, &kmem_fops},
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static int misc_open(struct inode * inode, struct file * file)
int minor = iminor(inode);
struct miscdevice *c;
int err = -ENODEV;
struct file_operations *old_fops, *new_fops = NULL;
const struct file_operations *old_fops, *new_fops = NULL;

down(&misc_sem);

Expand Down
2 changes: 1 addition & 1 deletion drivers/input/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ void input_unregister_handler(struct input_handler *handler)
static int input_open_file(struct inode *inode, struct file *file)
{
struct input_handler *handler = input_table[iminor(inode) >> 5];
struct file_operations *old_fops, *new_fops = NULL;
const struct file_operations *old_fops, *new_fops = NULL;
int err;

/* No load-on-demand here? */
Expand Down
2 changes: 1 addition & 1 deletion drivers/isdn/capi/kcapi_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ static struct file_operations proc_applstats_ops = {
};

static void
create_seq_entry(char *name, mode_t mode, struct file_operations *f)
create_seq_entry(char *name, mode_t mode, const struct file_operations *f)
{
struct proc_dir_entry *entry;
entry = create_proc_entry(name, mode, NULL);
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/dvb-core/dvbdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static int dvb_device_open(struct inode *inode, struct file *file)

if (dvbdev && dvbdev->fops) {
int err = 0;
struct file_operations *old_fops;
const struct file_operations *old_fops;

file->private_data = dvbdev;
old_fops = file->f_op;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/videodev.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static int video_open(struct inode *inode, struct file *file)
unsigned int minor = iminor(inode);
int err = 0;
struct video_device *vfl;
struct file_operations *old_fops;
const struct file_operations *old_fops;

if(minor>=VIDEO_NUM_DEVICES)
return -ENODEV;
Expand Down
2 changes: 1 addition & 1 deletion drivers/message/i2o/i2o_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
typedef struct _i2o_proc_entry_t {
char *name; /* entry name */
mode_t mode; /* mode */
struct file_operations *fops; /* open function */
const struct file_operations *fops; /* open function */
} i2o_proc_entry;

/* global I2O /proc/i2o entry */
Expand Down
6 changes: 3 additions & 3 deletions drivers/oprofile/oprofilefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static struct file_operations ulong_ro_fops = {


static struct dentry * __oprofilefs_create_file(struct super_block * sb,
struct dentry * root, char const * name, struct file_operations * fops,
struct dentry * root, char const * name, const struct file_operations * fops,
int perm)
{
struct dentry * dentry;
Expand Down Expand Up @@ -203,7 +203,7 @@ int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,


int oprofilefs_create_file(struct super_block * sb, struct dentry * root,
char const * name, struct file_operations * fops)
char const * name, const struct file_operations * fops)
{
if (!__oprofilefs_create_file(sb, root, name, fops, 0644))
return -EFAULT;
Expand All @@ -212,7 +212,7 @@ int oprofilefs_create_file(struct super_block * sb, struct dentry * root,


int oprofilefs_create_file_perm(struct super_block * sb, struct dentry * root,
char const * name, struct file_operations * fops, int perm)
char const * name, const struct file_operations * fops, int perm)
{
if (!__oprofilefs_create_file(sb, root, name, fops, perm))
return -EFAULT;
Expand Down
2 changes: 1 addition & 1 deletion drivers/telephony/phonedev.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static int phone_open(struct inode *inode, struct file *file)
unsigned int minor = iminor(inode);
int err = 0;
struct phone_device *p;
struct file_operations *old_fops, *new_fops = NULL;
const struct file_operations *old_fops, *new_fops = NULL;

if (minor >= PHONE_NUM_DEVICES)
return -ENODEV;
Expand Down
6 changes: 3 additions & 3 deletions drivers/usb/core/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
#include "usb.h"

#define MAX_USB_MINORS 256
static struct file_operations *usb_minors[MAX_USB_MINORS];
static const struct file_operations *usb_minors[MAX_USB_MINORS];
static DEFINE_SPINLOCK(minor_lock);

static int usb_open(struct inode * inode, struct file * file)
{
int minor = iminor(inode);
struct file_operations *c;
const struct file_operations *c;
int err = -ENODEV;
struct file_operations *old_fops, *new_fops = NULL;
const struct file_operations *old_fops, *new_fops = NULL;

spin_lock (&minor_lock);
c = usb_minors[minor];
Expand Down
6 changes: 3 additions & 3 deletions drivers/usb/gadget/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,7 @@ static void destroy_ep_files (struct dev_data *dev)

static struct inode *
gadgetfs_create_file (struct super_block *sb, char const *name,
void *data, struct file_operations *fops,
void *data, const struct file_operations *fops,
struct dentry **dentry_p);

static int activate_ep_files (struct dev_data *dev)
Expand Down Expand Up @@ -1955,7 +1955,7 @@ module_param (default_perm, uint, 0644);

static struct inode *
gadgetfs_make_inode (struct super_block *sb,
void *data, struct file_operations *fops,
void *data, const struct file_operations *fops,
int mode)
{
struct inode *inode = new_inode (sb);
Expand All @@ -1979,7 +1979,7 @@ gadgetfs_make_inode (struct super_block *sb,
*/
static struct inode *
gadgetfs_create_file (struct super_block *sb, char const *name,
void *data, struct file_operations *fops,
void *data, const struct file_operations *fops,
struct dentry **dentry_p)
{
struct dentry *dentry;
Expand Down
4 changes: 2 additions & 2 deletions fs/char_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count,
}

int register_chrdev(unsigned int major, const char *name,
struct file_operations *fops)
const struct file_operations *fops)
{
struct char_device_struct *cd;
struct cdev *cdev;
Expand Down Expand Up @@ -473,7 +473,7 @@ struct cdev *cdev_alloc(void)
return p;
}

void cdev_init(struct cdev *cdev, struct file_operations *fops)
void cdev_init(struct cdev *cdev, const struct file_operations *fops)
{
memset(cdev, 0, sizeof *cdev);
INIT_LIST_HEAD(&cdev->list);
Expand Down
2 changes: 1 addition & 1 deletion fs/debugfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static int debugfs_create_by_name(const char *name, mode_t mode,
*/
struct dentry *debugfs_create_file(const char *name, mode_t mode,
struct dentry *parent, void *data,
struct file_operations *fops)
const struct file_operations *fops)
{
struct dentry *dentry = NULL;
int error;
Expand Down
2 changes: 1 addition & 1 deletion fs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static struct inode *alloc_inode(struct super_block *sb)
{
static struct address_space_operations empty_aops;
static struct inode_operations empty_iops;
static struct file_operations empty_fops;
static const struct file_operations empty_fops;
struct inode *inode;

if (sb->s_op->alloc_inode)
Expand Down
2 changes: 1 addition & 1 deletion fs/nfsd/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ nfsd_close(struct file *filp)
* after it.
*/
static inline int nfsd_dosync(struct file *filp, struct dentry *dp,
struct file_operations *fop)
const struct file_operations *fop)
{
struct inode *inode = dp->d_inode;
int (*fsync) (struct file *, struct dentry *, int);
Expand Down
2 changes: 1 addition & 1 deletion fs/proc/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ static void proc_kill_inodes(struct proc_dir_entry *de)
struct file * filp = list_entry(p, struct file, f_u.fu_list);
struct dentry * dentry = filp->f_dentry;
struct inode * inode;
struct file_operations *fops;
const struct file_operations *fops;

if (dentry->d_op != &proc_dentry_operations)
continue;
Expand Down
2 changes: 1 addition & 1 deletion fs/proc/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ do { \

#endif

extern void create_seq_entry(char *name, mode_t mode, struct file_operations *f);
extern void create_seq_entry(char *name, mode_t mode, const struct file_operations *f);
extern int proc_exe_link(struct inode *, struct dentry **, struct vfsmount **);
extern int proc_tid_stat(struct task_struct *, char *);
extern int proc_tgid_stat(struct task_struct *, char *);
Expand Down
2 changes: 1 addition & 1 deletion fs/proc/proc_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ static struct file_operations proc_sysrq_trigger_operations = {

struct proc_dir_entry *proc_root_kcore;

void create_seq_entry(char *name, mode_t mode, struct file_operations *f)
void create_seq_entry(char *name, mode_t mode, const struct file_operations *f)
{
struct proc_dir_entry *entry;
entry = create_proc_entry(name, mode, NULL);
Expand Down
2 changes: 1 addition & 1 deletion fs/select.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ int do_select(int n, fd_set_bits *fds, s64 *timeout)
for (i = 0; i < n; ++rinp, ++routp, ++rexp) {
unsigned long in, out, ex, all_bits, bit = 1, mask, j;
unsigned long res_in = 0, res_out = 0, res_ex = 0;
struct file_operations *f_op = NULL;
const struct file_operations *f_op = NULL;
struct file *file = NULL;

in = *inp++; out = *outp++; ex = *exp++;
Expand Down
4 changes: 2 additions & 2 deletions include/linux/cdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
struct cdev {
struct kobject kobj;
struct module *owner;
struct file_operations *ops;
const struct file_operations *ops;
struct list_head list;
dev_t dev;
unsigned int count;
};

void cdev_init(struct cdev *, struct file_operations *);
void cdev_init(struct cdev *, const struct file_operations *);

struct cdev *cdev_alloc(void);

Expand Down
2 changes: 1 addition & 1 deletion include/linux/debugfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct debugfs_blob_wrapper {
#if defined(CONFIG_DEBUG_FS)
struct dentry *debugfs_create_file(const char *name, mode_t mode,
struct dentry *parent, void *data,
struct file_operations *fops);
const struct file_operations *fops);

struct dentry *debugfs_create_dir(const char *name, struct dentry *parent);

Expand Down
6 changes: 3 additions & 3 deletions include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ struct inode {
struct mutex i_mutex;
struct rw_semaphore i_alloc_sem;
struct inode_operations *i_op;
struct file_operations *i_fop; /* former ->i_op->default_file_ops */
const struct file_operations *i_fop; /* former ->i_op->default_file_ops */
struct super_block *i_sb;
struct file_lock *i_flock;
struct address_space *i_mapping;
Expand Down Expand Up @@ -636,7 +636,7 @@ struct file {
} f_u;
struct dentry *f_dentry;
struct vfsmount *f_vfsmnt;
struct file_operations *f_op;
const struct file_operations *f_op;
atomic_t f_count;
unsigned int f_flags;
mode_t f_mode;
Expand Down Expand Up @@ -1414,7 +1414,7 @@ extern void bd_release_from_disk(struct block_device *, struct gendisk *);
extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *);
extern int register_chrdev_region(dev_t, unsigned, const char *);
extern int register_chrdev(unsigned int, const char *,
struct file_operations *);
const struct file_operations *);
extern int unregister_chrdev(unsigned int, const char *);
extern void unregister_chrdev_region(dev_t, unsigned);
extern int chrdev_open(struct inode *, struct file *);
Expand Down
2 changes: 1 addition & 1 deletion include/linux/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ struct input_handler {
struct input_handle* (*connect)(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id);
void (*disconnect)(struct input_handle *handle);

struct file_operations *fops;
const struct file_operations *fops;
int minor;
char *name;

Expand Down
2 changes: 1 addition & 1 deletion include/linux/miscdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct class_device;
struct miscdevice {
int minor;
const char *name;
struct file_operations *fops;
const struct file_operations *fops;
struct list_head list;
struct device *dev;
struct class_device *class;
Expand Down
4 changes: 2 additions & 2 deletions include/linux/oprofile.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ void oprofile_add_trace(unsigned long eip);
* the specified file operations.
*/
int oprofilefs_create_file(struct super_block * sb, struct dentry * root,
char const * name, struct file_operations * fops);
char const * name, const struct file_operations * fops);

int oprofilefs_create_file_perm(struct super_block * sb, struct dentry * root,
char const * name, struct file_operations * fops, int perm);
char const * name, const struct file_operations * fops, int perm);

/** Create a file for read/write access to an unsigned long. */
int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
Expand Down
4 changes: 2 additions & 2 deletions include/linux/proc_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct proc_dir_entry {
gid_t gid;
loff_t size;
struct inode_operations * proc_iops;
struct file_operations * proc_fops;
const struct file_operations * proc_fops;
get_info_t *get_info;
struct module *owner;
struct proc_dir_entry *next, *parent, *subdir;
Expand Down Expand Up @@ -189,7 +189,7 @@ static inline struct proc_dir_entry *proc_net_create(const char *name,
}

static inline struct proc_dir_entry *proc_net_fops_create(const char *name,
mode_t mode, struct file_operations *fops)
mode_t mode, const struct file_operations *fops)
{
struct proc_dir_entry *res = create_proc_entry(name, mode, proc_net);
if (res)
Expand Down
12 changes: 6 additions & 6 deletions include/linux/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
*/

struct device;
extern int register_sound_special(struct file_operations *fops, int unit);
extern int register_sound_special_device(struct file_operations *fops, int unit, struct device *dev);
extern int register_sound_mixer(struct file_operations *fops, int dev);
extern int register_sound_midi(struct file_operations *fops, int dev);
extern int register_sound_dsp(struct file_operations *fops, int dev);
extern int register_sound_synth(struct file_operations *fops, int dev);
extern int register_sound_special(const struct file_operations *fops, int unit);
extern int register_sound_special_device(const struct file_operations *fops, int unit, struct device *dev);
extern int register_sound_mixer(const struct file_operations *fops, int dev);
extern int register_sound_midi(const struct file_operations *fops, int dev);
extern int register_sound_dsp(const struct file_operations *fops, int dev);
extern int register_sound_synth(const struct file_operations *fops, int dev);

extern void unregister_sound_special(int unit);
extern void unregister_sound_mixer(int unit);
Expand Down
Loading

0 comments on commit 99ac48f

Please sign in to comment.