hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/dma/st_fdma.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * DMA driver for STMicroelectronics STi FDMA controller
34 *
....@@ -5,11 +6,6 @@
56 *
67 * Author: Ludovic Barre <Ludovic.barre@st.com>
78 * Peter Griffin <peter.griffin@linaro.org>
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version.
139 */
1410
1511 #include <linux/init.h>
....@@ -19,6 +15,7 @@
1915 #include <linux/platform_device.h>
2016 #include <linux/interrupt.h>
2117 #include <linux/remoteproc.h>
18
+#include <linux/slab.h>
2219
2320 #include "st_fdma.h"
2421
....@@ -243,8 +240,7 @@
243240 struct st_fdma_desc *fdesc;
244241 int i;
245242
246
- fdesc = kzalloc(sizeof(*fdesc) +
247
- sizeof(struct st_fdma_sw_node) * sg_len, GFP_NOWAIT);
243
+ fdesc = kzalloc(struct_size(fdesc, node, sg_len), GFP_NOWAIT);
248244 if (!fdesc)
249245 return NULL;
250246
....@@ -293,8 +289,6 @@
293289 struct st_fdma_chan *fchan = to_st_fdma_chan(chan);
294290 struct rproc *rproc = fchan->fdev->slim_rproc->rproc;
295291 unsigned long flags;
296
-
297
- LIST_HEAD(head);
298292
299293 dev_dbg(fchan->fdev->dev, "%s: freeing chan:%d\n",
300294 __func__, fchan->vchan.chan.chan_id);
....@@ -626,7 +620,6 @@
626620 static int st_fdma_pause(struct dma_chan *chan)
627621 {
628622 unsigned long flags;
629
- LIST_HEAD(head);
630623 struct st_fdma_chan *fchan = to_st_fdma_chan(chan);
631624 int ch_id = fchan->vchan.chan.chan_id;
632625 unsigned long cmd = FDMA_CMD_PAUSE(ch_id);
....@@ -779,10 +772,8 @@
779772 platform_set_drvdata(pdev, fdev);
780773
781774 fdev->irq = platform_get_irq(pdev, 0);
782
- if (fdev->irq < 0) {
783
- dev_err(&pdev->dev, "Failed to get irq resource\n");
775
+ if (fdev->irq < 0)
784776 return -EINVAL;
785
- }
786777
787778 ret = devm_request_irq(&pdev->dev, fdev->irq, st_fdma_irq_handler, 0,
788779 dev_name(&pdev->dev), fdev);
....@@ -833,7 +824,7 @@
833824 fdev->dma_device.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
834825 fdev->dma_device.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
835826
836
- ret = dma_async_device_register(&fdev->dma_device);
827
+ ret = dmaenginem_async_device_register(&fdev->dma_device);
837828 if (ret) {
838829 dev_err(&pdev->dev,
839830 "Failed to register DMA device (%d)\n", ret);
....@@ -844,15 +835,13 @@
844835 if (ret) {
845836 dev_err(&pdev->dev,
846837 "Failed to register controller (%d)\n", ret);
847
- goto err_dma_dev;
838
+ goto err_rproc;
848839 }
849840
850841 dev_info(&pdev->dev, "ST FDMA engine driver, irq:%d\n", fdev->irq);
851842
852843 return 0;
853844
854
-err_dma_dev:
855
- dma_async_device_unregister(&fdev->dma_device);
856845 err_rproc:
857846 st_fdma_free(fdev);
858847 st_slim_rproc_put(fdev->slim_rproc);
....@@ -867,7 +856,6 @@
867856 devm_free_irq(&pdev->dev, fdev->irq, fdev);
868857 st_slim_rproc_put(fdev->slim_rproc);
869858 of_dma_controller_free(pdev->dev.of_node);
870
- dma_async_device_unregister(&fdev->dma_device);
871859
872860 return 0;
873861 }