Skip to contentSkip to conversation

- create common header for init/main.c called init functions

PATCH In review Ben Dooks 3 participants 5 messages Oct 14, 2005 – Oct 19, 2005

Subsystems (7)
VFS ACPI Library code MM core +3 more subsystems
lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

PATCH 1/1 - create common header for init/main.c called init functions

init/main.c calls a number of functions externally but declaring them locally. This patch creates a new header (linux/kernel_init.h) and moves all the declarations into it.

Also removes any old init functions now done by an initcall()

drivers/acpi/bus.c +1 -0
diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/drivers/acpi/bus.c linux-2.6.14-rc4-bjd3c/drivers/acpi/bus.c
@@ -30,6 +30,7 @@
 #include <linux/pm.h>
 #include <linux/device.h>
 #include <linux/proc_fs.h>
+#include <linux/kernel_init.h>
 #ifdef CONFIG_X86
 #include <asm/mpspec.h>
 #endif
drivers/base/init.c +1 -0
diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/drivers/base/init.c linux-2.6.14-rc4-bjd3c/drivers/base/init.c
@@ -9,6 +9,7 @@
 
 #include <linux/device.h>
 #include <linux/init.h>
+#include <linux/kernel_init.h>
 
 #include "base.h"
 
fs/buffer.c +2 -0
diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/fs/buffer.c linux-2.6.14-rc4-bjd3c/fs/buffer.c
@@ -19,7 +19,9 @@
  */
 
 #include <linux/config.h>
+#include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/kernel_init.h>
 #include <linux/syscalls.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
include/linux/kernel_init.h +26 -0
diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/include/linux/kernel_init.h linux-2.6.14-rc4-bjd3c/include/linux/kernel_init.h
@@ -0,0 +1,26 @@
+/* include/linux/kernel_init.h
+ *
+ * (C) 2005 Simtec Electronics
+ *	Ben Dooks <[email protected]>
+ *
+ * Initialisation function prototypes
+*/
+
+extern void init_IRQ(void);
+extern void __init fork_init(unsigned long);
+extern void __init signals_init(void);
+extern void __init buffer_init(void);
+extern void __init driver_init(void);
+extern void __init pidhash_init(void);
+extern void __init pidmap_init(void);
+extern void __init prio_tree_init(void);
+extern void __init populate_rootfs(void);
+extern void __init prepare_namespace(void);
+
+extern void free_initmem(void);
+
+#ifdef	CONFIG_ACPI
+extern void __init acpi_early_init(void);
+#else
+static inline void acpi_early_init(void) { }
+#endif
init/do_mounts.c +1 -0
diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/init/do_mounts.c linux-2.6.14-rc4-bjd3c/init/do_mounts.c
@@ -8,6 +8,7 @@
 #include <linux/security.h>
 #include <linux/delay.h>
 #include <linux/mount.h>
+#include <linux/kernel_init.h>
 
 #include <linux/nfs_fs.h>
 #include <linux/nfs_fs_sb.h>
init/initramfs.c +1 -0
diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/init/initramfs.c linux-2.6.14-rc4-bjd3c/init/initramfs.c
@@ -6,6 +6,7 @@
 #include <linux/delay.h>
 #include <linux/string.h>
 #include <linux/syscalls.h>
+#include <linux/kernel_init.h>
 
 static __initdata char *message;
 static void __init error(char *x)
init/main.c +4 -23
diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/init/main.c linux-2.6.14-rc4-bjd3c/init/main.c
@@ -17,6 +17,7 @@
 #include <linux/proc_fs.h>
 #include <linux/devfs_fs_kernel.h>
 #include <linux/kernel.h>
+#include <linux/kernel_init.h>
 #include <linux/syscalls.h>
 #include <linux/string.h>
 #include <linux/ctype.h>
@@ -47,8 +48,11 @@
 #include <linux/rmap.h>
 #include <linux/mempolicy.h>
 #include <linux/key.h>
+#include <linux/sysctl.h>
 #include <net/sock.h>
 
