Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9c2e08c5 authored by Arjan van de Ven's avatar Arjan van de Ven Committed by Linus Torvalds
Browse files

[PATCH] mark struct file_operations const 9



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: default avatarArjan van de Ven <arjan@linux.intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent da7071d7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -149,7 +149,7 @@ long spufs_run_spu(struct file *file,
		   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);
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ static struct class *tape_class;
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)
{
+1 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ struct tape_class_device {
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
);
+2 −2
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ static int default_open(struct inode *inode, struct file *file)
	return 0;
}

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,
@@ -215,7 +215,7 @@ static int create_by_name(const char *name, mode_t mode,
 */
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;
+2 −2
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ static struct seq_operations proc_keys_ops = {
	.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,
@@ -54,7 +54,7 @@ static struct seq_operations proc_key_users_ops = {
	.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,
Loading