hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/crypto/caam/sg_sw_qm.h
....@@ -1,34 +1,7 @@
1
+/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
12 /*
23 * Copyright 2013-2016 Freescale Semiconductor, Inc.
34 * Copyright 2016-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 name of Freescale Semiconductor nor the
13
- * names of its 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 Freescale Semiconductor ``AS IS'' AND ANY
23
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25
- * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
26
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
325 */
336
347 #ifndef __SG_SW_QM_H
....@@ -81,15 +54,19 @@
8154 * but does not have final bit; instead, returns last entry
8255 */
8356 static inline struct qm_sg_entry *
84
-sg_to_qm_sg(struct scatterlist *sg, int sg_count,
57
+sg_to_qm_sg(struct scatterlist *sg, int len,
8558 struct qm_sg_entry *qm_sg_ptr, u16 offset)
8659 {
87
- while (sg_count && sg) {
88
- dma_to_qm_sg_one(qm_sg_ptr, sg_dma_address(sg),
89
- sg_dma_len(sg), offset);
60
+ int ent_len;
61
+
62
+ while (len) {
63
+ ent_len = min_t(int, sg_dma_len(sg), len);
64
+
65
+ dma_to_qm_sg_one(qm_sg_ptr, sg_dma_address(sg), ent_len,
66
+ offset);
9067 qm_sg_ptr++;
9168 sg = sg_next(sg);
92
- sg_count--;
69
+ len -= ent_len;
9370 }
9471 return qm_sg_ptr - 1;
9572 }
....@@ -98,10 +75,10 @@
9875 * convert scatterlist to h/w link table format
9976 * scatterlist must have been previously dma mapped
10077 */
101
-static inline void sg_to_qm_sg_last(struct scatterlist *sg, int sg_count,
78
+static inline void sg_to_qm_sg_last(struct scatterlist *sg, int len,
10279 struct qm_sg_entry *qm_sg_ptr, u16 offset)
10380 {
104
- qm_sg_ptr = sg_to_qm_sg(sg, sg_count, qm_sg_ptr, offset);
81
+ qm_sg_ptr = sg_to_qm_sg(sg, len, qm_sg_ptr, offset);
10582 qm_sg_entry_set_f(qm_sg_ptr, qm_sg_entry_get_len(qm_sg_ptr));
10683 }
10784