+#include <linux/radix-tree.h>
+
 #include <asm/io.h>
 #include <asm/bugs.h>
 #include <asm/setup.h>
@@ -80,30 +84,7 @@
 
 static int init(void *);
 
-extern void init_IRQ(void);
-extern void fork_init(unsigned long);
-extern void mca_init(void);
-extern void sbus_init(void);
-extern void sysctl_init(void);
-extern void signals_init(void);
-extern void buffer_init(void);
-extern void pidhash_init(void);
-extern void pidmap_init(void);
-extern void prio_tree_init(void);
-extern void radix_tree_init(void);
-extern void free_initmem(void);
-extern void populate_rootfs(void);
-extern void driver_init(void);
-extern void prepare_namespace(void);
-#ifdef	CONFIG_ACPI
-extern void acpi_early_init(void);
-#else
-static inline void acpi_early_init(void) { }
-#endif
 
-#ifdef CONFIG_TC
-extern void tc_init(void);
-#endif
 
 enum system_states system_state;
 EXPORT_SYMBOL(system_state);
kernel/fork.c +1 -0
diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/kernel/fork.c linux-2.6.14-rc4-bjd3c/kernel/fork.c
@@ -42,6 +42,7 @@
 #include <linux/profile.h>
 #include <linux/rmap.h>
 #include <linux/acct.h>
+#include <linux/kernel_init.h>
 
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
kernel/pid.c +1 -0
diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/kernel/pid.c linux-2.6.14-rc4-bjd3c/kernel/pid.c
@@ -26,6 +26,7 @@
 #include <linux/init.h>
 #include <linux/bootmem.h>
 #include <linux/hash.h>
+#include <linux/kernel_init.h>
 
 #define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift)
 static struct hlist_head *pid_hash[PIDTYPE_MAX];
kernel/signal.c +1 -0
diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/kernel/signal.c linux-2.6.14-rc4-bjd3c/kernel/signal.c
@@ -25,6 +25,7 @@
 #include <linux/posix-timers.h>
 #include <linux/signal.h>
 #include <linux/audit.h>
+#include <linux/kernel_init.h>
 #include <asm/param.h>
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
lib/prio_tree.c +1 -0
diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/lib/prio_tree.c linux-2.6.14-rc4-bjd3c/lib/prio_tree.c
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/prio_tree.h>
+#include <linux/kernel_init.h>
 
 /*
  * A clever mix of heap and radix trees forms a radix priority search tree (PST)
lib/radix-tree.c +1 -0
diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/lib/radix-tree.c linux-2.6.14-rc4-bjd3c/lib/radix-tree.c
@@ -21,6 +21,7 @@
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/kernel_init.h>
 #include <linux/module.h>
 #include <linux/radix-tree.h>
 #include <linux/percpu.h>
#1 lore raw
Quoted 4 lines · Ben Dooks

init/main.c calls a number of functions externally but declaring them locally. This patch creates a new header (linux/kernel_init.h) and moves all the declarations into it.

These functions are only referenced in init/main.c, and rightfully so. In the end, this doesn't change anything much, other than maintainance overhead for the new include/linux/kernel_init.h

But, comments within..

Quoted 2 lines

Also removes any old init functions now done by an initcall()

(mca|sbus|tc)_init() removal look good.

drivers/acpi/bus.c line 33

Quoted 10 lines

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/drivers/acpi/bus.c linux-2.6.14-rc4-bjd3c/drivers/acpi/bus.c

drivers/acpi/bus.c +1 -0
@@ -30,6 +30,7 @@
 #include <linux/pm.h>
 #include <linux/device.h>
 #include <linux/proc_fs.h>
+#include <linux/kernel_init.h>

Unecessary, acpi_early_init() defined here.

drivers/base/init.c line 12

Quoted 11 lines
drivers/acpi/bus.c +0 -0
 #ifdef CONFIG_X86
 #include <asm/mpspec.h>
 #endif

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/drivers/base/init.c linux-2.6.14-rc4-bjd3c/drivers/base/init.c

drivers/base/init.c +1 -0
@@ -9,6 +9,7 @@
 
 #include <linux/device.h>
 #include <linux/init.h>
+#include <linux/kernel_init.h>

Ditto driver_init().

fs/buffer.c line 24

Quoted 12 lines
drivers/base/init.c +0 -0
 #include "base.h"
 

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/fs/buffer.c linux-2.6.14-rc4-bjd3c/fs/buffer.c

fs/buffer.c +2 -0
@@ -19,7 +19,9 @@
  */
 
 #include <linux/config.h>
