All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] const struct file_operations *
@ 2003-06-24 14:05 David Woodhouse
  2003-06-24 14:14 ` Matthew Wilcox
  0 siblings, 1 reply; 3+ messages in thread
From: David Woodhouse @ 2003-06-24 14:05 UTC (permalink / raw)
  To: torvalds; +Cc: linux-fsdevel

I found driver authors overriding individual file_operations members at
runtime. Let's make it hurt at least a little...

For configurations with kernel .rodata in ROM instead of RAM, it's
actually slightly advantageous to have these structures marked as const
too -- but that can be done later and isn't mandatory.

===== drivers/char/misc.c 1.20 vs edited =====
--- 1.20/drivers/char/misc.c	Sat May 17 20:39:13 2003
+++ edited/drivers/char/misc.c	Tue Jun 24 14:56:39 2003
@@ -103,7 +103,7 @@
 	int minor = minor(inode->i_rdev);
 	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);
 	
===== drivers/input/input.c 1.32 vs edited =====
--- 1.32/drivers/input/input.c	Mon Jun  9 12:44:00 2003
+++ edited/drivers/input/input.c	Tue Jun 24 14:57:24 2003
@@ -528,7 +528,7 @@
 static int input_open_file(struct inode *inode, struct file *file)
 {
 	struct input_handler *handler = input_table[minor(inode->i_rdev) >> 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? */
===== fs/select.c 1.20 vs edited =====
--- 1.20/fs/select.c	Thu May  8 05:21:13 2003
+++ edited/fs/select.c	Tue Jun 24 14:53:35 2003
@@ -203,7 +203,7 @@
 		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++;
===== fs/proc/generic.c 1.21 vs edited =====
--- 1.21/fs/proc/generic.c	Fri Apr 25 16:46:19 2003
+++ edited/fs/proc/generic.c	Tue Jun 24 14:55:30 2003
@@ -498,7 +498,7 @@
 		struct file * filp = list_entry(p, struct file, f_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;
===== include/linux/fs.h 1.251 vs edited =====
--- 1.251/include/linux/fs.h	Fri Jun 20 21:16:06 2003
+++ edited/include/linux/fs.h	Tue Jun 24 14:51:39 2003
@@ -371,8 +371,8 @@
 	unsigned short          i_bytes;
 	spinlock_t		i_lock;	/* i_blocks, i_bytes, maybe i_size */
 	struct semaphore	i_sem;
-	struct inode_operations	*i_op;
-	struct file_operations	*i_fop;	/* former ->i_op->default_file_ops */
+	const struct inode_operations *i_op;
+	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;
@@ -426,7 +426,7 @@
 	struct list_head	f_list;
 	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;




-- 
dwmw2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] const struct file_operations *
  2003-06-24 14:05 [PATCH] const struct file_operations * David Woodhouse
@ 2003-06-24 14:14 ` Matthew Wilcox
  2003-06-24 14:16   ` David Woodhouse
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2003-06-24 14:14 UTC (permalink / raw)
  To: David Woodhouse; +Cc: torvalds, linux-fsdevel

On Tue, Jun 24, 2003 at 03:05:58PM +0100, David Woodhouse wrote:
> For configurations with kernel .rodata in ROM instead of RAM, it's
> actually slightly advantageous to have these structures marked as const
> too -- but that can be done later and isn't mandatory.

And indeed may not be advantageous.  ROM accesses are typically slower
than RAM accesses (or were, back when I cared about these kinds of
things).  Doing this kind of thing is good though -- the more ways we
can get compilers to bitch about badly written code, the better.

-- 
"It's not Hollywood.  War is real, war is primarily not about defeat or
victory, it is about death.  I've seen thousands and thousands of dead bodies.
Do you think I want to have an academic debate on this subject?" -- Robert Fisk

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] const struct file_operations *
  2003-06-24 14:14 ` Matthew Wilcox
@ 2003-06-24 14:16   ` David Woodhouse
  0 siblings, 0 replies; 3+ messages in thread
From: David Woodhouse @ 2003-06-24 14:16 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: torvalds, linux-fsdevel

On Tue, 2003-06-24 at 15:14, Matthew Wilcox wrote:
> On Tue, Jun 24, 2003 at 03:05:58PM +0100, David Woodhouse wrote:
> > For configurations with kernel .rodata in ROM instead of RAM, it's
> > actually slightly advantageous to have these structures marked as const
> > too -- but that can be done later and isn't mandatory.
> 
> And indeed may not be advantageous.  ROM accesses are typically slower
> than RAM accesses (or were, back when I cared about these kinds of
> things).

Don't get me started on how pointless XIP is... :)

-- 
dwmw2


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-06-24 14:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-24 14:05 [PATCH] const struct file_operations * David Woodhouse
2003-06-24 14:14 ` Matthew Wilcox
2003-06-24 14:16   ` David Woodhouse

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.