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

Configure Feed

Select the types of activity you want to include in your feed.

crypto: s390/aes-gcm - use the new scatterwalk functions

Use scatterwalk_next() which consolidates scatterwalk_clamp() and
scatterwalk_map(). Use scatterwalk_done_src() and
scatterwalk_done_dst() which consolidate scatterwalk_unmap(),
scatterwalk_advance(), and scatterwalk_done().

Besides the new functions being a bit easier to use, this is necessary
because scatterwalk_done() is planned to be removed.

Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Tested-by: Harald Freudenberger <freude@linux.ibm.com>
Cc: Holger Dengler <dengler@linux.ibm.com>
Cc: linux-s390@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Eric Biggers and committed by
Herbert Xu
e7d5d8a8 422bf8fc

+13 -20
+13 -20
arch/s390/crypto/aes_s390.c
··· 787 787 788 788 static inline unsigned int _gcm_sg_clamp_and_map(struct gcm_sg_walk *gw) 789 789 { 790 - struct scatterlist *nextsg; 791 - 792 - gw->walk_bytes = scatterwalk_clamp(&gw->walk, gw->walk_bytes_remain); 793 - while (!gw->walk_bytes) { 794 - nextsg = sg_next(gw->walk.sg); 795 - if (!nextsg) 796 - return 0; 797 - scatterwalk_start(&gw->walk, nextsg); 798 - gw->walk_bytes = scatterwalk_clamp(&gw->walk, 799 - gw->walk_bytes_remain); 800 - } 801 - gw->walk_ptr = scatterwalk_map(&gw->walk); 790 + if (gw->walk_bytes_remain == 0) 791 + return 0; 792 + gw->walk_ptr = scatterwalk_next(&gw->walk, gw->walk_bytes_remain, 793 + &gw->walk_bytes); 802 794 return gw->walk_bytes; 803 795 } 804 796 805 797 static inline void _gcm_sg_unmap_and_advance(struct gcm_sg_walk *gw, 806 - unsigned int nbytes) 798 + unsigned int nbytes, bool out) 807 799 { 808 800 gw->walk_bytes_remain -= nbytes; 809 - scatterwalk_unmap(gw->walk_ptr); 810 - scatterwalk_advance(&gw->walk, nbytes); 811 - scatterwalk_done(&gw->walk, 0, gw->walk_bytes_remain); 801 + if (out) 802 + scatterwalk_done_dst(&gw->walk, gw->walk_ptr, nbytes); 803 + else 804 + scatterwalk_done_src(&gw->walk, gw->walk_ptr, nbytes); 812 805 gw->walk_ptr = NULL; 813 806 } 814 807 ··· 837 844 n = min(gw->walk_bytes, AES_BLOCK_SIZE - gw->buf_bytes); 838 845 memcpy(gw->buf + gw->buf_bytes, gw->walk_ptr, n); 839 846 gw->buf_bytes += n; 840 - _gcm_sg_unmap_and_advance(gw, n); 847 + _gcm_sg_unmap_and_advance(gw, n, false); 841 848 if (gw->buf_bytes >= minbytesneeded) { 842 849 gw->ptr = gw->buf; 843 850 gw->nbytes = gw->buf_bytes; ··· 897 904 } else 898 905 gw->buf_bytes = 0; 899 906 } else 900 - _gcm_sg_unmap_and_advance(gw, bytesdone); 907 + _gcm_sg_unmap_and_advance(gw, bytesdone, false); 901 908 902 909 return bytesdone; 903 910 } ··· 915 922 return i; 916 923 n = min(gw->walk_bytes, bytesdone - i); 917 924 memcpy(gw->walk_ptr, gw->buf + i, n); 918 - _gcm_sg_unmap_and_advance(gw, n); 925 + _gcm_sg_unmap_and_advance(gw, n, true); 919 926 } 920 927 } else 921 - _gcm_sg_unmap_and_advance(gw, bytesdone); 928 + _gcm_sg_unmap_and_advance(gw, bytesdone, true); 922 929 923 930 return bytesdone; 924 931 }