+#include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/kernel_init.h>

Ditto buffer_init().

include/linux/kernel_init.h

Quoted 7 lines
fs/buffer.c +0 -0
 #include <linux/syscalls.h>
 #include <linux/fs.h>
 #include <linux/mm.h>

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/include/linux/kernel_init.h linux-2.6.14-rc4-bjd3c/include/linux/kernel_init.h

include/linux/kernel_init.h +0 -0
@@ -0,0 +1,26 @@

#ifndef _LINUX_KERNEL_INIT_H
#define _LINUX_KERNEL_INIT_H

include/linux/kernel_init.h line 4

Quoted 4 lines
include/linux/kernel_init.h +4 -0
+/* include/linux/kernel_init.h
+ *
+ * (C) 2005 Simtec Electronics
+ *	Ben Dooks <[email protected]>

A little too much, no? This is only moving existing stuff around..

Quoted 4 lines
include/linux/kernel_init.h +4 -0
+ *
+ * Initialisation function prototypes
+*/
+

include/linux/kernel_init.h line 18

Quoted 10 lines
include/linux/kernel_init.h +10 -0
+extern void init_IRQ(void);
+extern void __init fork_init(unsigned long);
+extern void __init signals_init(void);
+extern void __init buffer_init(void);
+extern void __init driver_init(void);
+extern void __init pidhash_init(void);
+extern void __init pidmap_init(void);
+extern void __init prio_tree_init(void);
+extern void __init populate_rootfs(void);
+extern void __init prepare_namespace(void);

extern void foo_init(void) __init;

include/linux/kernel_init.h line 26

Quoted 8 lines
include/linux/kernel_init.h +8 -0
+
+extern void free_initmem(void);
+
+#ifdef	CONFIG_ACPI
+extern void __init acpi_early_init(void);
+#else
+static inline void acpi_early_init(void) { }
+#endif

#endif /* _LINUX_KERNEL_INIT_H */

init/do_mounts.c line 11

Quoted 8 lines

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/init/do_mounts.c linux-2.6.14-rc4-bjd3c/init/do_mounts.c

init/do_mounts.c +1 -0
@@ -8,6 +8,7 @@
 #include <linux/security.h>
 #include <linux/delay.h>
 #include <linux/mount.h>
+#include <linux/kernel_init.h>

Unecessary, prepare_namespace() defined here.

init/initramfs.c line 9

Quoted 10 lines
init/do_mounts.c +0 -0
 #include <linux/nfs_fs.h>
 #include <linux/nfs_fs_sb.h>

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/init/initramfs.c linux-2.6.14-rc4-bjd3c/init/initramfs.c

init/initramfs.c +1 -0
@@ -6,6 +6,7 @@
 #include <linux/delay.h>
 #include <linux/string.h>
 #include <linux/syscalls.h>
+#include <linux/kernel_init.h>

Ditto populate_rootfs().

Quoted 14 lines
init/initramfs.c +0 -0
 static __initdata char *message;
 static void __init error(char *x)

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/init/main.c linux-2.6.14-rc4-bjd3c/init/main.c

init/main.c +1 -0
@@ -17,6 +17,7 @@
 #include <linux/proc_fs.h>
 #include <linux/devfs_fs_kernel.h>
 #include <linux/kernel.h>
+#include <linux/kernel_init.h>
 #include <linux/syscalls.h>
 #include <linux/string.h>
 #include <linux/ctype.h>

init/main.c line 55

