Skip to content

Commit 646ff78

Browse files
jhovoldvinodkoul
authored andcommitted
dmaengine: ti: dma-crossbar: clean up dra7x route allocation error paths
Use a common exit path to drop the cross platform device reference on errors for consistency with am335x. Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20251117161258.10679-16-johan@kernel.org Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 4fc17b1 commit 646ff78

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

drivers/dma/ti/dma-crossbar.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -245,28 +245,26 @@ static void *ti_dra7_xbar_route_allocate(struct of_phandle_args *dma_spec,
245245
{
246246
struct platform_device *pdev = of_find_device_by_node(ofdma->of_node);
247247
struct ti_dra7_xbar_data *xbar = platform_get_drvdata(pdev);
248-
struct ti_dra7_xbar_map *map;
248+
struct ti_dra7_xbar_map *map = ERR_PTR(-EINVAL);
249249

250250
if (dma_spec->args[0] >= xbar->xbar_requests) {
251251
dev_err(&pdev->dev, "Invalid XBAR request number: %d\n",
252252
dma_spec->args[0]);
253-
put_device(&pdev->dev);
254-
return ERR_PTR(-EINVAL);
253+
goto out_put_pdev;
255254
}
256255

257256
/* The of_node_put() will be done in the core for the node */
258257
dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
259258
if (!dma_spec->np) {
260259
dev_err(&pdev->dev, "Can't get DMA master\n");
261-
put_device(&pdev->dev);
262-
return ERR_PTR(-EINVAL);
260+
goto out_put_pdev;
263261
}
264262

265263
map = kzalloc(sizeof(*map), GFP_KERNEL);
266264
if (!map) {
267265
of_node_put(dma_spec->np);
268-
put_device(&pdev->dev);
269-
return ERR_PTR(-ENOMEM);
266+
map = ERR_PTR(-ENOMEM);
267+
goto out_put_pdev;
270268
}
271269

272270
mutex_lock(&xbar->mutex);
@@ -277,8 +275,8 @@ static void *ti_dra7_xbar_route_allocate(struct of_phandle_args *dma_spec,
277275
dev_err(&pdev->dev, "Run out of free DMA requests\n");
278276
kfree(map);
279277
of_node_put(dma_spec->np);
280-
put_device(&pdev->dev);
281-
return ERR_PTR(-ENOMEM);
278+
map = ERR_PTR(-ENOMEM);
279+
goto out_put_pdev;
282280
}
283281
set_bit(map->xbar_out, xbar->dma_inuse);
284282
mutex_unlock(&xbar->mutex);
@@ -292,6 +290,7 @@ static void *ti_dra7_xbar_route_allocate(struct of_phandle_args *dma_spec,
292290

293291
ti_dra7_xbar_write(xbar->iomem, map->xbar_out, map->xbar_in);
294292

293+
out_put_pdev:
295294
put_device(&pdev->dev);
296295

297296
return map;

0 commit comments

Comments
 (0)