diff options
| author | Herbert Xu <herbert@gondor.apana.org.au> | 2016-07-12 01:18:00 -0400 |
|---|---|---|
| committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-07-18 05:35:50 -0400 |
| commit | ac02725812cb3a814cfe1fdc2a8a59db073e7e66 (patch) | |
| tree | 5480b15a94af14bd105e3981ece6a12898faeb14 /include/crypto | |
| parent | 2ee732d57496b8365819dfb958bc1ff04fcd4cac (diff) | |
crypto: scatterwalk - Inline start/map/done
This patch inlines the functions scatterwalk_start, scatterwalk_map
and scatterwalk_done as they're all tiny and mostly used by the block
cipher walker.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include/crypto')
| -rw-r--r-- | include/crypto/scatterwalk.h | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h index 7e1a33645eb5..880e6be9e95e 100644 --- a/include/crypto/scatterwalk.h +++ b/include/crypto/scatterwalk.h | |||
| @@ -16,14 +16,10 @@ | |||
| 16 | #ifndef _CRYPTO_SCATTERWALK_H | 16 | #ifndef _CRYPTO_SCATTERWALK_H |
| 17 | #define _CRYPTO_SCATTERWALK_H | 17 | #define _CRYPTO_SCATTERWALK_H |
| 18 | 18 | ||
| 19 | #include <asm/kmap_types.h> | ||
| 20 | #include <crypto/algapi.h> | 19 | #include <crypto/algapi.h> |
| 21 | #include <linux/hardirq.h> | ||
| 22 | #include <linux/highmem.h> | 20 | #include <linux/highmem.h> |
| 23 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
| 24 | #include <linux/mm.h> | ||
| 25 | #include <linux/scatterlist.h> | 22 | #include <linux/scatterlist.h> |
| 26 | #include <linux/sched.h> | ||
| 27 | 23 | ||
| 28 | static inline void scatterwalk_crypto_chain(struct scatterlist *head, | 24 | static inline void scatterwalk_crypto_chain(struct scatterlist *head, |
| 29 | struct scatterlist *sg, | 25 | struct scatterlist *sg, |
| @@ -83,11 +79,49 @@ static inline void scatterwalk_unmap(void *vaddr) | |||
| 83 | kunmap_atomic(vaddr); | 79 | kunmap_atomic(vaddr); |
| 84 | } | 80 | } |
| 85 | 81 | ||
| 86 | void scatterwalk_start(struct scatter_walk *walk, struct scatterlist *sg); | 82 | static inline void scatterwalk_start(struct scatter_walk *walk, |
| 83 | struct scatterlist *sg) | ||
| 84 | { | ||
| 85 | walk->sg = sg; | ||
| 86 | walk->offset = sg->offset; | ||
| 87 | } | ||
| 88 | |||
| 89 | static inline void *scatterwalk_map(struct scatter_walk *walk) | ||
| 90 | { | ||
| 91 | return kmap_atomic(scatterwalk_page(walk)) + | ||
| 92 | offset_in_page(walk->offset); | ||
| 93 | } | ||
| 94 | |||
| 95 | static inline void scatterwalk_pagedone(struct scatter_walk *walk, int out, | ||
| 96 | unsigned int more) | ||
| 97 | { | ||
| 98 | if (out) { | ||
| 99 | struct page *page; | ||
| 100 | |||
| 101 | page = sg_page(walk->sg) + ((walk->offset - 1) >> PAGE_SHIFT); | ||
| 102 | /* Test ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE first as | ||
| 103 | * PageSlab cannot be optimised away per se due to | ||
| 104 | * use of volatile pointer. | ||
| 105 | */ | ||
| 106 | if (ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE && !PageSlab(page)) | ||
| 107 | flush_dcache_page(page); | ||
| 108 | } | ||
| 109 | |||
| 110 | if (more && walk->offset >= walk->sg->offset + walk->sg->length) | ||
| 111 | scatterwalk_start(walk, sg_next(walk->sg)); | ||
| 112 | } | ||
| 113 | |||
| 114 | static inline void scatterwalk_done(struct scatter_walk *walk, int out, | ||
| 115 | int more) | ||
| 116 | { | ||
| 117 | if (!more || walk->offset >= walk->sg->offset + walk->sg->length || | ||
| 118 | !(walk->offset & (PAGE_SIZE - 1))) | ||
| 119 | scatterwalk_pagedone(walk, out, more); | ||
| 120 | } | ||
| 121 | |||
| 87 | void scatterwalk_copychunks(void *buf, struct scatter_walk *walk, | 122 | void scatterwalk_copychunks(void *buf, struct scatter_walk *walk, |
| 88 | size_t nbytes, int out); | 123 | size_t nbytes, int out); |
| 89 | void *scatterwalk_map(struct scatter_walk *walk); | 124 | void *scatterwalk_map(struct scatter_walk *walk); |
| 90 | void scatterwalk_done(struct scatter_walk *walk, int out, int more); | ||
| 91 | 125 | ||
| 92 | void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg, | 126 | void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg, |
| 93 | unsigned int start, unsigned int nbytes, int out); | 127 | unsigned int start, unsigned int nbytes, int out); |
