Commit 8697648c authored by Rusty Russell's avatar Rusty Russell Committed by David S. Miller

[CRYPTO]: Use try_then_request_module().

try_then_request_module() does what crypto/autoload.c is doing, so
replace it.  Fix try_then_request_module(), too (thanks James).
parent fb06b8ee
...@@ -2,11 +2,10 @@ ...@@ -2,11 +2,10 @@
# Cryptographic API # Cryptographic API
# #
autoload-crypto-$(CONFIG_KMOD) = autoload.o
proc-crypto-$(CONFIG_PROC_FS) = proc.o proc-crypto-$(CONFIG_PROC_FS) = proc.o
obj-$(CONFIG_CRYPTO) += api.o cipher.o digest.o compress.o \ obj-$(CONFIG_CRYPTO) += api.o cipher.o digest.o compress.o \
$(autoload-crypto-y) $(proc-crypto-y) $(proc-crypto-y)
obj-$(CONFIG_CRYPTO_HMAC) += hmac.o obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o
......
/*
* Cryptographic API.
*
* Algorithm autoloader.
*
* Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
*/
#include <linux/kernel.h>
#include <linux/crypto.h>
#include <linux/string.h>
#include <linux/kmod.h>
#include "internal.h"
/*
* A far more intelligent version of this is planned. For now, just
* try an exact match on the name of the algorithm.
*/
void crypto_alg_autoload(const char *name)
{
request_module("%s", name);
}
struct crypto_alg *crypto_alg_mod_lookup(const char *name)
{
struct crypto_alg *alg = crypto_alg_lookup(name);
if (alg == NULL) {
crypto_alg_autoload(name);
alg = crypto_alg_lookup(name);
}
return alg;
}
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/highmem.h> #include <linux/highmem.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kmod.h>
#include <asm/hardirq.h> #include <asm/hardirq.h>
#include <asm/kmap_types.h> #include <asm/kmap_types.h>
...@@ -48,15 +49,12 @@ static inline void *crypto_tfm_ctx(struct crypto_tfm *tfm) ...@@ -48,15 +49,12 @@ static inline void *crypto_tfm_ctx(struct crypto_tfm *tfm)
struct crypto_alg *crypto_alg_lookup(const char *name); struct crypto_alg *crypto_alg_lookup(const char *name);
#ifdef CONFIG_KMOD /* A far more intelligent version of this is planned. For now, just
void crypto_alg_autoload(const char *name); * try an exact match on the name of the algorithm. */
struct crypto_alg *crypto_alg_mod_lookup(const char *name);
#else
static inline struct crypto_alg *crypto_alg_mod_lookup(const char *name) static inline struct crypto_alg *crypto_alg_mod_lookup(const char *name)
{ {
return crypto_alg_lookup(name); return try_then_request_module(crypto_alg_lookup(name), name);
} }
#endif
#ifdef CONFIG_CRYPTO_HMAC #ifdef CONFIG_CRYPTO_HMAC
int crypto_alloc_hmac_block(struct crypto_tfm *tfm); int crypto_alloc_hmac_block(struct crypto_tfm *tfm);
......
...@@ -29,7 +29,7 @@ extern int request_module(const char * name, ...) __attribute__ ((format (printf ...@@ -29,7 +29,7 @@ extern int request_module(const char * name, ...) __attribute__ ((format (printf
static inline int request_module(const char * name, ...) { return -ENOSYS; } static inline int request_module(const char * name, ...) { return -ENOSYS; }
#endif #endif
#define try_then_request_module(x, mod...) ((x) ?: request_module(mod), (x)) #define try_then_request_module(x, mod...) ((x) ?: (request_module(mod), (x)))
extern int call_usermodehelper(char *path, char *argv[], char *envp[], int wait); extern int call_usermodehelper(char *path, char *argv[], char *envp[], int wait);
#ifdef CONFIG_HOTPLUG #ifdef CONFIG_HOTPLUG
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment