hc
2024-01-31 f9004dbfff8a3fbbd7e2a88c8a4327c7f2f8e5b2
kernel/drivers/crypto/img-hash.c
....@@ -1,15 +1,13 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2014 Imagination Technologies
34 * Authors: Will Thomas, James Hartley
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License version 2 as published
7
- * by the Free Software Foundation.
85 *
96 * Interface structure taken from omap-sham driver
107 */
118
129 #include <linux/clk.h>
10
+#include <linux/dma-mapping.h>
1311 #include <linux/dmaengine.h>
1412 #include <linux/interrupt.h>
1513 #include <linux/io.h>
....@@ -106,7 +104,7 @@
106104 struct ahash_request fallback_req;
107105
108106 /* Zero length buffer must remain last member of struct */
109
- u8 buffer[0] __aligned(sizeof(u32));
107
+ u8 buffer[] __aligned(sizeof(u32));
110108 };
111109
112110 struct img_hash_ctx {
....@@ -333,12 +331,12 @@
333331 static int img_hash_dma_init(struct img_hash_dev *hdev)
334332 {
335333 struct dma_slave_config dma_conf;
336
- int err = -EINVAL;
334
+ int err;
337335
338
- hdev->dma_lch = dma_request_slave_channel(hdev->dev, "tx");
339
- if (!hdev->dma_lch) {
336
+ hdev->dma_lch = dma_request_chan(hdev->dev, "tx");
337
+ if (IS_ERR(hdev->dma_lch)) {
340338 dev_err(hdev->dev, "Couldn't acquire a slave DMA channel.\n");
341
- return -EBUSY;
339
+ return PTR_ERR(hdev->dma_lch);
342340 }
343341 dma_conf.direction = DMA_MEM_TO_DEV;
344342 dma_conf.dst_addr = hdev->bus_addr;
....@@ -359,12 +357,16 @@
359357 static void img_hash_dma_task(unsigned long d)
360358 {
361359 struct img_hash_dev *hdev = (struct img_hash_dev *)d;
362
- struct img_hash_request_ctx *ctx = ahash_request_ctx(hdev->req);
360
+ struct img_hash_request_ctx *ctx;
363361 u8 *addr;
364362 size_t nbytes, bleft, wsend, len, tbc;
365363 struct scatterlist tsg;
366364
367
- if (!hdev->req || !ctx->sg)
365
+ if (!hdev->req)
366
+ return;
367
+
368
+ ctx = ahash_request_ctx(hdev->req);
369
+ if (!ctx->sg)
368370 return;
369371
370372 addr = sg_virt(ctx->sg);
....@@ -961,9 +963,7 @@
961963 crypto_init_queue(&hdev->queue, IMG_HASH_QUEUE_LENGTH);
962964
963965 /* Register bank */
964
- hash_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
965
-
966
- hdev->io_base = devm_ioremap_resource(dev, hash_res);
966
+ hdev->io_base = devm_platform_ioremap_resource(pdev, 0);
967967 if (IS_ERR(hdev->io_base)) {
968968 err = PTR_ERR(hdev->io_base);
969969 dev_err(dev, "can't ioremap, returned %d\n", err);
....@@ -983,7 +983,6 @@
983983
984984 irq = platform_get_irq(pdev, 0);
985985 if (irq < 0) {
986
- dev_err(dev, "no IRQ resource info\n");
987986 err = irq;
988987 goto res_err;
989988 }