[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] cleanups for patch-int-2.4.0-3
Hi Astor,
this patch moves all the initialization for the kerneli-patch
to the newstyle module_{init,exit} version. It does also work
for 2.2.18, the most recent Linux 2.2 version, so I don't think
it causes branching headaches. Once requiring 2.2.18 one proc
support function in cryptoapi.c can also be removed.
Christoph
--
Of course it doesn't work. We've performed a software upgrade.
diff -uNr --exclude-from=dontdiff linux-2.4.2-pre3/crypto/cipher-aes.c linux/crypto/cipher-aes.c
--- linux-2.4.2-pre3/crypto/cipher-aes.c Mon Feb 12 00:06:37 2001
+++ linux/crypto/cipher-aes.c Sun Feb 11 23:52:37 2001
@@ -424,11 +424,7 @@
struct cipher_implementation aes_cbc;
-#ifdef MODULE
- int __init init_module(void)
-#else
- int __init init_rijndael(void)
-#endif
+static int __init init_rijndael(void)
{
gen_tabs();
memcpy(&aes_ecb, &rijndael_ecb, sizeof(struct cipher_implementation));
@@ -449,8 +445,7 @@
return 0;
}
-#ifdef MODULE
-void cleanup_module(void)
+static void __exit cleanup_rijndael(void)
{
#ifdef CONFIG_CIPHER_RIJNDAEL
if (unregister_cipher(&rijndael_ecb))
@@ -463,5 +458,6 @@
if (unregister_cipher(&aes_cbc))
printk(KERN_WARNING "Couldn't unregister aes-cbc encryption\n");
}
-#endif
+module_init(init_rijndael);
+module_exit(cleanup_rijndael);
diff -uNr --exclude-from=dontdiff linux-2.4.2-pre3/crypto/cipher-blowfish.c linux/crypto/cipher-blowfish.c
--- linux-2.4.2-pre3/crypto/cipher-blowfish.c Mon Feb 12 00:06:37 2001
+++ linux/crypto/cipher-blowfish.c Sun Feb 11 23:53:19 2001
@@ -491,11 +491,7 @@
INIT_CIPHER_OPS(blowfish)
};
-#ifdef MODULE
-int __init init_module(void)
-#else
-int __init init_blowfish(void)
-#endif
+static int __init init_blowfish(void)
{
if (register_cipher(&blowfish_ecb))
printk(KERN_WARNING "Couldn't register blowfish-ecb encryption\n");
@@ -505,12 +501,13 @@
return 0;
}
-#ifdef MODULE
-void cleanup_module(void)
+static void __exit cleanup_blowfish(void)
{
if (unregister_cipher(&blowfish_ecb))
printk(KERN_WARNING "Couldn't unregister blowfish-ecb encryption\n");
if (unregister_cipher(&blowfish_cbc))
printk(KERN_WARNING "Couldn't unregister blowfish-cbc encryption\n");
}
-#endif
+
+module_init(init_blowfish);
+module_exit(cleanup_blowfish);
diff -uNr --exclude-from=dontdiff linux-2.4.2-pre3/crypto/cipher-des-ede3.c linux/crypto/cipher-des-ede3.c
--- linux-2.4.2-pre3/crypto/cipher-des-ede3.c Mon Feb 12 00:06:37 2001
+++ linux/crypto/cipher-des-ede3.c Mon Feb 12 00:42:32 2001
@@ -1303,11 +1303,7 @@
INIT_CIPHER_OPS(des_ede3)
};
-#ifdef MODULE
-int __init init_module(void)
-#else
-int __init init_des_ede3(void)
-#endif
+static int __init init_des_ede3(void)
{
if (register_cipher(&des_ede3_ecb))
printk(KERN_WARNING "Couldn't register des_ede3-ecb encryption\n");
@@ -1317,12 +1313,13 @@
return 0;
}
-#ifdef MODULE
-void cleanup_module(void)
+static void __exit cleanup_des_ede3(void)
{
if (unregister_cipher(&des_ede3_ecb))
printk(KERN_WARNING "Couldn't unregister des_ede3-ecb encryption\n");
if (unregister_cipher(&des_ede3_cbc))
printk(KERN_WARNING "Couldn't unregister des_ede3-cbc encryption\n");
}
-#endif
+
+module_init(init_des_ede3);
+module_exit(cleanup_des_ede3);
diff -uNr --exclude-from=dontdiff linux-2.4.2-pre3/crypto/cipher-des.c linux/crypto/cipher-des.c
--- linux-2.4.2-pre3/crypto/cipher-des.c Mon Feb 12 00:06:37 2001
+++ linux/crypto/cipher-des.c Sun Feb 11 23:54:40 2001
@@ -1216,11 +1216,7 @@
INIT_CIPHER_OPS(des)
};
-#ifdef MODULE
-int __init init_module(void)
-#else
-int __init init_des(void)
-#endif
+static int __init init_des(void)
{
if (register_cipher(&des_ecb))
printk(KERN_WARNING "Couldn't register des-ecb encryption\n");
@@ -1230,12 +1226,13 @@
return 0;
}
-#ifdef MODULE
-void cleanup_module(void)
+static void __exit cleanup_des(void)
{
if (unregister_cipher(&des_ecb))
printk(KERN_WARNING "Couldn't unregister des-ecb encryption\n");
if (unregister_cipher(&des_cbc))
printk(KERN_WARNING "Couldn't unregister des-cbc encryption\n");
}
-#endif
+
+module_init(init_des);
+module_exit(cleanup_des);
diff -uNr --exclude-from=dontdiff linux-2.4.2-pre3/crypto/cipher-dfc.c linux/crypto/cipher-dfc.c
--- linux-2.4.2-pre3/crypto/cipher-dfc.c Mon Feb 12 00:06:37 2001
+++ linux/crypto/cipher-dfc.c Sun Feb 11 23:55:27 2001
@@ -464,11 +464,7 @@
};
-#ifdef MODULE
- int __init init_module(void)
-#else
- int __init init_dfc(void)
-#endif
+static int __init init_dfc(void)
{
if (register_cipher(&dfc_ecb))
printk(KERN_WARNING "Couldn't register dfc-ecb encryption\n");
@@ -478,13 +474,13 @@
return 0;
}
-#ifdef MODULE
-void cleanup_module(void)
+static void __exit cleanup_dfc(void)
{
if (unregister_cipher(&dfc_ecb))
printk(KERN_WARNING "Couldn't unregister dfc-ecb encryption\n");
if (unregister_cipher(&dfc_cbc))
printk(KERN_WARNING "Couldn't unregister dfc-cbc encryption\n");
}
-#endif
+module_init(init_dfc);
+module_exit(cleanup_dfc);
diff -uNr --exclude-from=dontdiff linux-2.4.2-pre3/crypto/cipher-idea.c linux/crypto/cipher-idea.c
--- linux-2.4.2-pre3/crypto/cipher-idea.c Mon Feb 12 00:06:37 2001
+++ linux/crypto/cipher-idea.c Sun Feb 11 23:56:16 2001
@@ -391,11 +391,7 @@
INIT_CIPHER_OPS(idea)
};
-#ifdef MODULE
-int __init init_module(void)
-#else
-int __init init_idea(void)
-#endif
+static int __init init_idea(void)
{
if (register_cipher(&idea_ecb))
printk(KERN_WARNING "Couldn't register idea-ecb encryption\n");
@@ -404,12 +400,13 @@
return 0;
}
-#ifdef MODULE
-void cleanup_module(void)
+static void __exit cleanup_idea(void)
{
if (unregister_cipher(&idea_ecb))
printk(KERN_WARNING "Couldn't unregister idea-ecb encryption\n");
if (unregister_cipher(&idea_cbc))
printk(KERN_WARNING "Couldn't unregister idea-cbc encryption\n");
}
-#endif
+
+module_init(init_idea);
+module_exit(cleanup_idea);
diff -uNr --exclude-from=dontdiff linux-2.4.2-pre3/crypto/cipher-mars.c linux/crypto/cipher-mars.c
--- linux-2.4.2-pre3/crypto/cipher-mars.c Mon Feb 12 00:06:37 2001
+++ linux/crypto/cipher-mars.c Sun Feb 11 23:57:12 2001
@@ -454,11 +454,7 @@
};
-#ifdef MODULE
- int __init init_module(void)
-#else
- int __init init_mars(void)
-#endif
+static int __init init_mars(void)
{
if (register_cipher(&mars_ecb))
printk(KERN_WARNING "Couldn't register mars-ecb encryption\n");
@@ -468,12 +464,13 @@
return 0;
}
-#ifdef MODULE
-void cleanup_module(void)
+static void __exit cleanup_mars(void)
{
if (unregister_cipher(&mars_ecb))
printk(KERN_WARNING "Couldn't unregister mars-ecb encryption\n");
if (unregister_cipher(&mars_cbc))
printk(KERN_WARNING "Couldn't unregister mars-cbc encryption\n");
}
-#endif
+
+module_init(init_mars);
+module_exit(cleanup_mars);
diff -uNr --exclude-from=dontdiff linux-2.4.2-pre3/crypto/cipher-rc5.c linux/crypto/cipher-rc5.c
--- linux-2.4.2-pre3/crypto/cipher-rc5.c Mon Feb 12 00:06:37 2001
+++ linux/crypto/cipher-rc5.c Sun Feb 11 23:58:00 2001
@@ -209,11 +209,7 @@
};
-#ifdef MODULE
-int __init init_module(void)
-#else
-int __init init_rc5(void)
-#endif
+static int __init init_rc5(void)
{
if (register_cipher(&rc5_ecb))
printk(KERN_WARNING "Couldn't register RC5-ecb encryption\n");
@@ -223,12 +219,13 @@
return 0;
}
-#ifdef MODULE
-void cleanup_module(void)
+static void __exit cleanup_rc5(void)
{
if (unregister_cipher(&rc5_ecb))
printk(KERN_WARNING "Couldn't unregister RC5_ecb encryption\n");
if (unregister_cipher(&rc5_cbc))
printk(KERN_WARNING "Couldn't unregister RC5-cbc encryption\n");
}
-#endif
+
+module_init(init_rc5);
+module_exit(cleanup_rc5);
diff -uNr --exclude-from=dontdiff linux-2.4.2-pre3/crypto/cipher-rc6.c linux/crypto/cipher-rc6.c
--- linux-2.4.2-pre3/crypto/cipher-rc6.c Mon Feb 12 00:06:37 2001
+++ linux/crypto/cipher-rc6.c Sun Feb 11 23:58:45 2001
@@ -193,11 +193,7 @@
INIT_CIPHER_OPS(rc6)
};
-#ifdef MODULE
- int __init init_module(void)
-#else
- int __init init_rc6(void)
-#endif
+static int __init init_rc6(void)
{
if (register_cipher(&rc6_ecb))
printk(KERN_WARNING "Couldn't register rc6-ecb encryption\n");
@@ -207,12 +203,13 @@
return 0;
}
-#ifdef MODULE
-void cleanup_module(void)
+static void __exit cleanup_rc6(void)
{
if (unregister_cipher(&rc6_ecb))
printk(KERN_WARNING "Couldn't unregister rc6-ecb encryption\n");
if (unregister_cipher(&rc6_cbc))
printk(KERN_WARNING "Couldn't unregister rc6-cbc encryption\n");
}
-#endif
+
+module_init(init_rc6);
+module_exit(cleanup_rc6);
diff -uNr --exclude-from=dontdiff linux-2.4.2-pre3/crypto/cipher-serpent.c linux/crypto/cipher-serpent.c
--- linux-2.4.2-pre3/crypto/cipher-serpent.c Mon Feb 12 00:06:37 2001
+++ linux/crypto/cipher-serpent.c Sun Feb 11 23:59:27 2001
@@ -1027,11 +1027,7 @@
INIT_CIPHER_OPS(serpent)
};
-#ifdef MODULE
-int __init init_module(void)
-#else
-int __init init_serpent(void)
-#endif
+static int __init init_serpent(void)
{
if (register_cipher(&serpent_ecb))
printk(KERN_WARNING "Couldn't register serpent-ecb encryption\n");
@@ -1041,13 +1037,13 @@
return 0;
}
-#ifdef MODULE
-void cleanup_module(void)
+static void __exit cleanup_serpent(void)
{
if (unregister_cipher(&serpent_ecb))
printk(KERN_WARNING "Couldn't unregister serpent-ecb encryption\n");
if (unregister_cipher(&serpent_cbc))
printk(KERN_WARNING "Couldn't unregister serpent-cbc encryption\n");
}
-#endif
+module_init(init_serpent);
+module_exit(cleanup_serpent);
diff -uNr --exclude-from=dontdiff linux-2.4.2-pre3/crypto/cipher-twofish.c linux/crypto/cipher-twofish.c
--- linux-2.4.2-pre3/crypto/cipher-twofish.c Mon Feb 12 00:06:37 2001
+++ linux/crypto/cipher-twofish.c Mon Feb 12 00:00:55 2001
@@ -442,11 +442,7 @@
INIT_CIPHER_OPS(twofish)
};
-#ifdef MODULE
- int __init init_module(void)
-#else
- int __init init_twofish(void)
-#endif
+static int __init init_twofish(void)
{
if (register_cipher(&twofish_ecb))
printk(KERN_WARNING "Couldn't register twofish-ecb encryption\n");
@@ -456,8 +452,7 @@
return 0;
}
-#ifdef MODULE
-void cleanup_module(void)
+static void cleanup_twofish(void)
{
if (unregister_cipher(&twofish_ecb))
printk(KERN_WARNING "Couldn't unregister twofish-ecb encryption\n");
@@ -465,4 +460,5 @@
printk(KERN_WARNING "Couldn't unregister twofish-cbc encryption\n");
}
-#endif
+module_init(init_twofish);
+module_exit(cleanup_twofish);
diff -uNr --exclude-from=dontdiff linux-2.4.2-pre3/crypto/cryptoapi.c linux/crypto/cryptoapi.c
--- linux-2.4.2-pre3/crypto/cryptoapi.c Mon Feb 12 00:06:37 2001
+++ linux/crypto/cryptoapi.c Mon Feb 12 00:05:06 2001
@@ -6,9 +6,6 @@
* 2000-10-15 Harald Welte <laforge@gnumonks.org>
* - ported to Linux 2.4
*
- * This module is still using old 2.2 module_init/exit semantics for
- * backwards compatibility - HW
- *
* Copyright 1998 by Alexander Kjeldaas. Redistribution of this file
* is permitted under the GNU Public License.
*/
@@ -58,8 +55,8 @@
int count, int *eof, void *data);
#endif
-LIST_HEAD(ciphers);
-LIST_HEAD(digests);
+static LIST_HEAD(ciphers);
+static LIST_HEAD(digests);
static struct transform_group transforms[MAX_TRANSFORM] = {
/* digest */
@@ -76,40 +73,7 @@
}
};
-#ifdef CONFIG_PROC_FS
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18)
-/* We have to emulate the 2.4 function proc_mkdir, because it is not
- * present in 2.2 - HW */
-static struct proc_dir_entry *
-proc_mkdir(const char *name, struct proc_dir_entry *parent)
-{
- struct proc_dir_entry *ent = NULL;
- const char *fn = name;
- int len;
-
- if (!parent)
- parent = &proc_root;
- len = strlen(fn);
-
- ent = kmalloc(sizeof(struct proc_dir_entry) + len + 1, GFP_KERNEL);
- if (!ent)
- goto out;
- memset(ent, 0, sizeof(struct proc_dir_entry));
- memcpy(((char *) ent) + sizeof(*ent), fn, len + 1);
- ent->name = ((char *) ent) + sizeof(*ent);
- ent->namelen = len;
- ent->ops = NULL;
- ent->nlink = 2;
- ent->mode = S_IFDIR | S_IRUGO | S_IXUGO;
-
- proc_register(parent, ent);
-
-out:
- return ent;
-}
-#endif
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) && defined(CONFIG_PROC_FS)
static struct proc_dir_entry *
create_proc_read_entry(const char *name,
mode_t mode, struct proc_dir_entry *base,
@@ -124,7 +88,6 @@
}
#endif
-#endif
/**
@@ -459,11 +422,8 @@
#endif
-#ifdef MODULE
-int __init init_module(void)
-#else
-int __init cryptoapi_init(void)
-#endif
+static int __init
+init_cryptoapi(void)
{
int i;
@@ -475,52 +435,11 @@
proc_mkdir(transforms[i].tg_name, proc_crypto);
}
#endif
-
-#ifdef CONFIG_DIGEST_MD5
- init_md5();
-#endif
-#ifdef CONFIG_DIGEST_SHA1
- init_sha1();
-#endif
-#ifdef CONFIG_CIPHER_AES
- init_rijndael();
-#endif
-#ifdef CONFIG_CIPHER_TWOFISH
- init_twofish();
-#endif
-#ifdef CONFIG_CIPHER_SERPENT
- init_serpent();
-#endif
-#ifdef CONFIG_CIPHER_RC5
- init_rc5();
-#endif
-#ifdef CONFIG_CIPHER_RC6
- init_rc6();
-#endif
-#ifdef CONFIG_CIPHER_MARS
- init_mars();
-#endif
-#ifdef CONFIG_CIPHER_DFC
- init_dfc();
-#endif
-#ifdef CONFIG_CIPHER_BLOWFISH
- init_blowfish();
-#endif
-#ifdef CONFIG_CIPHER_IDEA
- init_idea();
-#endif
-#ifdef CONFIG_CIPHER_DES
- init_des();
-#endif
-#ifdef CONFIG_CIPHER_DES_EDE3
- init_des_ede3();
-#endif
-
return 0;
}
-#ifdef MODULE
-void cleanup_module(void)
+static void __exit
+cleanup_cryptoapi(void)
{
int i;
@@ -533,7 +452,9 @@
#endif
}
-#endif
+
+module_init(init_cryptoapi);
+module_exit(cleanup_cryptoapi);
EXPORT_SYMBOL(find_transform_by_name);
diff -uNr --exclude-from=dontdiff linux-2.4.2-pre3/crypto/digest-md5.c linux/crypto/digest-md5.c
--- linux-2.4.2-pre3/crypto/digest-md5.c Mon Feb 12 00:06:37 2001
+++ linux/crypto/digest-md5.c Mon Feb 12 00:01:42 2001
@@ -85,20 +85,17 @@
INIT_DIGEST_OPS(md5)
};
-#ifdef MODULE
-#define init_md5 init_module
-#endif
-
-int __init init_md5 (void)
+static int __init init_md5 (void)
{
printk ("MD5 Message Digest Algorithm (c) RSA Systems, Inc\n");
register_digest (&md5);
return 0;
}
-#ifdef MODULE
-void cleanup_module (void)
+static void __exit cleanup_md5 (void)
{
unregister_digest (&md5);
}
-#endif
+
+module_init(init_md5);
+module_exit(cleanup_md5);
diff -uNr --exclude-from=dontdiff linux-2.4.2-pre3/crypto/digest-sha1.c linux/crypto/digest-sha1.c
--- linux-2.4.2-pre3/crypto/digest-sha1.c Mon Feb 12 00:06:37 2001
+++ linux/crypto/digest-sha1.c Mon Feb 12 00:02:24 2001
@@ -84,19 +84,16 @@
INIT_DIGEST_OPS(sha1)
};
-#ifdef MODULE
-#define init_sha1 init_module
-#endif
-
-int __init init_sha1 (void)
+static int __init init_sha1 (void)
{
register_digest (&sha1);
return 0;
}
-#ifdef MODULE
-void cleanup_module (void)
+static void __exit cleanup_sha1 (void)
{
unregister_digest (&sha1);
}
-#endif
+
+module_init(init_sha1);
+module_exit(cleanup_sha1);
diff -uNr --exclude-from=dontdiff linux-2.4.2-pre3/include/linux/crypto.h linux/include/linux/crypto.h
--- linux-2.4.2-pre3/include/linux/crypto.h Mon Feb 12 00:06:37 2001
+++ linux/include/linux/crypto.h Mon Feb 12 00:05:59 2001
@@ -249,31 +249,6 @@
int unregister_cipher(struct cipher_implementation *ci);
int unregister_digest(struct digest_implementation *ci);
-/* System initialization */
-extern int cryptoapi_init(void);
-
-/* Cipher implementations */
-
-extern int init_cast256(void);
-extern int init_crypton(void);
-extern int init_serpent(void);
-extern int init_mars(void);
-extern int init_rc5(void);
-extern int init_rc6(void);
-extern int init_dfc(void);
-extern int init_rijndael(void);
-extern int init_blowfish(void);
-extern int init_twofish(void);
-extern int init_idea(void);
-extern int init_des(void);
-extern int init_des_ede3(void);
-
-
-/* Digest implementations */
-
-extern int init_md5(void);
-extern int init_sha1(void);
-
/* Utility macros */
diff -uNr --exclude-from=dontdiff linux-2.4.2-pre3/init/main.c linux/init/main.c
--- linux-2.4.2-pre3/init/main.c Mon Feb 12 00:06:37 2001
+++ linux/init/main.c Sun Feb 11 23:51:29 2001
@@ -67,10 +67,6 @@
#include <asm/smp.h>
#endif
-#ifdef CONFIG_CRYPTO
-#include <linux/crypto.h>
-#endif
-
/*
* Versions of gcc older than that listed below may actually compile
* and link okay, but the end product can have subtle run time bugs.
@@ -730,11 +726,6 @@
filesystem_setup();
-#ifdef CONFIG_CRYPTO
- /* .. crypto .. */
- cryptoapi_init();
-#endif
-
#ifdef CONFIG_IRDA
irda_device_init(); /* Must be done after protocol initialization */
#endif
Linux-crypto: cryptography in and on the Linux system
Archive: http://mail.nl.linux.org/linux-crypto/