Quoted 8 lines
init/main.c +3 -0
@@ -47,8 +48,11 @@
 #include <linux/rmap.h>
 #include <linux/mempolicy.h>
 #include <linux/key.h>
+#include <linux/sysctl.h>
 #include <net/sock.h>
 
+#include <linux/radix-tree.h>
+

No need for the extra whitespace, could have as well gone right below <linux/sysctl.h>

Quoted 38 lines
init/main.c +0 -23
 #include <asm/io.h>
 #include <asm/bugs.h>
 #include <asm/setup.h>
@@ -80,30 +84,7 @@
 
 static int init(void *);
 
-extern void init_IRQ(void);
-extern void fork_init(unsigned long);
-extern void mca_init(void);
-extern void sbus_init(void);
-extern void sysctl_init(void);
-extern void signals_init(void);
-extern void buffer_init(void);
-extern void pidhash_init(void);
-extern void pidmap_init(void);
-extern void prio_tree_init(void);
-extern void radix_tree_init(void);
-extern void free_initmem(void);
-extern void populate_rootfs(void);
-extern void driver_init(void);
-extern void prepare_namespace(void);
-#ifdef	CONFIG_ACPI
-extern void acpi_early_init(void);
-#else
-static inline void acpi_early_init(void) { }
-#endif
 
-#ifdef CONFIG_TC
-extern void tc_init(void);
-#endif
 
 enum system_states system_state;
 EXPORT_SYMBOL(system_state);

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/kernel/fork.c linux-2.6.14-rc4-bjd3c/kernel/fork.c

kernel/fork.c line 45

Quoted 4 lines
kernel/fork.c +1 -0
@@ -42,6 +42,7 @@
 #include <linux/profile.h>
 #include <linux/rmap.h>
 #include <linux/acct.h>
+#include <linux/kernel_init.h>

Unecessary, fork_init() defined here.

kernel/pid.c line 29

Quoted 10 lines
kernel/fork.c +0 -0
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/kernel/pid.c linux-2.6.14-rc4-bjd3c/kernel/pid.c

kernel/pid.c +1 -0
@@ -26,6 +26,7 @@
 #include <linux/init.h>
 #include <linux/bootmem.h>
 #include <linux/hash.h>
+#include <linux/kernel_init.h>

Ditto pid(map|hash)_init().

kernel/signal.c line 28

Quoted 10 lines
kernel/pid.c +0 -0
 #define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift)
 static struct hlist_head *pid_hash[PIDTYPE_MAX];

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/kernel/signal.c linux-2.6.14-rc4-bjd3c/kernel/signal.c

kernel/signal.c +1 -0
@@ -25,6 +25,7 @@
 #include <linux/posix-timers.h>
 #include <linux/signal.h>
 #include <linux/audit.h>
+#include <linux/kernel_init.h>

Ditto signals_init().

lib/prio_tree.c line 17

Quoted 11 lines
kernel/signal.c +0 -0
 #include <asm/param.h>
 #include <asm/uaccess.h>
 #include <asm/unistd.h>

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/lib/prio_tree.c linux-2.6.14-rc4-bjd3c/lib/prio_tree.c

lib/prio_tree.c +1 -0
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/prio_tree.h>
+#include <linux/kernel_init.h>

Ditto prio_tree_init().

lib/radix-tree.c line 24

