diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2007-12-07 11:52:49 +0100 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2008-01-10 22:16:32 +0100 |
commit | 42c271c6c538857cb13c5ead5184d264d745f675 (patch) | |
tree | 9f6a05c756be3fc3f35ae7fe9b333a33986a2f56 /include/crypto/scatterwalk.h | |
parent | [CRYPTO] aead: Return EBADMSG for ICV mismatch (diff) | |
download | linux-42c271c6c538857cb13c5ead5184d264d745f675.tar.xz linux-42c271c6c538857cb13c5ead5184d264d745f675.zip |
[CRYPTO] scatterwalk: Move scatterwalk.h to linux/crypto
The scatterwalk infrastructure is used by algorithms so it needs to
move out of crypto for future users that may live in drivers/crypto
or asm/*/crypto.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to '')
-rw-r--r-- | include/crypto/scatterwalk.h (renamed from crypto/scatterwalk.h) | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/crypto/scatterwalk.h b/include/crypto/scatterwalk.h index fd5517d2a7a9..07b6f17122d2 100644 --- a/crypto/scatterwalk.h +++ b/include/crypto/scatterwalk.h @@ -1,9 +1,10 @@ /* - * Cryptographic API. + * Cryptographic scatter and gather helpers. * * Copyright (c) 2002 James Morris <jmorris@intercode.com.au> * Copyright (c) 2002 Adam J. Richter <adam@yggdrasil.com> * Copyright (c) 2004 Jean-Luc Cooke <jlcooke@certainkey.com> + * Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.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 @@ -15,10 +16,41 @@ #ifndef _CRYPTO_SCATTERWALK_H #define _CRYPTO_SCATTERWALK_H +#include <asm/kmap_types.h> +#include <crypto/algapi.h> +#include <linux/hardirq.h> +#include <linux/highmem.h> +#include <linux/kernel.h> #include <linux/mm.h> #include <linux/scatterlist.h> -#include "internal.h" +static inline enum km_type crypto_kmap_type(int out) +{ + enum km_type type; + + if (in_softirq()) + type = out * (KM_SOFTIRQ1 - KM_SOFTIRQ0) + KM_SOFTIRQ0; + else + type = out * (KM_USER1 - KM_USER0) + KM_USER0; + + return type; +} + +static inline void *crypto_kmap(struct page *page, int out) +{ + return kmap_atomic(page, crypto_kmap_type(out)); +} + +static inline void crypto_kunmap(void *vaddr, int out) +{ + kunmap_atomic(vaddr, crypto_kmap_type(out)); +} + +static inline void crypto_yield(u32 flags) +{ + if (flags & CRYPTO_TFM_REQ_MAY_SLEEP) + cond_resched(); +} static inline unsigned long scatterwalk_samebuf(struct scatter_walk *walk_in, struct scatter_walk *walk_out) |