[PATCH] 2.3.13-pre8 init tweaks

Jakub Jelinek (jj@sunsite.ms.mff.cuni.cz)
Mon, 9 Aug 1999 15:57:18 +0200


Hi!

This patch makes __exit and __exitdata attributes work (so that those
functions/data are discarded if not module).
Also, it IMHO simplifies the __initcall stuff.
__initcall is now an attribute like __init is, meaning put this function
into init sections and record it in the table for do_initcalls().
For code which will always be compiled into the kernel, initialization then
looks like this:

static int __initcall bdflush_init(void)
{
kernel_thread(bdflush, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
return 0;
}

and that's it.
For tristate code where you want to put the function into init section and
record it for do_initcalls if it is not a module and want to have it as
initialization function for module, you just do

static int __initcall init_module (void)
{
...
}

static void __exit cleanup_module (void)
{
...
}

The static is important, otherwise the non-module could not be linked in.
IMHO it is better to write the attributes like this in the function
definitions than to set them later on using some module_init/exit macros.
FYI modutils don't care about binding of symbols, so even a static
init_module is init_module for them.

--- linux/arch/alpha/vmlinux.lds~ Fri Aug 6 09:27:53 1999
+++ linux/arch/alpha/vmlinux.lds Mon Aug 9 15:25:14 1999
@@ -3,6 +3,7 @@ ENTRY(__start)
SECTIONS
{
. = 0xfffffc0000310000;
+ /DISCARD/ : { *(.text.exit) *(.data.exit) }
_text = .;
.text : { *(.text) }
.text2 : { *(.text2) }
@@ -34,7 +35,7 @@ SECTIONS

. = ALIGN(8);
__initcall_start = .;
- .initcall.init : { *(.initcall.init) }
+ .initcall.init : { *(.ctors) }
__initcall_end = .;

. = ALIGN(2*8192); /* Align double page for init_task_union */
@@ -47,7 +48,7 @@ SECTIONS
_data = .;
.data.cacheline_aligned : { *(.data.cacheline_aligned) }
.rodata : { *(.rodata) }
- .data : { *(.data) CONSTRUCTORS }
+ .data : { *(.data) }
.got : { *(.got) }
.sdata : { *(.sdata) }
_edata = .;
--- linux/arch/i386/kernel/apm.c~ Mon Aug 9 14:25:46 1999
+++ linux/arch/i386/kernel/apm.c Mon Aug 9 14:03:44 1999
@@ -1436,7 +1436,7 @@ __setup("apm=", apm_setup);
* In short, if something bad happens, at least we have a choice
* of just killing the apm thread..
*/
-static int __init apm_init(void)
+static int __initcall init_module(void)
{
static struct proc_dir_entry *ent;

@@ -1541,5 +1541,3 @@ static int __init apm_init(void)

kernel_thread(apm, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND | SIGCHLD);
}
-
-module_init(apm_init)
--- linux/arch/i386/kernel/process.c~ Mon Aug 9 14:03:45 1999
+++ linux/arch/i386/kernel/process.c Mon Aug 9 14:26:39 1999
@@ -84,7 +84,7 @@ void (*idle)(void) = default_idle;

#include <linux/pci.h>

-static int __init piix4_idle_init(void)
+static int __initcall piix4_idle_init(void)
{
/* This is the PIIX4 ACPI device */
struct pci_dev *dev = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, NULL);
@@ -106,8 +106,6 @@ static int __init piix4_idle_init(void)
}
return 0;
}
-
-__initcall(piix4_idle_init);

#endif

--- linux/arch/i386/vmlinux.lds.S~ Wed Aug 4 13:41:30 1999
+++ linux/arch/i386/vmlinux.lds.S Mon Aug 9 15:22:22 1999
@@ -7,6 +7,7 @@ ENTRY(_start)
SECTIONS
{
. = PAGE_OFFSET_RAW + 0x100000;
+ /DISCARD/ : { *(.text.exit) *(.data.exit) }
_text = .; /* Text and read-only data */
.text : {
*(.text)
@@ -28,10 +29,7 @@ SECTIONS

_etext = .; /* End of text section */

- .data : { /* Data */
- *(.data)
- CONSTRUCTORS
- }
+ .data : { *(.data) } /* Data */

_edata = .; /* End of data section */

@@ -46,8 +44,9 @@ SECTIONS
__setup_start = .;
.setup.init : { *(.setup.init) }
__setup_end = .;
+ . = ALIGN(4);
__initcall_start = .;
- .initcall.init : { *(.initcall.init) }
+ .initcall.init : { *(.ctors) }
__initcall_end = .;
. = ALIGN(4096);
__init_end = .;
--- linux/arch/i386/vmlinux.lds~ Wed Aug 4 13:41:28 1999
+++ linux/arch/i386/vmlinux.lds Mon Aug 9 15:22:31 1999
@@ -7,6 +7,7 @@ ENTRY(_start)
SECTIONS
{
. = 0xC0000000 + 0x100000;
+ /DISCARD/ : { *(.text.exit) *(.data.exit) }
_text = .; /* Text and read-only data */
.text : {
*(.text)
@@ -28,10 +29,7 @@ SECTIONS

_etext = .; /* End of text section */

- .data : { /* Data */
- *(.data)
- CONSTRUCTORS
- }
+ .data : { *(.data) } /* Data */

_edata = .; /* End of data section */

@@ -46,8 +44,9 @@ SECTIONS
__setup_start = .;
.setup.init : { *(.setup.init) }
__setup_end = .;
+ . = ALIGN(4);
__initcall_start = .;
- .initcall.init : { *(.initcall.init) }
+ .initcall.init : { *(.ctors) }
__initcall_end = .;
. = ALIGN(4096);
__init_end = .;
--- linux/arch/ppc/vmlinux.lds~ Fri Aug 6 09:28:20 1999
+++ linux/arch/ppc/vmlinux.lds Mon Aug 9 15:25:02 1999
@@ -6,6 +6,7 @@ SECTIONS
{
/* Read-only sections, merged into text segment: */
. = + SIZEOF_HEADERS;
+ /DISCARD/ : { *(.text.exit) *(.data.exit) }
.interp : { *(.interp) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
@@ -54,7 +55,6 @@ SECTIONS
*(.sdata2)
*(.got.plt) *(.got)
*(.dynamic)
- CONSTRUCTORS
}
_edata = .;
PROVIDE (edata = .);
@@ -75,8 +75,9 @@ SECTIONS
__setup_start = .;
.setup.init : { *(.setup.init) }
__setup_end = .;
+ . = ALIGN(8);
__initcall_start = .;
- .initcall.init : { *(.initcall.init) }
+ .initcall.init : { *(.ctors) }
__initcall_end = .;
. = ALIGN(4096);
__init_end = .;
--- linux/arch/sparc/mm/asyncd.c~ Wed Aug 4 13:41:58 1999
+++ linux/arch/sparc/mm/asyncd.c Mon Aug 9 13:39:59 1999
@@ -273,12 +273,10 @@ int asyncd(void *unused)

#if CONFIG_AP1000

-static int __init init_ap1000(void)
+static int __initcall init_ap1000(void)
{
kernel_thread(asyncd, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
return 0;
}
-
-module_init(init_ap1000)

#endif
--- linux/arch/sparc64/kernel/binfmt_aout32.c~ Fri Jul 30 13:32:53 1999
+++ linux/arch/sparc64/kernel/binfmt_aout32.c Mon Aug 9 15:27:04 1999
@@ -39,7 +39,7 @@ static int aout32_core_dump(long signr,
extern void dump_thread(struct pt_regs *, struct user *);

static struct linux_binfmt aout32_format = {
- NULL, NULL, load_aout32_binary, load_aout32_library, aout32_core_dump,
+ NULL, THIS_MODULE, load_aout32_binary, load_aout32_library, aout32_core_dump,
PAGE_SIZE
};

@@ -453,7 +453,12 @@ load_aout32_library(int fd)
}


-__initfunc(int init_aout32_binfmt(void))
+static int __initcall init_module(void)
{
return register_binfmt(&aout32_format);
+}
+
+static void __exit cleanup_module(void)
+{
+ unregister_binfmt(&aout_format);
}
--- linux/arch/sparc64/vmlinux.lds~ Fri Aug 6 10:18:30 1999
+++ linux/arch/sparc64/vmlinux.lds Mon Aug 9 15:22:11 1999
@@ -8,6 +8,7 @@ SECTIONS
empty_zero_page = 0x0000000000400000;
swapper_pmd_dir = 0x0000000000402000;
empty_pg_dir = 0x0000000000403000;
+ /DISCARD/ : { *(.text.exit) *(.data.exit) }
. = 0x4000;
.text 0x0000000000404000 :
{
@@ -18,11 +19,7 @@ SECTIONS
PROVIDE (etext = .);
.rodata : { *(.rodata) }
.rodata1 : { *(.rodata1) }
- .data :
- {
- *(.data)
- CONSTRUCTORS
- }
+ .data : { *(.data) }
.data1 : { *(.data1) }
_edata = .;
PROVIDE (edata = .);
@@ -43,8 +40,9 @@ SECTIONS
__setup_start = .;
.setup_init : { *(.setup.init) }
__setup_end = .;
+ . = ALIGN(8);
__initcall_start = .;
- .initcall.init : { *(.initcall.init) }
+ .initcall.init : { *(.ctors) }
__initcall_end = .;
. = ALIGN(8192);
__init_end = .;
--- linux/drivers/block/genhd.c~ Mon Aug 9 14:05:00 1999
+++ linux/drivers/block/genhd.c Mon Aug 9 14:27:28 1999
@@ -1387,7 +1387,7 @@ static inline void setup_dev(struct gend
resetup_one_dev(dev, drive);
}

-static int __init device_setup(void)
+static int __initcall device_setup(void)
{
extern void console_map_init(void);
extern void cpqarray_init(void);
@@ -1447,8 +1447,6 @@ static int __init device_setup(void)
#endif
return 0;
}
-
-__initcall(device_setup);

#ifdef CONFIG_PROC_FS
int get_partition_list(char * page)
--- linux/drivers/char/msbusmouse.c~ Wed Aug 4 13:42:30 1999
+++ linux/drivers/char/msbusmouse.c Mon Aug 9 13:41:38 1999
@@ -117,7 +117,7 @@ static struct busmouse msbusmouse = {
MICROSOFT_BUSMOUSE, "msbusmouse", open_mouse, release_mouse, 0
};

-__initfunc(int ms_bus_mouse_init(void))
+static int __initcall init_module(void)
{
int present = 0;
int mse_byte, i;
@@ -151,11 +151,8 @@ __initfunc(int ms_bus_mouse_init(void))
return msedev < 0 ? msedev : 0;
}

-void ms_bus_mouse_exit(void)
+static void __exit cleanup_module(void)
{
unregister_busmouse(msedev);
release_region(MS_MSE_CONTROL_PORT, 0x04);
}
-
-module_init(ms_bus_mouse_init)
-module_exit(ms_bus_mouse_exit)
--- linux/drivers/net/hamradio/soundmodem/sm.c~ Fri Aug 6 09:29:46 1999
+++ linux/drivers/net/hamradio/soundmodem/sm.c Mon Aug 9 14:34:36 1999
@@ -611,10 +611,7 @@ static int midiio[NR_PORTS] = { [0 ... N

/* --------------------------------------------------------------------- */

-#ifndef MODULE
-static
-#endif
-int __init init_module(void)
+static int __initcall init_module(void)
{
int i, j, found = 0;
char set_hw = 1;
@@ -671,8 +668,6 @@ int __init init_module(void)

/* --------------------------------------------------------------------- */

-#ifdef MODULE
-
MODULE_PARM(mode, "1-" __MODULE_STRING(NR_PORTS) "s");
MODULE_PARM_DESC(mode, "soundmodem operating mode; eg. sbc:afsk1200 or wss:fsk9600");
MODULE_PARM(iobase, "1-" __MODULE_STRING(NR_PORTS) "i");
@@ -693,7 +688,7 @@ MODULE_PARM_DESC(midiio, "soundmodem PTT
MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu");
MODULE_DESCRIPTION("Soundcard amateur radio modem driver");

-void cleanup_module(void)
+static void __exit cleanup_module(void)
{
int i;

@@ -713,7 +708,7 @@ void cleanup_module(void)
}
}

-#else /* MODULE */
+#ifndef MODULE

/*
* format: soundmodem=io,irq,dma[,dma2[,serio[,pario]]],mode
@@ -750,7 +745,6 @@ static int __init sm_setup(char *str)
}

__setup("soundmodem=", sm_setup);
-__initcall(init_module);

#endif /* MODULE */
/* --------------------------------------------------------------------- */
--- linux/drivers/net/hamradio/baycom_epp.c~ Fri Aug 6 09:29:43 1999
+++ linux/drivers/net/hamradio/baycom_epp.c Mon Aug 9 14:29:27 1999
@@ -1420,10 +1420,7 @@ static int iobase[NR_PORTS] = { 0x378, }

/* --------------------------------------------------------------------- */

-#ifndef MODULE
-static
-#endif
-int __init init_module(void)
+static int __initcall init_module(void)
{
struct device *dev;
int i, found = 0;
@@ -1478,8 +1475,6 @@ int __init init_module(void)

/* --------------------------------------------------------------------- */

-#ifdef MODULE
-
MODULE_PARM(mode, "1-" __MODULE_STRING(NR_PORTS) "s");
MODULE_PARM_DESC(mode, "baycom operating mode");
MODULE_PARM(iobase, "1-" __MODULE_STRING(NR_PORTS) "i");
@@ -1488,7 +1483,7 @@ MODULE_PARM_DESC(iobase, "baycom io base
MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu");
MODULE_DESCRIPTION("Baycom epp amateur radio modem driver");

-void cleanup_module(void)
+static void __exit cleanup_module(void)
{
struct device *dev;
struct baycom_state *bc;
@@ -1507,7 +1502,7 @@ void cleanup_module(void)
}
}

-#else /* MODULE */
+#ifndef MODULE

/*
* format: baycom_epp=io,mode
@@ -1531,7 +1526,6 @@ static int __init baycom_epp_setup(char
}

__setup("baycom_epp=", baycom_epp_setup);
-__initcall(init_module);

#endif /* MODULE */
/* --------------------------------------------------------------------- */
--- linux/drivers/net/hamradio/baycom_par.c~ Mon Aug 9 14:06:37 1999
+++ linux/drivers/net/hamradio/baycom_par.c Mon Aug 9 14:31:47 1999
@@ -491,10 +491,7 @@ static int iobase[NR_PORTS] = { 0x378, }

/* --------------------------------------------------------------------- */

-#ifndef MODULE
-static
-#endif
-int __init init_module(void)
+static int __initcall init_module(void)
{
int i, j, found = 0;
char set_hw = 1;
@@ -532,8 +529,6 @@ int __init init_module(void)

/* --------------------------------------------------------------------- */

-#ifdef MODULE
-
MODULE_PARM(mode, "1-" __MODULE_STRING(NR_PORTS) "s");
MODULE_PARM_DESC(mode, "baycom operating mode; eg. par96 or picpar");
MODULE_PARM(iobase, "1-" __MODULE_STRING(NR_PORTS) "i");
@@ -542,7 +537,7 @@ MODULE_PARM_DESC(iobase, "baycom io base
MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu");
MODULE_DESCRIPTION("Baycom par96 and picpar amateur radio modem driver");

-void cleanup_module(void)
+static void __exit cleanup_module(void)
{
int i;

@@ -560,7 +555,7 @@ void cleanup_module(void)
}
}

-#else /* MODULE */
+#ifndef MODULE

/*
* format: baycom_par=io,mode
@@ -584,7 +579,6 @@ static int __init baycom_par_setup(char
}

__setup("baycom_par=", baycom_par_setup);
-__initcall(init_module);

#endif /* MODULE */
/* --------------------------------------------------------------------- */
--- linux/drivers/net/hamradio/baycom_ser_fdx.c~ Mon Aug 9 14:06:39 1999
+++ linux/drivers/net/hamradio/baycom_ser_fdx.c Mon Aug 9 14:31:34 1999
@@ -600,10 +600,7 @@ static int baud[NR_PORTS] = { [0 ... NR_

/* --------------------------------------------------------------------- */

-#ifndef MODULE
-static
-#endif
-int __init init_module(void)
+static int __initcall init_module(void)
{
int i, j, found = 0;
char set_hw = 1;
@@ -643,8 +640,6 @@ int __init init_module(void)

/* --------------------------------------------------------------------- */

-#ifdef MODULE
-
MODULE_PARM(mode, "1-" __MODULE_STRING(NR_PORTS) "s");
MODULE_PARM_DESC(mode, "baycom operating mode; * for software DCD");
MODULE_PARM(iobase, "1-" __MODULE_STRING(NR_PORTS) "i");
@@ -657,7 +652,7 @@ MODULE_PARM_DESC(baud, "baycom baud rate
MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu");
MODULE_DESCRIPTION("Baycom ser12 full duplex amateur radio modem driver");

-void cleanup_module(void)
+static void __exit cleanup_module(void)
{
int i;

@@ -675,7 +670,7 @@ void cleanup_module(void)
}
}

-#else /* MODULE */
+#ifndef MODULE

/*
* format: baycom_ser_fdx=io,irq,mode
@@ -703,7 +698,6 @@ static int __init baycom_ser_fdx_setup(c
}

__setup("baycom_ser_fdx=", baycom_ser_fdx_setup);
-__initcall(init_module);

#endif /* MODULE */
/* --------------------------------------------------------------------- */
--- linux/drivers/net/hamradio/baycom_ser_hdx.c~ Mon Aug 9 14:06:39 1999
+++ linux/drivers/net/hamradio/baycom_ser_hdx.c Mon Aug 9 14:32:29 1999
@@ -637,10 +637,7 @@ static int irq[NR_PORTS] = { 4, };

/* --------------------------------------------------------------------- */

-#ifndef MODULE
-static
-#endif
-int __init init_module(void)
+static int __initcall init_module(void)
{
int i, j, found = 0;
char set_hw = 1;
@@ -679,8 +676,6 @@ int __init init_module(void)

/* --------------------------------------------------------------------- */

-#ifdef MODULE
-
MODULE_PARM(mode, "1-" __MODULE_STRING(NR_PORTS) "s");
MODULE_PARM_DESC(mode, "baycom operating mode; * for software DCD");
MODULE_PARM(iobase, "1-" __MODULE_STRING(NR_PORTS) "i");
@@ -691,7 +686,7 @@ MODULE_PARM_DESC(irq, "baycom irq number
MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu");
MODULE_DESCRIPTION("Baycom ser12 half duplex amateur radio modem driver");

-void cleanup_module(void)
+static void __exit cleanup_module(void)
{
int i;

@@ -709,7 +704,7 @@ void cleanup_module(void)
}
}

-#else /* MODULE */
+#ifndef MODULE

/*
* format: baycom_ser_hdx=io,irq,mode
@@ -735,7 +730,6 @@ static int __init baycom_ser_hdx_setup(c
}

__setup("baycom_ser_hdx=", baycom_ser_hdx_setup);
-__initcall(init_module);

#endif /* MODULE */
/* --------------------------------------------------------------------- */
--- linux/drivers/pci/proc.c~ Mon Aug 9 14:06:47 1999
+++ linux/drivers/pci/proc.c Mon Aug 9 14:36:32 1999
@@ -586,7 +586,7 @@ static struct proc_dir_entry proc_old_pc
0, &proc_array_inode_operations
};

-static int __init pci_proc_init(void)
+static int __initcall pci_proc_init(void)
{
if (pci_present()) {
proc_bus_pci_dir = create_proc_entry("pci", S_IFDIR, proc_bus);
@@ -596,5 +596,3 @@ static int __init pci_proc_init(void)
}
return 0;
}
-
-__initcall(pci_proc_init);
--- linux/drivers/sound/es1370.c~ Mon Aug 9 14:07:21 1999
+++ linux/drivers/sound/es1370.c Mon Aug 9 14:37:28 1999
@@ -2318,10 +2318,7 @@ static struct initvol {
{ SOUND_MIXER_WRITE_OGAIN, 0x4040 }
};

-#ifndef MODULE
-static
-#endif
-int __init init_module(void)
+static int __initcall init_module(void)
{
struct es1370_state *s;
struct pci_dev *pcidev = NULL;
@@ -2440,8 +2437,6 @@ int __init init_module(void)

/* --------------------------------------------------------------------- */

-#ifdef MODULE
-
MODULE_PARM(joystick, "1-" __MODULE_STRING(NR_DEVICE) "i");
MODULE_PARM_DESC(joystick, "if 1 enables joystick interface (still need separate driver)");
MODULE_PARM(lineout, "1-" __MODULE_STRING(NR_DEVICE) "i");
@@ -2452,7 +2447,7 @@ MODULE_PARM_DESC(micbias, "sets the +5V
MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu");
MODULE_DESCRIPTION("ES1370 AudioPCI Driver");

-void cleanup_module(void)
+static void __exit cleanup_module(void)
{
struct es1370_state *s;

@@ -2472,7 +2467,7 @@ void cleanup_module(void)
printk(KERN_INFO "es1370: unloading\n");
}

-#else /* MODULE */
+#ifndef MODULE

/* format is: es1370=[joystick[,lineout[,micbias]]] */

@@ -2493,6 +2488,5 @@ static int __init es1370_setup(char *str
}

__setup("es1370=", es1370_setup);
-__initcall(init_module);

#endif /* MODULE */
--- linux/drivers/sound/es1371.c~ Mon Aug 9 14:07:21 1999
+++ linux/drivers/sound/es1371.c Mon Aug 9 14:38:34 1999
@@ -2719,10 +2719,7 @@ static struct initvol {
{ SOUND_MIXER_WRITE_IGAIN, 0x4040 }
};

-#ifndef MODULE
-static
-#endif
-int __init init_module(void)
+static int __initcall init_module(void)
{
struct es1371_state *s;
struct pci_dev *pcidev = NULL;
@@ -2885,15 +2882,13 @@ int __init init_module(void)

/* --------------------------------------------------------------------- */

-#ifdef MODULE
-
MODULE_PARM(joystick, "1-" __MODULE_STRING(NR_DEVICE) "i");
MODULE_PARM_DESC(joystick, "sets address and enables joystick interface (still need separate driver)");

MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu");
MODULE_DESCRIPTION("ES1371 AudioPCI97 Driver");

-void cleanup_module(void)
+static void __exit cleanup_module(void)
{
struct es1371_state *s;

@@ -2913,7 +2908,7 @@ void cleanup_module(void)
printk(KERN_INFO "es1371: unloading\n");
}

-#else /* MODULE */
+#ifndef MODULE

/* format is: es1371=[joystick] */

@@ -2930,6 +2925,5 @@ static int __init es1371_setup(char *str
}

__setup("es1371=", es1371_setup);
-__initcall(init_module);

#endif /* MODULE */
--- linux/drivers/sound/sonicvibes.c~ Mon Aug 9 14:07:24 1999
+++ linux/drivers/sound/sonicvibes.c Mon Aug 9 14:39:30 1999
@@ -2314,10 +2314,7 @@ static struct initvol {
{ SOUND_MIXER_WRITE_PCM, 0x4040 }
};

-#ifndef MODULE
-static
-#endif
-int __init init_module(void)
+static int __initcall init_module(void)
{
struct sv_state *s;
struct pci_dev *pcidev = NULL;
@@ -2501,8 +2498,6 @@ int __init init_module(void)

/* --------------------------------------------------------------------- */

-#ifdef MODULE
-
MODULE_PARM(reverb, "1-" __MODULE_STRING(NR_DEVICE) "i");
MODULE_PARM_DESC(reverb, "if 1 enables the reverb circuitry. NOTE: your card must have the reverb RAM");
#if 0
@@ -2516,7 +2511,7 @@ MODULE_PARM_DESC(dmaio, "if the motherbo
MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu");
MODULE_DESCRIPTION("S3 SonicVibes Driver");

-void cleanup_module(void)
+static void __exit cleanup_module(void)
{
struct sv_state *s;

@@ -2545,7 +2540,7 @@ void cleanup_module(void)
printk(KERN_INFO "sv: unloading\n");
}

-#else /* MODULE */
+#ifndef MODULE

/* format is: sonicvibes=[reverb] sonicvibesdmaio=dmaioaddr */

@@ -2578,6 +2573,5 @@ static int __init sonicvibesdmaio_setup(

__setup("sonicvibes=", sonicvibes_setup);
__setup("sonicvibesdmaio=", sonicvibesdmaio_setup);
-__initcall(init_module);

#endif /* MODULE */
--- linux/drivers/parport/init.c~ Fri Aug 6 09:29:49 1999
+++ linux/drivers/parport/init.c Mon Aug 9 14:35:48 1999
@@ -128,7 +128,7 @@ void cleanup_module(void)

#else

-int __init parport_init (void)
+int __initcall parport_init (void)
{
if (io[0] == PARPORT_DISABLE)
return 1;
@@ -154,8 +154,6 @@ int __init parport_init (void)
#endif
return 0;
}
-
-__initcall (parport_init);

#endif

--- linux/fs/buffer.c~ Fri Aug 6 09:30:52 1999
+++ linux/fs/buffer.c Mon Aug 9 13:49:05 1999
@@ -2314,11 +2314,8 @@ int bdflush(void * unused)
}
}

-static int __init bdflush_init(void)
+static int __initcall bdflush_init(void)
{
kernel_thread(bdflush, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
return 0;
}
-
-module_init(bdflush_init)
-
--- linux/fs/binfmt_aout.c~ Wed Aug 4 13:43:29 1999
+++ linux/fs/binfmt_aout.c Mon Aug 9 13:45:39 1999
@@ -553,15 +553,12 @@ load_aout_library(int fd)
}


-static int __init init_aout_binfmt(void)
+static int __initcall init_module(void)
{
return register_binfmt(&aout_format);
}

-static void __exit exit_aout_binfmt(void)
+static void __exit cleanup_module(void)
{
unregister_binfmt(&aout_format);
}
-
-module_init(init_aout_binfmt)
-module_exit(exit_aout_binfmt)
--- linux/fs/binfmt_elf.c~ Wed Aug 4 13:43:32 1999
+++ linux/fs/binfmt_elf.c Mon Aug 9 13:46:09 1999
@@ -1290,16 +1290,13 @@ static int elf_core_dump(long signr, str
}
#endif /* USE_ELF_CORE_DUMP */

-static int __init init_elf_binfmt(void)
+static int __initcall init_module(void)
{
return register_binfmt(&elf_format);
}

-static void __exit exit_elf_binfmt(void)
+static void __exit cleanup_module(void)
{
/* Remove the COFF and ELF loaders. */
unregister_binfmt(&elf_format);
}
-
-module_init(init_elf_binfmt)
-module_exit(exit_elf_binfmt)
--- linux/fs/binfmt_em86.c~ Wed Aug 4 13:43:34 1999
+++ linux/fs/binfmt_em86.c Mon Aug 9 13:46:55 1999
@@ -108,15 +108,12 @@ struct linux_binfmt em86_format = {
NULL, THIS_MODULE, load_em86, NULL, NULL, 0
};

-static int __init init_em86_binfmt(void)
+static int __initcall init_module(void)
{
return register_binfmt(&em86_format);
}

-static void __exit exit_em86_binfmt(void)
+static void __exit cleanup_module(void)
{
unregister_binfmt(&em86_format);
}
-
-module_init(init_em86_binfmt)
-module_exit(exit_em86_binfmt)
--- linux/fs/binfmt_misc.c~ Wed Aug 4 13:43:34 1999
+++ linux/fs/binfmt_misc.c Mon Aug 9 13:47:36 1999
@@ -489,7 +489,7 @@ static void bm_modcount(struct inode *in
}
#endif

-static int __init init_misc_binfmt(void)
+static int __initcall init_module(void)
{
int error = -ENOENT;
struct proc_dir_entry *status = NULL, *reg;
@@ -524,7 +524,7 @@ cleanup_bm:
goto out;
}

-static void __exit exit_misc_binfmt(void)
+static void __exit cleanup_module(void)
{
unregister_binfmt(&misc_format);
remove_proc_entry("register", bm_dir);
@@ -534,6 +534,3 @@ static void __exit exit_misc_binfmt(void
}

EXPORT_NO_SYMBOLS;
-
-module_init(init_misc_binfmt)
-module_exit(exit_misc_binfmt)
--- linux/fs/binfmt_script.c~ Wed Aug 4 13:43:35 1999
+++ linux/fs/binfmt_script.c Mon Aug 9 13:48:06 1999
@@ -104,15 +104,12 @@ struct linux_binfmt script_format = {
NULL, THIS_MODULE, load_script, NULL, NULL, 0
};

-static int __init init_script_binfmt(void)
+static int __initcall init_module(void)
{
return register_binfmt(&script_format);
}

-static void __exit exit_script_binfmt(void)
+static void __exit cleanup_module(void)
{
unregister_binfmt(&script_format);
}
-
-module_init(init_script_binfmt)
-module_exit(exit_script_binfmt)
--- linux/include/asm-alpha/init.h~ Fri Aug 6 09:31:08 1999
+++ linux/include/asm-alpha/init.h Mon Aug 9 13:30:33 1999
@@ -1 +1,11 @@
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
+#ifndef _ASM_INIT_H
+#define _ASM_INIT_H
+
+#ifndef _LINUX_INIT_H
+#error "<asm/init.h> should never be used directly - use <linux/init.h> instead"
+#endif
+
+#ifndef __ASSEMBLY__
+typedef unsigned long initcall_t;
+#endif
+#endif
--- linux/include/asm-arm/init.h~ Wed Jul 28 13:30:56 1999
+++ linux/include/asm-arm/init.h Mon Aug 9 13:30:33 1999
@@ -1,32 +1,11 @@
-#ifndef _ASMARM_INIT_H
-#define _ASMARM_INIT_H
-
-#include <linux/config.h>
-
-/* C routines */
-
-#ifdef CONFIG_TEXT_SECTIONS
-
-#define __init __attribute__ ((__section__ (".text.init")))
-#define __initfunc(__arginit) \
- __arginit __init; \
- __arginit
-
-#else
-
-#define __init
-#define __initfunc(__arginit) __arginit
+#ifndef _ASM_INIT_H
+#define _ASM_INIT_H

+#ifndef _LINUX_INIT_H
+#error "<asm/init.h> should never be used directly - use <linux/init.h> instead"
#endif

-#define __initdata __attribute__ ((__section__ (".data.init")))
-
-/* Assembly routines */
-#define __INIT .section ".text.init",@alloc,@execinstr
-#define __INITDATA .section ".data.init",@alloc,@write
-#define __FINIT .previous
-
-#define __cacheline_aligned __attribute__ \
- ((__aligned__ (L1_CACHE_BYTES)))
-
+#ifndef __ASSEMBLY__
+typedef unsigned long initcall_t;
+#endif
#endif
--- linux/include/asm-i386/init.h~ Wed Aug 4 13:44:20 1999
+++ linux/include/asm-i386/init.h Mon Aug 9 13:30:33 1999
@@ -1 +1,11 @@
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
+#ifndef _ASM_INIT_H
+#define _ASM_INIT_H
+
+#ifndef _LINUX_INIT_H
+#error "<asm/init.h> should never be used directly - use <linux/init.h> instead"
+#endif
+
+#ifndef __ASSEMBLY__
+typedef unsigned long initcall_t;
+#endif
+#endif
--- linux/include/asm-m68k/init.h~ Wed Jul 28 13:31:23 1999
+++ linux/include/asm-m68k/init.h Mon Aug 9 13:30:33 1999
@@ -1,37 +1,11 @@
-#ifndef _M68K_INIT_H
-#define _M68K_INIT_H
-
-#include <linux/config.h>
-
-#ifndef CONFIG_KGDB
-
-#define __init __attribute__ ((__section__ (".text.init")))
-#define __initdata __attribute__ ((__section__ (".data.init")))
-#define __initfunc(__arginit) \
- __arginit __init; \
- __arginit
-/* For assembly routines */
-#define __INIT .section ".text.init",#alloc,#execinstr
-#define __FINIT .previous
-#define __INITDATA .section ".data.init",#alloc,#write
-
-#define __cacheline_aligned __attribute__ \
- ((__aligned__(16), __section__ (".data.cacheline_aligned")))
-
-#else
-
-/* gdb doesn't like it all if the code for one source file isn't together in
- * the executable, so we must avoid the .init sections :-( */
-
-#define __init
-#define __initdata
-#define __initfunc(__arginit) __arginit
-/* For assembly routines */
-#define __INIT
-#define __FINIT
-#define __INITDATA
-#define __cacheline_aligned __attribute__ ((__aligned__(16)))
-
-#endif /* CONFIG_KGDB */
+#ifndef _ASM_INIT_H
+#define _ASM_INIT_H

+#ifndef _LINUX_INIT_H
+#error "<asm/init.h> should never be used directly - use <linux/init.h> instead"
+#endif
+
+#ifndef __ASSEMBLY__
+typedef unsigned long initcall_t;
+#endif
#endif
--- linux/include/asm-mips/init.h~ Wed Jul 28 13:31:31 1999
+++ linux/include/asm-mips/init.h Mon Aug 9 13:30:33 1999
@@ -1,30 +1,11 @@
-/* $Id: init.h,v 1.3 1999/02/15 02:22:10 ralf Exp $
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright 1998, 1999 Ralf Baechle
- */
-#ifndef __MIPS_INIT_H
-#define __MIPS_INIT_H
+#ifndef _ASM_INIT_H
+#define _ASM_INIT_H

-#define __init __attribute__ ((__section__ (".text.init")))
-#define __initdata __attribute__ ((__section__ (".data.init")))
-#define __initfunc(__arginit) \
- __arginit __init; \
- __arginit
-
-#if __GNUC__ >= 2 && __GNUC_MINOR__ >= 8
-#define __initlocaldata __initdata
-#else
-#define __initlocaldata
+#ifndef _LINUX_INIT_H
+#error "<asm/init.h> should never be used directly - use <linux/init.h> instead"
#endif

-/* For assembly routines */
-#define __INIT .section .text.init,"ax"
-#define __FINIT .previous
-#define __INITDATA .section .data.init,"a"
-#define __cacheline_aligned __attribute__((__aligned__(L1_CACHE_BYTES)))
-
-#endif /* __MIPS_INIT_H */
+#ifndef __ASSEMBLY__
+typedef unsigned long initcall_t;
+#endif
+#endif
--- linux/include/asm-ppc/init.h~ Fri Aug 6 09:31:30 1999
+++ linux/include/asm-ppc/init.h Mon Aug 9 15:38:49 1999
@@ -1,7 +1,13 @@
#ifndef _PPC_INIT_H
#define _PPC_INIT_H

-#include <linux/init.h>
+#ifndef _LINUX_INIT_H
+#error "<asm/init.h> should never be used directly - use <linux/init.h> instead"
+#endif
+
+#ifndef __ASSEMBLY__
+typedef unsigned long initcall_t;
+#endif

#if 0/*__GNUC__ > 2 || __GNUC_MINOR__ >= 90*/ /* egcs */
#define __pmacdata __attribute__ ((__section__ (".data.pmac")))
--- linux/include/asm-sparc64/init.h~ Wed Aug 4 13:44:59 1999
+++ linux/include/asm-sparc64/init.h Mon Aug 9 13:35:52 1999
@@ -1 +1,18 @@
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
+#ifndef _ASM_INIT_H
+#define _ASM_INIT_H
+
+#ifndef _LINUX_INIT_H
+#error "<asm/init.h> should never be used directly - use <linux/init.h> instead"
+#endif
+
+#ifndef __ASSEMBLY__
+
+#if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
+typedef unsigned long initcall_t;
+#else
+/* gcc up to 2.95 generates wrong sized constructors for 64bit SPARC code */
+typedef unsigned int initcall_t;
+#endif
+
+#endif
+#endif
--- linux/include/linux/init.h~ Fri Aug 6 09:31:50 1999
+++ linux/include/linux/init.h Mon Aug 9 14:44:23 1999
@@ -39,8 +39,29 @@
*
* For initialized data not at file scope, i.e. within a function,
* you should use __initlocaldata instead, due to a bug in GCC 2.7.
+ *
+ * For initialization functions to be run automaticaly on startup:
+ *
+ * static void __initcall initme(int x, int y)
+ * {
+ * extern int z; z = x * y;
+ * }
+ *
+ * or, if the init code is the same for modules and non-modules:
+ *
+ * static int __initcall init_module (void)
+ * {
+ * }
+ *
+ * For cleanup functions:
+ *
+ * static void __exit cleanup_module (void)
+ * {
+ * }
*/

+#include <asm/init.h>
+
/*
* Disable the __initfunc macros if a file that is a part of a
* module attempts to use them. We do not want to interfere
@@ -49,16 +70,14 @@

#ifndef MODULE

+#ifndef __ASSEMBLY__
+
/*
* Used for initialization calls..
*/
-typedef int (*initcall_t)(void);

extern initcall_t __initcall_start, __initcall_end;

-#define __initcall(fn) \
- static initcall_t __initcall_##fn __init_call = fn
-
/*
* Used for kernel command line parameter setup
*/
@@ -73,16 +92,18 @@ extern struct kernel_param __setup_start
static char __setup_str_##fn[] __initdata = str; \
static struct kernel_param __setup_##fn __initsetup = { __setup_str_##fn, fn }

+#endif /* __ASSEMBLY__ */
+
/*
* Mark functions and data as being only used at initialization
* or exit time.
*/
#define __init __attribute__ ((__section__ (".text.init")))
-#define __exit __attribute__ ((unused, __section__(".text.init")))
+#define __exit __attribute__ ((unused, __section__(".text.exit")))
#define __initdata __attribute__ ((__section__ (".data.init")))
-#define __exitdata __attribute__ ((unused, __section__ (".data.init")))
+#define __exitdata __attribute__ ((unused, __section__ (".data.exit")))
#define __initsetup __attribute__ ((unused,__section__ (".setup.init")))
-#define __init_call __attribute__ ((unused,__section__ (".initcall.init")))
+#define __initcall __attribute__ ((__section__ (".text.init"), __constructor__))

#define __initfunc(__arginit) \
__arginit __init; \
@@ -93,9 +114,6 @@ extern struct kernel_param __setup_start
#define __FINIT .previous
#define __INITDATA .section ".data.init","aw"

-#define module_init(x) __initcall(x);
-#define module_exit(x) /* nothing */
-
#else

#define __init
@@ -108,15 +126,6 @@ extern struct kernel_param __setup_start
#define __INIT
#define __FINIT
#define __INITDATA
-
-/* Not sure what version aliases were introduced in, but certainly in 2.95. */
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
-#define module_init(x) int init_module(void) __attribute__((alias(#x)));
-#define module_exit(x) void cleanup_module(void) __attribute__((alias(#x)));
-#else
-#define module_init(x) int init_module(void) { return x(); }
-#define module_exit(x) void cleanup_module(void) { x(); }
-#endif

#endif

--- linux/init/main.c~ Mon Aug 9 14:09:39 1999
+++ linux/init/main.c Mon Aug 9 14:47:50 1999
@@ -563,8 +563,7 @@ static void __init do_initcalls(void)

call = &__initcall_start;
do {
- (*call)();
- call++;
+ ((void (*)(void))(unsigned long)*call++)();
} while (call < &__initcall_end);
}

--- linux/mm/vmscan.c~ Wed Aug 4 13:46:39 1999
+++ linux/mm/vmscan.c Mon Aug 9 13:51:00 1999
@@ -524,12 +524,10 @@ int try_to_free_pages(unsigned int gfp_m
return retval;
}

-static int __init kswapd_init(void)
+static int __initcall kswapd_init(void)
{
printk("Starting kswapd v1.6\n");
swap_setup();
kernel_thread(kswapd, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
return 0;
}
-
-module_init(kswapd_init)

Cheers,
Jakub
___________________________________________________________________
Jakub Jelinek | jj@sunsite.mff.cuni.cz | http://sunsite.mff.cuni.cz
Administrator of SunSITE Czech Republic, MFF, Charles University
___________________________________________________________________
UltraLinux | http://ultra.linux.cz/ | http://ultra.penguin.cz/
Linux version 2.3.13 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/