Quoted 10 lines
lib/prio_tree.c +0 -0
 /*
  * A clever mix of heap and radix trees forms a radix priority search tree (PST)

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/lib/radix-tree.c linux-2.6.14-rc4-bjd3c/lib/radix-tree.c

lib/radix-tree.c +1 -0
@@ -21,6 +21,7 @@
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/kernel_init.h>

Ditto radix_tree_init(), and already prototyped in include/linux/radix-tree.h:

Quoted 3 lines
lib/radix-tree.c +0 -0
 #include <linux/module.h>
 #include <linux/radix-tree.h>
 #include <linux/percpu.h>
#2 lore raw
Quoted 10 lines · Arthur Othieno
Quoted 4 lines · Ben Dooks

init/main.c calls a number of functions externally but declaring them locally. This patch creates a new header (linux/kernel_init.h) and moves all the declarations into it.

These functions are only referenced in init/main.c, and rightfully so. In the end, this doesn't change anything much, other than maintainance overhead for the new include/linux/kernel_init.h
...

I disagree.

Without having looked deeper at the details of this specific patch, it's generally a good cleanup to move function declarations to header files.

This avoids the nasty class of runtime errors we sometimes get when someone changes the prototype of a function but forgets to update all the prototypes floating around in .c files.

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
author
#3 lore raw
In reply to Arthur Othieno
Quoted 9 lines · Arthur Othieno
Quoted 4 lines · Ben Dooks

init/main.c calls a number of functions externally but declaring them locally. This patch creates a new header (linux/kernel_init.h) and moves all the declarations into it.

These functions are only referenced in init/main.c, and rightfully so. In the end, this doesn't change anything much, other than maintainance overhead for the new include/linux/kernel_init.h

Yes, but they generate warnings from sparse, and there are currently quite a lot of them.

Maybe the patch should move the init functions into their respective header files, i'll look at sortig that out and re-issuing them.

Quoted 9 lines

But, comments within..

Quoted 2 lines

Also removes any old init functions now done by an initcall()

(mca|sbus|tc)_init() removal look good.

Quoted 1 line
Quoted 10 lines

drivers/acpi/bus.c line 33

Quoted 8 lines

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/drivers/acpi/bus.c linux-2.6.14-rc4-bjd3c/drivers/acpi/bus.c

drivers/acpi/bus.c +1 -0
@@ -30,6 +30,7 @@
 #include <linux/pm.h>
 #include <linux/device.h>
 #include <linux/proc_fs.h>
+#include <linux/kernel_init.h>

Unecessary, acpi_early_init() defined here.

I missed the actual definition, but, you notice it is wrappered in CONFIG_X86, which isn't much used on non X86 systems.

Quoted 22 lines

drivers/base/init.c line 12

Quoted 11 lines
drivers/acpi/bus.c +0 -0
 #ifdef CONFIG_X86
 #include <asm/mpspec.h>
 #endif

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/drivers/base/init.c linux-2.6.14-rc4-bjd3c/drivers/base/init.c

drivers/base/init.c +1 -0
@@ -9,6 +9,7 @@
 
 #include <linux/device.h>
 #include <linux/init.h>
+#include <linux/kernel_init.h>

Ditto driver_init().

Quoted 8 lines
drivers/base/init.c +0 -0
 #include "base.h"
 

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/fs/buffer.c linux-2.6.14-rc4-bjd3c/fs/buffer.c

fs/buffer.c +0 -0
@@ -19,7 +19,9 @@
  */
 
Quoted 6 lines

fs/buffer.c line 24

Quoted 4 lines
fs/buffer.c +2 -0
 #include <linux/config.h>
+#include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/kernel_init.h>

Ditto buffer_init().

not a header file

Quoted 46 lines

include/linux/kernel_init.h

Quoted 7 lines
fs/buffer.c +0 -0
 #include <linux/syscalls.h>
 #include <linux/fs.h>
 #include <linux/mm.h>

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/include/linux/kernel_init.h linux-2.6.14-rc4-bjd3c/include/linux/kernel_init.h

include/linux/kernel_init.h +0 -0
@@ -0,0 +1,26 @@

#ifndef _LINUX_KERNEL_INIT_H
#define _LINUX_KERNEL_INIT_H

include/linux/kernel_init.h line 4

Quoted 4 lines
include/linux/kernel_init.h +4 -0
+/* include/linux/kernel_init.h
+ *
+ * (C) 2005 Simtec Electronics
+ *	Ben Dooks <[email protected]>

A little too much, no? This is only moving existing stuff around..

Quoted 4 lines
include/linux/kernel_init.h +4 -0
+ *
+ * Initialisation function prototypes
+*/
+

include/linux/kernel_init.h line 18

