public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -tip] x86: kdebugfs.c cleanup
@ 2009-03-14 15:01 Jaswinder Singh Rajput
  2009-03-15  4:18 ` Li Zefan
  0 siblings, 1 reply; 3+ messages in thread
From: Jaswinder Singh Rajput @ 2009-03-14 15:01 UTC (permalink / raw)
  To: Ingo Molnar, x86 maintainers, LKML

Subject: [PATCH] x86: kdebugfs.c cleanup

Impact: cleanup

Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
---
 arch/x86/kernel/kdebugfs.c |   35 +++++++++++++++++++++++------------
 1 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
index ff7d3b0..3d292f0 100644
--- a/arch/x86/kernel/kdebugfs.c
+++ b/arch/x86/kernel/kdebugfs.c
@@ -8,11 +8,11 @@
  */
 #include <linux/debugfs.h>
 #include <linux/uaccess.h>
-#include <linux/stat.h>
+#include <linux/module.h>
 #include <linux/init.h>
+#include <linux/stat.h>
 #include <linux/io.h>
 #include <linux/mm.h>
-#include <linux/module.h>
 
 #include <asm/setup.h>
 
@@ -26,9 +26,8 @@ struct setup_data_node {
 	u32 len;
 };
 
-static ssize_t
-setup_data_read(struct file *file, char __user *user_buf, size_t count,
-		loff_t *ppos)
+static ssize_t setup_data_read(struct file *file, char __user *user_buf,
+			       size_t count, loff_t *ppos)
 {
 	struct setup_data_node *node = file->private_data;
 	unsigned long remain;
@@ -39,20 +38,21 @@ setup_data_read(struct file *file, char __user *user_buf, size_t count,
 
 	if (pos < 0)
 		return -EINVAL;
+
 	if (pos >= node->len)
 		return 0;
 
 	if (count > node->len - pos)
 		count = node->len - pos;
+
 	pa = node->paddr + sizeof(struct setup_data) + pos;
 	pg = pfn_to_page((pa + count - 1) >> PAGE_SHIFT);
 	if (PageHighMem(pg)) {
 		p = ioremap_cache(pa, count);
 		if (!p)
 			return -ENXIO;
-	} else {
+	} else
 		p = __va(pa);
-	}
 
 	remain = copy_to_user(user_buf, p, count);
 
@@ -70,12 +70,13 @@ setup_data_read(struct file *file, char __user *user_buf, size_t count,
 static int setup_data_open(struct inode *inode, struct file *file)
 {
 	file->private_data = inode->i_private;
+
 	return 0;
 }
 
 static const struct file_operations fops_setup_data = {
-	.read =		setup_data_read,
-	.open =		setup_data_open,
+	.read		= setup_data_read,
+	.open		= setup_data_open,
 };
 
 static int __init
@@ -92,16 +93,19 @@ create_setup_data_node(struct dentry *parent, int no,
 		error = -ENOMEM;
 		goto err_return;
 	}
+
 	type = debugfs_create_x32("type", S_IRUGO, d, &node->type);
 	if (!type) {
 		error = -ENOMEM;
 		goto err_dir;
 	}
+
 	data = debugfs_create_file("data", S_IRUGO, d, node, &fops_setup_data);
 	if (!data) {
 		error = -ENOMEM;
 		goto err_type;
 	}
+
 	return 0;
 
 err_type:
@@ -135,6 +139,7 @@ static int __init create_setup_data_nodes(struct dentry *parent)
 			error = -ENOMEM;
 			goto err_dir;
 		}
+
 		pg = pfn_to_page((pa_data+sizeof(*data)-1) >> PAGE_SHIFT);
 		if (PageHighMem(pg)) {
 			data = ioremap_cache(pa_data, sizeof(*data));
@@ -143,9 +148,8 @@ static int __init create_setup_data_nodes(struct dentry *parent)
 				error = -ENXIO;
 				goto err_dir;
 			}
-		} else {
+		} else
 			data = __va(pa_data);
-		}
 
 		node->paddr = pa_data;
 		node->type = data->type;
@@ -155,10 +159,13 @@ static int __init create_setup_data_nodes(struct dentry *parent)
 
 		if (PageHighMem(pg))
 			iounmap(data);
+
 		if (error)
 			goto err_dir;
+
 		no++;
 	}
+
 	return 0;
 
 err_dir:
@@ -182,21 +189,25 @@ static int __init boot_params_kdebugfs_init(void)
 		error = -ENOMEM;
 		goto err_return;
 	}
+
 	version = debugfs_create_x16("version", S_IRUGO, dbp,
 				     &boot_params.hdr.version);
 	if (!version) {
 		error = -ENOMEM;
 		goto err_dir;
 	}
+
 	data = debugfs_create_blob("data", S_IRUGO, dbp,
 				   &boot_params_blob);
 	if (!data) {
 		error = -ENOMEM;
 		goto err_version;
 	}
+
 	error = create_setup_data_nodes(dbp);
 	if (error)
 		goto err_data;
+
 	return 0;
 
 err_data:
@@ -208,7 +219,7 @@ err_dir:
 err_return:
 	return error;
 }
-#endif
+#endif /* CONFIG_DEBUG_BOOT_PARAMS */
 
 static int __init arch_kdebugfs_init(void)
 {
-- 
1.6.0.6




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

* Re: [PATCH -tip] x86: kdebugfs.c cleanup
  2009-03-14 15:01 [PATCH -tip] x86: kdebugfs.c cleanup Jaswinder Singh Rajput
@ 2009-03-15  4:18 ` Li Zefan
  2009-03-15  4:54   ` Ingo Molnar
  0 siblings, 1 reply; 3+ messages in thread
From: Li Zefan @ 2009-03-15  4:18 UTC (permalink / raw)
  To: Jaswinder Singh Rajput; +Cc: Ingo Molnar, x86 maintainers, LKML

>  #include <linux/debugfs.h>
>  #include <linux/uaccess.h>
> -#include <linux/stat.h>
> +#include <linux/module.h>
>  #include <linux/init.h>
> +#include <linux/stat.h>
>  #include <linux/io.h>
>  #include <linux/mm.h>
> -#include <linux/module.h>
>  

Just curious about the rule to sort those includes, and why they need
to be rearranged.

>  #include <asm/setup.h>
>  

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

* Re: [PATCH -tip] x86: kdebugfs.c cleanup
  2009-03-15  4:18 ` Li Zefan
