Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+40 -49
-43
crypto/scatterwalk.c
··· 18 18 #include <linux/kernel.h> 19 19 #include <linux/mm.h> 20 20 #include <linux/module.h> 21 - #include <linux/pagemap.h> 22 - #include <linux/highmem.h> 23 21 #include <linux/scatterlist.h> 24 22 25 23 static inline void memcpy_dir(void *buf, void *sgdata, size_t nbytes, int out) ··· 27 29 28 30 memcpy(dst, src, nbytes); 29 31 } 30 - 31 - void scatterwalk_start(struct scatter_walk *walk, struct scatterlist *sg) 32 - { 33 - walk->sg = sg; 34 - walk->offset = sg->offset; 35 - } 36 - EXPORT_SYMBOL_GPL(scatterwalk_start); 37 - 38 - void *scatterwalk_map(struct scatter_walk *walk) 39 - { 40 - return kmap_atomic(scatterwalk_page(walk)) + 41 - offset_in_page(walk->offset); 42 - } 43 - EXPORT_SYMBOL_GPL(scatterwalk_map); 44 - 45 - static void scatterwalk_pagedone(struct scatter_walk *walk, int out, 46 - unsigned int more) 47 - { 48 - if (out) { 49 - struct page *page; 50 - 51 - page = sg_page(walk->sg) + ((walk->offset - 1) >> PAGE_SHIFT); 52 - /* Test ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE first as 53 - * PageSlab cannot be optimised away per se due to 54 - * use of volatile pointer. 55 - */ 56 - if (ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE && !PageSlab(page)) 57 - flush_dcache_page(page); 58 - } 59 - 60 - if (more && walk->offset >= walk->sg->offset + walk->sg->length) 61 - scatterwalk_start(walk, sg_next(walk->sg)); 62 - } 63 - 64 - void scatterwalk_done(struct scatter_walk *walk, int out, int more) 65 - { 66 - if (!more || walk->offset >= walk->sg->offset + walk->sg->length || 67 - !(walk->offset & (PAGE_SIZE - 1))) 68 - scatterwalk_pagedone(walk, out, more); 69 - } 70 - EXPORT_SYMBOL_GPL(scatterwalk_done); 71 32 72 33 void scatterwalk_copychunks(void *buf, struct scatter_walk *walk, 73 34 size_t nbytes, int out)
+40 -6
include/crypto/scatterwalk.h
··· 16 16 #ifndef _CRYPTO_SCATTERWALK_H 17 17 #define _CRYPTO_SCATTERWALK_H 18 18 19 - #include <asm/kmap_types.h> 20 19 #include <crypto/algapi.h> 21 - #include <linux/hardirq.h> 22 20 #include <linux/highmem.h> 23 21 #include <linux/kernel.h> 24 - #include <linux/mm.h> 25 22 #include <linux/scatterlist.h> 26 - #include <linux/sched.h> 27 23 28 24 static inline void scatterwalk_crypto_chain(struct scatterlist *head, 29 25 struct scatterlist *sg, ··· 79 83 kunmap_atomic(vaddr); 80 84 } 81 85 82 - void scatterwalk_start(struct scatter_walk *walk, struct scatterlist *sg); 86 + static inline void scatterwalk_start(struct scatter_walk *walk, 87 + struct scatterlist *sg) 88 + { 89 + walk->sg = sg; 90 + walk->offset = sg->offset; 91 + } 92 + 93 + static inline void *scatterwalk_map(struct scatter_walk *walk) 94 + { 95 + return kmap_atomic(scatterwalk_page(walk)) + 96 + offset_in_page(walk->offset); 97 + } 98 + 99 + static inline void scatterwalk_pagedone(struct scatter_walk *walk, int out, 100 + unsigned int more) 101 + { 102 + if (out) { 103 + struct page *page; 104 + 105 + page = sg_page(walk->sg) + ((walk->offset - 1) >> PAGE_SHIFT); 106 + /* Test ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE first as 107 + * PageSlab cannot be optimised away per se due to 108 + * use of volatile pointer. 109 + */ 110 + if (ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE && !PageSlab(page)) 111 + flush_dcache_page(page); 112 + } 113 + 114 + if (more && walk->offset >= walk->sg->offset + walk->sg->length) 115 + scatterwalk_start(walk, sg_next(walk->sg)); 116 + } 117 + 118 + static inline void scatterwalk_done(struct scatter_walk *walk, int out, 119 + int more) 120 + { 121 + if (!more || walk->offset >= walk->sg->offset + walk->sg->length || 122 + !(walk->offset & (PAGE_SIZE - 1))) 123 + scatterwalk_pagedone(walk, out, more); 124 + } 125 + 83 126 void scatterwalk_copychunks(void *buf, struct scatter_walk *walk, 84 127 size_t nbytes, int out); 85 128 void *scatterwalk_map(struct scatter_walk *walk); 86 - void scatterwalk_done(struct scatter_walk *walk, int out, int more); 87 129 88 130 void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg, 89 131 unsigned int start, unsigned int nbytes, int out);