Quoted 10 lines
include/linux/kernel_init.h +10 -0
+extern void init_IRQ(void);
+extern void __init fork_init(unsigned long);
+extern void __init signals_init(void);
+extern void __init buffer_init(void);
+extern void __init driver_init(void);
+extern void __init pidhash_init(void);
+extern void __init pidmap_init(void);
+extern void __init prio_tree_init(void);
+extern void __init populate_rootfs(void);
+extern void __init prepare_namespace(void);

extern void foo_init(void) __init;

include/linux/kernel_init.h line 26

Quoted 8 lines
include/linux/kernel_init.h +8 -0
+
+extern void free_initmem(void);
+
+#ifdef	CONFIG_ACPI
+extern void __init acpi_early_init(void);
+#else
+static inline void acpi_early_init(void) { }
+#endif

#endif /* _LINUX_KERNEL_INIT_H */

Quoted 10 lines

init/do_mounts.c line 11

Quoted 8 lines

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/init/do_mounts.c linux-2.6.14-rc4-bjd3c/init/do_mounts.c

init/do_mounts.c +1 -0
@@ -8,6 +8,7 @@
 #include <linux/security.h>
 #include <linux/delay.h>
 #include <linux/mount.h>
+#include <linux/kernel_init.h>

Unecessary, prepare_namespace() defined here.

not a header file

Quoted 71 lines

init/initramfs.c line 9

Quoted 10 lines
init/do_mounts.c +0 -0
 #include <linux/nfs_fs.h>
 #include <linux/nfs_fs_sb.h>

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/init/initramfs.c linux-2.6.14-rc4-bjd3c/init/initramfs.c

init/initramfs.c +1 -0
@@ -6,6 +6,7 @@
 #include <linux/delay.h>
 #include <linux/string.h>
 #include <linux/syscalls.h>
+#include <linux/kernel_init.h>

Ditto populate_rootfs().

Quoted 14 lines
init/initramfs.c +0 -0
 static __initdata char *message;
 static void __init error(char *x)

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/init/main.c linux-2.6.14-rc4-bjd3c/init/main.c

init/main.c +1 -0
@@ -17,6 +17,7 @@
 #include <linux/proc_fs.h>
 #include <linux/devfs_fs_kernel.h>
 #include <linux/kernel.h>
+#include <linux/kernel_init.h>
 #include <linux/syscalls.h>
 #include <linux/string.h>
 #include <linux/ctype.h>

init/main.c line 55

Quoted 8 lines
init/main.c +3 -0
@@ -47,8 +48,11 @@
 #include <linux/rmap.h>
 #include <linux/mempolicy.h>
 #include <linux/key.h>
+#include <linux/sysctl.h>
 #include <net/sock.h>
 
+#include <linux/radix-tree.h>
+

No need for the extra whitespace, could have as well gone right below <linux/sysctl.h>

Quoted 32 lines
init/main.c +0 -23
 #include <asm/io.h>
 #include <asm/bugs.h>
 #include <asm/setup.h>
@@ -80,30 +84,7 @@
 
 static int init(void *);
 
-extern void init_IRQ(void);
-extern void fork_init(unsigned long);
-extern void mca_init(void);
-extern void sbus_init(void);
-extern void sysctl_init(void);
-extern void signals_init(void);
-extern void buffer_init(void);
-extern void pidhash_init(void);
-extern void pidmap_init(void);
-extern void prio_tree_init(void);
-extern void radix_tree_init(void);
-extern void free_initmem(void);
-extern void populate_rootfs(void);
-extern void driver_init(void);
-extern void prepare_namespace(void);
-#ifdef	CONFIG_ACPI
-extern void acpi_early_init(void);
-#else
-static inline void acpi_early_init(void) { }
-#endif
 
-#ifdef CONFIG_TC
-extern void tc_init(void);
-#endif
 
Quoted 12 lines

kernel/fork.c line 45

Quoted 10 lines
init/main.c +0 -0
 enum system_states system_state;
 EXPORT_SYMBOL(system_state);

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/kernel/fork.c linux-2.6.14-rc4-bjd3c/kernel/fork.c

kernel/fork.c +1 -0
@@ -42,6 +42,7 @@
 #include <linux/profile.h>
 #include <linux/rmap.h>
 #include <linux/acct.h>
+#include <linux/kernel_init.h>

Unecessary, fork_init() defined here.

not a header file!

Quoted 13 lines

kernel/pid.c line 29

Quoted 10 lines
kernel/fork.c +0 -0
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/kernel/pid.c linux-2.6.14-rc4-bjd3c/kernel/pid.c

kernel/pid.c +1 -0
@@ -26,6 +26,7 @@
 #include <linux/init.h>
 #include <linux/bootmem.h>
 #include <linux/hash.h>
+#include <linux/kernel_init.h>

Ditto pid(map|hash)_init().

Quoted 12 lines

kernel/signal.c line 28

Quoted 10 lines
kernel/pid.c +0 -0
 #define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift)
 static struct hlist_head *pid_hash[PIDTYPE_MAX];

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/kernel/signal.c linux-2.6.14-rc4-bjd3c/kernel/signal.c

kernel/signal.c +1 -0
@@ -25,6 +25,7 @@
 #include <linux/posix-timers.h>
 #include <linux/signal.h>
 #include <linux/audit.h>
+#include <linux/kernel_init.h>

Ditto signals_init().

hmm,

Quoted 5 lines
Quoted 5 lines
kernel/signal.c +0 -0
 #include <asm/param.h>
 #include <asm/uaccess.h>
 #include <asm/unistd.h>

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/lib/prio_tree.c linux-2.6.14-rc4-bjd3c/lib/prio_tree.c
--- linux-2.6.14-rc4-bjd3b/lib/prio_tree.c 2005-06-17 20:48:29.000000000 +0100

Quoted 8 lines

kernel/signal.c line 17

Quoted 6 lines

+++ linux-2.6.14-rc4-bjd3c/lib/prio_tree.c 2005-10-14 01:27:04.000000000 +0100

kernel/signal.c +1 -0
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/prio_tree.h>
+#include <linux/kernel_init.h>

Ditto prio_tree_init().

aha

Quoted 4 lines
Quoted 4 lines
kernel/signal.c +0 -0
 /*
  * A clever mix of heap and radix trees forms a radix priority search tree (PST)

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/lib/radix-tree.c linux-2.6.14-rc4-bjd3c/lib/radix-tree.c
--- linux-2.6.14-rc4-bjd3b/lib/radix-tree.c 2005-10-11 10:56:34.000000000 +0100

Quoted 8 lines

kernel/signal.c line 24

Quoted 6 lines

+++ linux-2.6.14-rc4-bjd3c/lib/radix-tree.c 2005-10-14 01:27:21.000000000 +0100

kernel/signal.c +1 -0
@@ -21,6 +21,7 @@
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/kernel_init.h>

Ditto radix_tree_init(), and already prototyped in include/linux/radix-tree.h:

ok, missed that one

Signature · 3 lines
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
author
#4 lore raw
In reply to Arthur Othieno
Quoted 19 lines · Arthur Othieno
Quoted 4 lines · Ben Dooks

init/main.c calls a number of functions externally but declaring them locally. This patch creates a new header (linux/kernel_init.h) and moves all the declarations into it.

These functions are only referenced in init/main.c, and rightfully so. In the end, this doesn't change anything much, other than maintainance overhead for the new include/linux/kernel_init.h

But, comments within..

Quoted 2 lines

Also removes any old init functions now done by an initcall()

(mca|sbus|tc)_init() removal look good.

Quoted 1 line
Quoted 8 lines

drivers/acpi/bus.c line 33

Quoted 8 lines

diff -urpN -X ../dontdiff linux-2.6.14-rc4-bjd3b/drivers/acpi/bus.c linux-2.6.14-rc4-bjd3c/drivers/acpi/bus.c

drivers/acpi/bus.c +1 -0
@@ -30,6 +30,7 @@
 #include <linux/pm.h>
 #include <linux/device.h>
 #include <linux/proc_fs.h>
+#include <linux/kernel_init.h>

I've attached a pair of patches, the first removes the unused functions, and the second moves the init function declarations into include/linux/init.h (and adds the init to include/linux/prio_tree.h)

Signature · 3 lines
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
init/main.c +0 -6
diff -urp -X linux-2.6.14-rc4-git7-bjd1/Documentation/dontdiff linux-2.6.14-rc4-git7/init/main.c linux-2.6.14-rc4-git7-bjd1/init/main.c
@@ -82,8 +82,6 @@ static int init(void *);
 
 extern void init_IRQ(void);
 extern void fork_init(unsigned long);
-extern void mca_init(void);
-extern void sbus_init(void);
 extern void sysctl_init(void);
 extern void signals_init(void);
 extern void buffer_init(void);
@@ -101,10 +99,6 @@ extern void acpi_early_init(void);
 static inline void acpi_early_init(void) { }
 #endif
 
-#ifdef CONFIG_TC
-extern void tc_init(void);
-#endif
-
 enum system_states system_state;
 EXPORT_SYMBOL(system_state);
 
include/linux/init.h +19 -0
diff -urp -X linux-2.6.14-rc4-git7-bjd1/Documentation/dontdiff linux-2.6.14-rc4-git7-bjd1/include/linux/init.h linux-2.6.14-rc4-git7-bjd2/include/linux/init.h
@@ -143,6 +143,25 @@ struct obs_kernel_param {
 
 /* Relies on saved_command_line being set */
 void __init parse_early_param(void);
