forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/drivers/dma/ti/dma-crossbar.c
....@@ -1,11 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com
34 * Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
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
7
- * published by the Free Software Foundation.
8
- *
95 */
106 #include <linux/slab.h>
117 #include <linux/err.h>
....@@ -137,7 +133,6 @@
137133 const struct of_device_id *match;
138134 struct device_node *dma_node;
139135 struct ti_am335x_xbar_data *xbar;
140
- struct resource *res;
141136 void __iomem *iomem;
142137 int i, ret;
143138
....@@ -177,8 +172,7 @@
177172 xbar->xbar_events = TI_AM335X_XBAR_LINES;
178173 }
179174
180
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
181
- iomem = devm_ioremap_resource(&pdev->dev, res);
175
+ iomem = devm_platform_ioremap_resource(pdev, 0);
182176 if (IS_ERR(iomem))
183177 return PTR_ERR(iomem);
184178
....@@ -251,6 +245,7 @@
251245 if (dma_spec->args[0] >= xbar->xbar_requests) {
252246 dev_err(&pdev->dev, "Invalid XBAR request number: %d\n",
253247 dma_spec->args[0]);
248
+ put_device(&pdev->dev);
254249 return ERR_PTR(-EINVAL);
255250 }
256251
....@@ -258,12 +253,14 @@
258253 dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
259254 if (!dma_spec->np) {
260255 dev_err(&pdev->dev, "Can't get DMA master\n");
256
+ put_device(&pdev->dev);
261257 return ERR_PTR(-EINVAL);
262258 }
263259
264260 map = kzalloc(sizeof(*map), GFP_KERNEL);
265261 if (!map) {
266262 of_node_put(dma_spec->np);
263
+ put_device(&pdev->dev);
267264 return ERR_PTR(-ENOMEM);
268265 }
269266
....@@ -274,6 +271,8 @@
274271 mutex_unlock(&xbar->mutex);
275272 dev_err(&pdev->dev, "Run out of free DMA requests\n");
276273 kfree(map);
274
+ of_node_put(dma_spec->np);
275
+ put_device(&pdev->dev);
277276 return ERR_PTR(-ENOMEM);
278277 }
279278 set_bit(map->xbar_out, xbar->dma_inuse);
....@@ -327,7 +326,6 @@
327326 struct device_node *dma_node;
328327 struct ti_dra7_xbar_data *xbar;
329328 struct property *prop;
330
- struct resource *res;
331329 u32 safe_val;
332330 int sz;
333331 void __iomem *iomem;
....@@ -407,8 +405,7 @@
407405 kfree(rsv_events);
408406 }
409407
410
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
411
- iomem = devm_ioremap_resource(&pdev->dev, res);
408
+ iomem = devm_platform_ioremap_resource(pdev, 0);
412409 if (IS_ERR(iomem))
413410 return PTR_ERR(iomem);
414411