@ 2009-03-15  4:54   ` Ingo Molnar
  0 siblings, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2009-03-15  4:54 UTC (permalink / raw)
  To: Li Zefan; +Cc: Jaswinder Singh Rajput, x86 maintainers, LKML


* Li Zefan <lizf@cn.fujitsu.com> wrote:

> >  #include <linux/debugfs.h>
> >  #include <linux/uaccess.h>
> > -#include <linux/stat.h>
> > +#include <linux/module.h>
> >  #include <linux/init.h>
> > +#include <linux/stat.h>
> >  #include <linux/io.h>
> >  #include <linux/mm.h>
> > -#include <linux/module.h>
> >  
> 
> Just curious about the rule to sort those includes, and why they need
> to be rearranged.

Such includes (the 'reverse christmas tree'):

#include <linux/interrupt.h>
#include <linux/mmiotrace.h>
#include <linux/bootmem.h>
#include <linux/compiler.h>
#include <linux/highmem.h>
#include <linux/kprobes.h>
#include <linux/uaccess.h>
#include <linux/vmalloc.h>
#include <linux/vt_kern.h>
#include <linux/signal.h>
#include <linux/kernel.h>
#include <linux/ptrace.h>
#include <linux/string.h>
#include <linux/module.h>
#include <linux/kdebug.h>
#include <linux/errno.h>
#include <linux/magic.h>
#include <linux/sched.h>
#include <linux/types.h>
#include <linux/init.h>
#include <linux/mman.h>
#include <linux/tty.h>
#include <linux/smp.h>
#include <linux/mm.h>

#include <asm/kmemcheck.h>
#include <asm/tlbflush.h>
#include <asm/pgalloc.h>
#include <asm/segment.h>
#include <asm/system.h>
#include <asm/proto.h>
#include <asm/traps.h>
#include <asm/desc.h>

are used by x86 architecture code (and some other subsystems) to 
reduce the likelyhood of patch conflicts in commonly modified 
kernel files.

Without such ordering developers typically append to the 
existing list of include files when introducing a new header - 
creating an almost certain patch conflict. Via the above 
ordering, new headers get distributed roughly evenly amongst the 
full range - and thus the chance of patch conflicts is much 
smaller.

This way it also looks a bit more structured and bit less messy. 
It looks unprofessional and sloppy if a .c file starts with a 
big block of thrown-together include files.

	Ingo

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

end of thread, other threads:[~2009-03-15  4:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-14 15:01 [PATCH -tip] x86: kdebugfs.c cleanup Jaswinder Singh Rajput
2009-03-15  4:18 ` Li Zefan
2009-03-15  4:54   ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox