Many struct file_operations in the kernel can be "const". Marking them const
moves these to the .rodata section, which avoids false sharing with potential
dirty data. In addition it'll catch accidental writes at compile time to
these shared resources.
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
32 files changed:
struct spu_context *ctx, u32 *npc, u32 *status);
long spufs_create(struct nameidata *nd,
unsigned int flags, mode_t mode);
struct spu_context *ctx, u32 *npc, u32 *status);
long spufs_create(struct nameidata *nd,
unsigned int flags, mode_t mode);
-extern struct file_operations spufs_context_fops;
+extern const struct file_operations spufs_context_fops;
/* gang management */
struct spu_gang *alloc_spu_gang(void);
/* gang management */
struct spu_gang *alloc_spu_gang(void);
struct tape_class_device *register_tape_dev(
struct device * device,
dev_t dev,
struct tape_class_device *register_tape_dev(
struct device * device,
dev_t dev,
- struct file_operations *fops,
+ const struct file_operations *fops,
char * device_name,
char * mode_name)
{
char * device_name,
char * mode_name)
{
struct tape_class_device *register_tape_dev(
struct device * device,
dev_t dev,
struct tape_class_device *register_tape_dev(
struct device * device,
dev_t dev,
- struct file_operations *fops,
+ const struct file_operations *fops,
char * device_name,
char * node_name
);
char * device_name,
char * node_name
);
-static struct file_operations default_file_ops = {
+static const struct file_operations default_file_ops = {
.read = default_read_file,
.write = default_write_file,
.open = default_open,
.read = default_read_file,
.write = default_write_file,
.open = default_open,
*/
struct dentry *securityfs_create_file(const char *name, mode_t mode,
struct dentry *parent, void *data,
*/
struct dentry *securityfs_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;
{
struct dentry *dentry = NULL;
int error;
.show = proc_keys_show,
};
.show = proc_keys_show,
};
-static struct file_operations proc_keys_fops = {
+static const struct file_operations proc_keys_fops = {
.open = proc_keys_open,
.read = seq_read,
.llseek = seq_lseek,
.open = proc_keys_open,
.read = seq_read,
.llseek = seq_lseek,
.show = proc_key_users_show,
};
.show = proc_key_users_show,
};
-static struct file_operations proc_key_users_fops = {
+static const struct file_operations proc_key_users_fops = {
.open = proc_key_users_open,
.read = seq_read,
.llseek = seq_lseek,
.open = proc_key_users_open,
.read = seq_read,
.llseek = seq_lseek,
#define sel_write_enforce NULL
#endif
#define sel_write_enforce NULL
#endif
-static struct file_operations sel_enforce_ops = {
+static const struct file_operations sel_enforce_ops = {
.read = sel_read_enforce,
.write = sel_write_enforce,
};
.read = sel_read_enforce,
.write = sel_write_enforce,
};
#define sel_write_disable NULL
#endif
#define sel_write_disable NULL
#endif
-static struct file_operations sel_disable_ops = {
+static const struct file_operations sel_disable_ops = {
.write = sel_write_disable,
};
.write = sel_write_disable,
};
return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
}
return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
}
-static struct file_operations sel_policyvers_ops = {
+static const struct file_operations sel_policyvers_ops = {
.read = sel_read_policyvers,
};
.read = sel_read_policyvers,
};
return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
}
return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
}
-static struct file_operations sel_mls_ops = {
+static const struct file_operations sel_mls_ops = {
-static struct file_operations sel_load_ops = {
+static const struct file_operations sel_load_ops = {
.write = sel_write_load,
};
.write = sel_write_load,
};
free_page((unsigned long) page);
return length;
}
free_page((unsigned long) page);
return length;
}
-static struct file_operations sel_checkreqprot_ops = {
+static const struct file_operations sel_checkreqprot_ops = {
.read = sel_read_checkreqprot,
.write = sel_write_checkreqprot,
};
.read = sel_read_checkreqprot,
.write = sel_write_checkreqprot,
};
free_page((unsigned long) page);
return length;
}
free_page((unsigned long) page);
return length;
}
-static struct file_operations sel_compat_net_ops = {
+static const struct file_operations sel_compat_net_ops = {
.read = sel_read_compat_net,
.write = sel_write_compat_net,
};
.read = sel_read_compat_net,
.write = sel_write_compat_net,
};
-static struct file_operations transaction_ops = {
+static const struct file_operations transaction_ops = {
.write = selinux_transaction_write,
.read = simple_transaction_read,
.release = simple_transaction_release,
.write = selinux_transaction_write,
.read = simple_transaction_read,
.release = simple_transaction_release,
-static struct file_operations sel_bool_ops = {
+static const struct file_operations sel_bool_ops = {
.read = sel_read_bool,
.write = sel_write_bool,
};
.read = sel_read_bool,
.write = sel_write_bool,
};
-static struct file_operations sel_commit_bools_ops = {
+static const struct file_operations sel_commit_bools_ops = {
.write = sel_commit_bools_write,
};
.write = sel_commit_bools_write,
};
-static struct file_operations sel_avc_cache_threshold_ops = {
+static const struct file_operations sel_avc_cache_threshold_ops = {
.read = sel_read_avc_cache_threshold,
.write = sel_write_avc_cache_threshold,
};
.read = sel_read_avc_cache_threshold,
.write = sel_write_avc_cache_threshold,
};
-static struct file_operations sel_avc_hash_stats_ops = {
+static const struct file_operations sel_avc_hash_stats_ops = {
.read = sel_read_avc_hash_stats,
};
.read = sel_read_avc_hash_stats,
};
return seq_open(file, &sel_avc_cache_stats_seq_ops);
}
return seq_open(file, &sel_avc_cache_stats_seq_ops);
}
-static struct file_operations sel_avc_cache_stats_ops = {
+static const struct file_operations sel_avc_cache_stats_ops = {
.open = sel_open_avc_cache_stats,
.read = seq_read,
.llseek = seq_lseek,
.open = sel_open_avc_cache_stats,
.read = seq_read,
.llseek = seq_lseek,
-static struct file_operations snd_ctl_f_ops =
+static const struct file_operations snd_ctl_f_ops =
{
.owner = THIS_MODULE,
.read = snd_ctl_read,
{
.owner = THIS_MODULE,
.read = snd_ctl_read,
-static struct file_operations snd_hwdep_f_ops =
+static const struct file_operations snd_hwdep_f_ops =
{
.owner = THIS_MODULE,
.llseek = snd_hwdep_llseek,
{
.owner = THIS_MODULE,
.llseek = snd_hwdep_llseek,
-static struct file_operations snd_info_entry_operations =
+static const struct file_operations snd_info_entry_operations =
{
.owner = THIS_MODULE,
.llseek = snd_info_entry_llseek,
{
.owner = THIS_MODULE,
.llseek = snd_info_entry_llseek,
static DEFINE_SPINLOCK(shutdown_lock);
static LIST_HEAD(shutdown_files);
static DEFINE_SPINLOCK(shutdown_lock);
static LIST_HEAD(shutdown_files);
-static struct file_operations snd_shutdown_f_ops;
+static const struct file_operations snd_shutdown_f_ops;
static unsigned int snd_cards_lock; /* locked for registering/using */
struct snd_card *snd_cards[SNDRV_CARDS];
static unsigned int snd_cards_lock; /* locked for registering/using */
struct snd_card *snd_cards[SNDRV_CARDS];
-static struct file_operations snd_shutdown_f_ops =
+static const struct file_operations snd_shutdown_f_ops =
{
.owner = THIS_MODULE,
.llseek = snd_disconnect_llseek,
{
.owner = THIS_MODULE,
.llseek = snd_disconnect_llseek,
-static struct file_operations snd_mixer_oss_f_ops =
+static const struct file_operations snd_mixer_oss_f_ops =
{
.owner = THIS_MODULE,
.open = snd_mixer_oss_open,
{
.owner = THIS_MODULE,
.open = snd_mixer_oss_open,
-static struct file_operations snd_pcm_oss_f_reg =
+static const struct file_operations snd_pcm_oss_f_reg =
{
.owner = THIS_MODULE,
.read = snd_pcm_oss_read,
{
.owner = THIS_MODULE,
.read = snd_pcm_oss_read,
-struct file_operations snd_pcm_f_ops[2] = {
+const struct file_operations snd_pcm_f_ops[2] = {
{
.owner = THIS_MODULE,
.write = snd_pcm_write,
{
.owner = THIS_MODULE,
.write = snd_pcm_write,
-static struct file_operations snd_rawmidi_f_ops =
+static const struct file_operations snd_rawmidi_f_ops =
{
.owner = THIS_MODULE,
.read = snd_rawmidi_read,
{
.owner = THIS_MODULE,
.read = snd_rawmidi_read,
* registration of sequencer minor device
*/
* registration of sequencer minor device
*/
-static struct file_operations seq_oss_f_ops =
+static const struct file_operations seq_oss_f_ops =
{
.owner = THIS_MODULE,
.read = odev_read,
{
.owner = THIS_MODULE,
.read = odev_read,
-static struct file_operations snd_seq_f_ops =
+static const struct file_operations snd_seq_f_ops =
{
.owner = THIS_MODULE,
.read = snd_seq_read,
{
.owner = THIS_MODULE,
.read = snd_seq_read,
-static struct file_operations snd_fops =
+static const struct file_operations snd_fops =
{
.owner = THIS_MODULE,
.open = snd_open
{
.owner = THIS_MODULE,
.open = snd_open
#define snd_timer_user_ioctl_compat NULL
#endif
#define snd_timer_user_ioctl_compat NULL
#endif
-static struct file_operations snd_timer_f_ops =
+static const struct file_operations snd_timer_f_ops =
{
.owner = THIS_MODULE,
.read = snd_timer_user_read,
{
.owner = THIS_MODULE,
.read = snd_timer_user_read,
-static struct file_operations ad1889_fops = {
+static const struct file_operations ad1889_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = ad1889_read,
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = ad1889_read,
return codec->mixer_ioctl(codec, cmd, arg);
}
return codec->mixer_ioctl(codec, cmd, arg);
}
-static struct file_operations ad1889_mixer_fops = {
+static const struct file_operations ad1889_mixer_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.ioctl = ad1889_mixer_ioctl,
.owner = THIS_MODULE,
.llseek = no_llseek,
.ioctl = ad1889_mixer_ioctl,
-static struct file_operations btaudio_mixer_fops = {
+static const struct file_operations btaudio_mixer_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.open = btaudio_mixer_open,
.owner = THIS_MODULE,
.llseek = no_llseek,
.open = btaudio_mixer_open,
-static struct file_operations btaudio_digital_dsp_fops = {
+static const struct file_operations btaudio_digital_dsp_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.open = btaudio_dsp_open_digital,
.owner = THIS_MODULE,
.llseek = no_llseek,
.open = btaudio_dsp_open_digital,
.poll = btaudio_dsp_poll,
};
.poll = btaudio_dsp_poll,
};
-static struct file_operations btaudio_analog_dsp_fops = {
+static const struct file_operations btaudio_analog_dsp_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.open = btaudio_dsp_open_analog,
.owner = THIS_MODULE,
.llseek = no_llseek,
.open = btaudio_dsp_open_analog,
-static struct file_operations mixer_fops =
+static const struct file_operations mixer_fops =
{
.owner = THIS_MODULE,
.llseek = no_llseek,
{
.owner = THIS_MODULE,
.llseek = no_llseek,
-static struct file_operations sq_fops =
+static const struct file_operations sq_fops =
{
.owner = THIS_MODULE,
.llseek = no_llseek,
{
.owner = THIS_MODULE,
.llseek = no_llseek,
-static struct file_operations state_fops = {
+static const struct file_operations state_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = state_read,
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = state_read,
-struct file_operations emu10k1_audio_fops = {
+const struct file_operations emu10k1_audio_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = emu10k1_audio_read,
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = emu10k1_audio_read,
}
/* MIDI file operations */
}
/* MIDI file operations */
-struct file_operations emu10k1_midi_fops = {
+const struct file_operations emu10k1_midi_fops = {
.owner = THIS_MODULE,
.read = emu10k1_midi_read,
.write = emu10k1_midi_write,
.owner = THIS_MODULE,
.read = emu10k1_midi_read,
.write = emu10k1_midi_write,
-struct file_operations emu10k1_mixer_fops = {
+const struct file_operations emu10k1_mixer_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.ioctl = emu10k1_mixer_ioctl,
.owner = THIS_MODULE,
.llseek = no_llseek,
.ioctl = emu10k1_mixer_ioctl,
-static struct file_operations hal2_audio_fops = {
+static const struct file_operations hal2_audio_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = hal2_read,
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = hal2_read,
.release = hal2_release,
};
.release = hal2_release,
};
-static struct file_operations hal2_mixer_fops = {
+static const struct file_operations hal2_mixer_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.ioctl = hal2_ioctl_mixdev,
.owner = THIS_MODULE,
.llseek = no_llseek,
.ioctl = hal2_ioctl_mixdev,
-static struct file_operations dev_fileops = {
+static const struct file_operations dev_fileops = {
.owner = THIS_MODULE,
.read = dev_read,
.write = dev_write,
.owner = THIS_MODULE,
.read = dev_read,
.write = dev_write,
#undef PSEUDO_DMA_AUTOINIT
#define ALLOW_BUFFER_MAPPING
#undef PSEUDO_DMA_AUTOINIT
#define ALLOW_BUFFER_MAPPING
-extern struct file_operations oss_sound_fops;
+extern const struct file_operations oss_sound_fops;
-struct file_operations dac_audio_fops = {
+const struct file_operations dac_audio_fops = {
.read = dac_audio_read,
.write = dac_audio_write,
.ioctl = dac_audio_ioctl,
.read = dac_audio_read,
.write = dac_audio_write,
.ioctl = dac_audio_ioctl,
-struct file_operations oss_sound_fops = {
+const struct file_operations oss_sound_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = sound_read,
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = sound_read,
-static struct file_operations via_mixer_fops = {
+static const struct file_operations via_mixer_fops = {
.owner = THIS_MODULE,
.open = via_mixer_open,
.llseek = no_llseek,
.owner = THIS_MODULE,
.open = via_mixer_open,
.llseek = no_llseek,
-static struct file_operations via_dsp_fops = {
+static const struct file_operations via_dsp_fops = {
.owner = THIS_MODULE,
.open = via_dsp_open,
.release = via_dsp_release,
.owner = THIS_MODULE,
.open = via_dsp_open,
.release = via_dsp_release,
-static struct file_operations vwsnd_audio_fops = {
+static const struct file_operations vwsnd_audio_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = vwsnd_audio_read,
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = vwsnd_audio_read,
-static struct file_operations vwsnd_mixer_fops = {
+static const struct file_operations vwsnd_mixer_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.ioctl = vwsnd_mixer_ioctl,
.owner = THIS_MODULE,
.llseek = no_llseek,
.ioctl = vwsnd_mixer_ioctl,
static int soundcore_open(struct inode *, struct file *);
static int soundcore_open(struct inode *, struct file *);
-static struct file_operations soundcore_fops=
+static const struct file_operations soundcore_fops=
{
/* We must have an owner or the module locking fails */
.owner = THIS_MODULE,
{
/* We must have an owner or the module locking fails */
.owner = THIS_MODULE,