+
+/* items used by init/main.c */
+
+extern void __init init_IRQ(void);
+extern void __init fork_init(unsigned long);
+extern void __init sysctl_init(void);
+extern void __init signals_init(void);
+extern void __init buffer_init(void);
+extern void __init pidhash_init(void);
+extern void __init pidmap_init(void);
+extern void __init free_initmem(void);
+extern void __init populate_rootfs(void);
+extern void __init driver_init(void);
+extern void __init prepare_namespace(void);
+
+#ifdef CONFIG_ACPI
+extern void __init acpi_early_init(void);
+#endif
+
 #endif /* __ASSEMBLY__ */
 
 /**
include/linux/prio_tree.h +2 -0
diff -urp -X linux-2.6.14-rc4-git7-bjd1/Documentation/dontdiff linux-2.6.14-rc4-git7-bjd1/include/linux/prio_tree.h linux-2.6.14-rc4-git7-bjd2/include/linux/prio_tree.h
@@ -117,4 +117,6 @@ struct prio_tree_node *prio_tree_next(st
 #define raw_prio_tree_remove(root, node) \
 	prio_tree_remove(root, (struct prio_tree_node *) (node))
 
+extern void __init prio_tree_init(void);
+
 #endif /* _LINUX_PRIO_TREE_H */
init/main.c +3 -16
diff -urp -X linux-2.6.14-rc4-git7-bjd1/Documentation/dontdiff linux-2.6.14-rc4-git7-bjd1/init/main.c linux-2.6.14-rc4-git7-bjd2/init/main.c
@@ -47,6 +47,8 @@
 #include <linux/rmap.h>
 #include <linux/mempolicy.h>
 #include <linux/key.h>
+#include <linux/prio_tree.h>
+#include <linux/radix-tree.h>
 #include <net/sock.h>
 
 #include <asm/io.h>
@@ -80,22 +82,7 @@
 
 static int init(void *);
 
-extern void init_IRQ(void);
-extern void fork_init(unsigned long);
-extern void sysctl_init(void);
-extern void signals_init(void);
-extern void buffer_init(void);
-extern void pidhash_init(void);
-extern void pidmap_init(void);
-extern void prio_tree_init(void);
-extern void radix_tree_init(void);
-extern void free_initmem(void);
-extern void populate_rootfs(void);
-extern void driver_init(void);
-extern void prepare_namespace(void);
-#ifdef	CONFIG_ACPI
-extern void acpi_early_init(void);
-#else
+#ifndef	CONFIG_ACPI
 static inline void acpi_early_init(void) { }
 #endif