hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/crypto/caam/sg_sw_qm2.h
....@@ -1,35 +1,7 @@
1
+/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
12 /*
23 * Copyright 2015-2016 Freescale Semiconductor, Inc.
34 * Copyright 2017 NXP
4
- *
5
- * Redistribution and use in source and binary forms, with or without
6
- * modification, are permitted provided that the following conditions are met:
7
- * * Redistributions of source code must retain the above copyright
8
- * notice, this list of conditions and the following disclaimer.
9
- * * Redistributions in binary form must reproduce the above copyright
10
- * notice, this list of conditions and the following disclaimer in the
11
- * documentation and/or other materials provided with the distribution.
12
- * * Neither the names of the above-listed copyright holders nor the
13
- * names of any contributors may be used to endorse or promote products
14
- * derived from this software without specific prior written permission.
15
- *
16
- *
17
- * ALTERNATIVELY, this software may be distributed under the terms of the
18
- * GNU General Public License ("GPL") as published by the Free Software
19
- * Foundation, either version 2 of that License or (at your option) any
20
- * later version.
21
- *
22
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
26
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
- * POSSIBILITY OF SUCH DAMAGE.
335 */
346
357 #ifndef _SG_SW_QM2_H_
....@@ -53,15 +25,19 @@
5325 * but does not have final bit; instead, returns last entry
5426 */
5527 static inline struct dpaa2_sg_entry *
56
-sg_to_qm_sg(struct scatterlist *sg, int sg_count,
28
+sg_to_qm_sg(struct scatterlist *sg, int len,
5729 struct dpaa2_sg_entry *qm_sg_ptr, u16 offset)
5830 {
59
- while (sg_count && sg) {
60
- dma_to_qm_sg_one(qm_sg_ptr, sg_dma_address(sg),
61
- sg_dma_len(sg), offset);
31
+ int ent_len;
32
+
33
+ while (len) {
34
+ ent_len = min_t(int, sg_dma_len(sg), len);
35
+
36
+ dma_to_qm_sg_one(qm_sg_ptr, sg_dma_address(sg), ent_len,
37
+ offset);
6238 qm_sg_ptr++;
6339 sg = sg_next(sg);
64
- sg_count--;
40
+ len -= ent_len;
6541 }
6642 return qm_sg_ptr - 1;
6743 }
....@@ -70,11 +46,11 @@
7046 * convert scatterlist to h/w link table format
7147 * scatterlist must have been previously dma mapped
7248 */
73
-static inline void sg_to_qm_sg_last(struct scatterlist *sg, int sg_count,
49
+static inline void sg_to_qm_sg_last(struct scatterlist *sg, int len,
7450 struct dpaa2_sg_entry *qm_sg_ptr,
7551 u16 offset)
7652 {
77
- qm_sg_ptr = sg_to_qm_sg(sg, sg_count, qm_sg_ptr, offset);
53
+ qm_sg_ptr = sg_to_qm_sg(sg, len, qm_sg_ptr, offset);
7854 dpaa2_sg_set_final(qm_sg_ptr, true);
7955 }
8056