.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) 2014 Imagination Technologies |
---|
3 | 4 | * 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. |
---|
8 | 5 | * |
---|
9 | 6 | * Interface structure taken from omap-sham driver |
---|
10 | 7 | */ |
---|
11 | 8 | |
---|
12 | 9 | #include <linux/clk.h> |
---|
| 10 | +#include <linux/dma-mapping.h> |
---|
13 | 11 | #include <linux/dmaengine.h> |
---|
14 | 12 | #include <linux/interrupt.h> |
---|
15 | 13 | #include <linux/io.h> |
---|
.. | .. |
---|
106 | 104 | struct ahash_request fallback_req; |
---|
107 | 105 | |
---|
108 | 106 | /* Zero length buffer must remain last member of struct */ |
---|
109 | | - u8 buffer[0] __aligned(sizeof(u32)); |
---|
| 107 | + u8 buffer[] __aligned(sizeof(u32)); |
---|
110 | 108 | }; |
---|
111 | 109 | |
---|
112 | 110 | struct img_hash_ctx { |
---|
.. | .. |
---|
333 | 331 | static int img_hash_dma_init(struct img_hash_dev *hdev) |
---|
334 | 332 | { |
---|
335 | 333 | struct dma_slave_config dma_conf; |
---|
336 | | - int err = -EINVAL; |
---|
| 334 | + int err; |
---|
337 | 335 | |
---|
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)) { |
---|
340 | 338 | dev_err(hdev->dev, "Couldn't acquire a slave DMA channel.\n"); |
---|
341 | | - return -EBUSY; |
---|
| 339 | + return PTR_ERR(hdev->dma_lch); |
---|
342 | 340 | } |
---|
343 | 341 | dma_conf.direction = DMA_MEM_TO_DEV; |
---|
344 | 342 | dma_conf.dst_addr = hdev->bus_addr; |
---|
.. | .. |
---|
359 | 357 | static void img_hash_dma_task(unsigned long d) |
---|
360 | 358 | { |
---|
361 | 359 | 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; |
---|
363 | 361 | u8 *addr; |
---|
364 | 362 | size_t nbytes, bleft, wsend, len, tbc; |
---|
365 | 363 | struct scatterlist tsg; |
---|
366 | 364 | |
---|
367 | | - if (!hdev->req || !ctx->sg) |
---|
| 365 | + if (!hdev->req) |
---|
| 366 | + return; |
---|
| 367 | + |
---|
| 368 | + ctx = ahash_request_ctx(hdev->req); |
---|
| 369 | + if (!ctx->sg) |
---|
368 | 370 | return; |
---|
369 | 371 | |
---|
370 | 372 | addr = sg_virt(ctx->sg); |
---|
.. | .. |
---|
961 | 963 | crypto_init_queue(&hdev->queue, IMG_HASH_QUEUE_LENGTH); |
---|
962 | 964 | |
---|
963 | 965 | /* 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); |
---|
967 | 967 | if (IS_ERR(hdev->io_base)) { |
---|
968 | 968 | err = PTR_ERR(hdev->io_base); |
---|
969 | 969 | dev_err(dev, "can't ioremap, returned %d\n", err); |
---|
.. | .. |
---|
983 | 983 | |
---|
984 | 984 | irq = platform_get_irq(pdev, 0); |
---|
985 | 985 | if (irq < 0) { |
---|
986 | | - dev_err(dev, "no IRQ resource info\n"); |
---|
987 | 986 | err = irq; |
---|
988 | 987 | goto res_err; |
---|
989 | 988 | } |
---|