Skip to content

Commit 2555691

Browse files
Bence Csókásbroonie
authored andcommitted
spi: atmel-quadspi: Use devm_dma_request_chan()
Leave releasing of DMA channels up to the devm facilities. This way we can eliminate the rest of the "goto ladder". Signed-off-by: Bence Csókás <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 08bf166 commit 2555691

File tree

1 file changed

+13
-35
lines changed

1 file changed

+13
-35
lines changed

drivers/spi/atmel-quadspi.c

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,18 +1285,21 @@ static int atmel_qspi_dma_init(struct spi_controller *ctrl)
12851285
struct atmel_qspi *aq = spi_controller_get_devdata(ctrl);
12861286
int ret;
12871287

1288-
aq->rx_chan = dma_request_chan(&aq->pdev->dev, "rx");
1288+
aq->rx_chan = devm_dma_request_chan(&aq->pdev->dev, "rx");
12891289
if (IS_ERR(aq->rx_chan)) {
12901290
ret = dev_err_probe(&aq->pdev->dev, PTR_ERR(aq->rx_chan),
12911291
"RX DMA channel is not available\n");
1292-
goto null_rx_chan;
1292+
aq->rx_chan = NULL;
1293+
return ret;
12931294
}
12941295

1295-
aq->tx_chan = dma_request_chan(&aq->pdev->dev, "tx");
1296+
aq->tx_chan = devm_dma_request_chan(&aq->pdev->dev, "tx");
12961297
if (IS_ERR(aq->tx_chan)) {
12971298
ret = dev_err_probe(&aq->pdev->dev, PTR_ERR(aq->tx_chan),
12981299
"TX DMA channel is not available\n");
1299-
goto release_rx_chan;
1300+
aq->rx_chan = NULL;
1301+
aq->tx_chan = NULL;
1302+
return ret;
13001303
}
13011304

13021305
ctrl->dma_rx = aq->rx_chan;
@@ -1307,21 +1310,6 @@ static int atmel_qspi_dma_init(struct spi_controller *ctrl)
13071310
dma_chan_name(aq->tx_chan), dma_chan_name(aq->rx_chan));
13081311

13091312
return 0;
1310-
1311-
release_rx_chan:
1312-
dma_release_channel(aq->rx_chan);
1313-
aq->tx_chan = NULL;
1314-
null_rx_chan:
1315-
aq->rx_chan = NULL;
1316-
return ret;
1317-
}
1318-
1319-
static void atmel_qspi_dma_release(struct atmel_qspi *aq)
1320-
{
1321-
if (aq->rx_chan)
1322-
dma_release_channel(aq->rx_chan);
1323-
if (aq->tx_chan)
1324-
dma_release_channel(aq->tx_chan);
13251313
}
13261314

13271315
static const struct atmel_qspi_ops atmel_qspi_ops = {
@@ -1426,14 +1414,13 @@ static int atmel_qspi_probe(struct platform_device *pdev)
14261414

14271415
/* Request the IRQ */
14281416
irq = platform_get_irq(pdev, 0);
1429-
if (irq < 0) {
1430-
err = irq;
1431-
goto dma_release;
1432-
}
1417+
if (irq < 0)
1418+
return irq;
1419+
14331420
err = devm_request_irq(&pdev->dev, irq, atmel_qspi_interrupt,
14341421
0, dev_name(&pdev->dev), aq);
14351422
if (err)
1436-
goto dma_release;
1423+
return err;
14371424

14381425
pm_runtime_set_autosuspend_delay(&pdev->dev, 500);
14391426
pm_runtime_use_autosuspend(&pdev->dev);
@@ -1442,22 +1429,16 @@ static int atmel_qspi_probe(struct platform_device *pdev)
14421429

14431430
err = atmel_qspi_init(aq);
14441431
if (err)
1445-
goto dma_release;
1432+
return err;
14461433

14471434
err = spi_register_controller(ctrl);
14481435
if (err)
1449-
goto dma_release;
1436+
return err;
14501437

14511438
pm_runtime_mark_last_busy(&pdev->dev);
14521439
pm_runtime_put_autosuspend(&pdev->dev);
14531440

14541441
return 0;
1455-
1456-
dma_release:
1457-
if (aq->caps->has_dma)
1458-
atmel_qspi_dma_release(aq);
1459-
1460-
return err;
14611442
}
14621443

14631444
static int atmel_qspi_sama7g5_suspend(struct atmel_qspi *aq)
@@ -1507,9 +1488,6 @@ static void atmel_qspi_remove(struct platform_device *pdev)
15071488

15081489
ret = pm_runtime_get_sync(&pdev->dev);
15091490
if (ret >= 0) {
1510-
if (aq->caps->has_dma)
1511-
atmel_qspi_dma_release(aq);
1512-
15131491
if (aq->caps->has_gclk) {
15141492
ret = atmel_qspi_sama7g5_suspend(aq);
15151493
if (ret)

0 commit comments

Comments
 (0)