Skip to content

Commit 2d06458

Browse files
Yang Yingliangbroonie
authored andcommitted
spi: xilinx: Switch to use devm_spi_alloc_master()
Switch to use devm_spi_alloc_master() to simpify error path. Signed-off-by: Yang Yingliang <[email protected]> Reviewed-by: Lukas Wunner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent c79ce0a commit 2d06458

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

drivers/spi/spi-xilinx.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ static int xilinx_spi_probe(struct platform_device *pdev)
421421
return -EINVAL;
422422
}
423423

424-
master = spi_alloc_master(&pdev->dev, sizeof(struct xilinx_spi));
424+
master = devm_spi_alloc_master(&pdev->dev, sizeof(struct xilinx_spi));
425425
if (!master)
426426
return -ENODEV;
427427

@@ -439,10 +439,8 @@ static int xilinx_spi_probe(struct platform_device *pdev)
439439

440440
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
441441
xspi->regs = devm_ioremap_resource(&pdev->dev, res);
442-
if (IS_ERR(xspi->regs)) {
443-
ret = PTR_ERR(xspi->regs);
444-
goto put_master;
445-
}
442+
if (IS_ERR(xspi->regs))
443+
return PTR_ERR(xspi->regs);
446444

447445
master->bus_num = pdev->id;
448446
master->num_chipselect = num_cs;
@@ -472,14 +470,13 @@ static int xilinx_spi_probe(struct platform_device *pdev)
472470

473471
xspi->irq = platform_get_irq(pdev, 0);
474472
if (xspi->irq < 0 && xspi->irq != -ENXIO) {
475-
ret = xspi->irq;
476-
goto put_master;
473+
return xspi->irq;
477474
} else if (xspi->irq >= 0) {
478475
/* Register for SPI Interrupt */
479476
ret = devm_request_irq(&pdev->dev, xspi->irq, xilinx_spi_irq, 0,
480477
dev_name(&pdev->dev), xspi);
481478
if (ret)
482-
goto put_master;
479+
return ret;
483480
}
484481

485482
/* SPI controller initializations */
@@ -488,7 +485,7 @@ static int xilinx_spi_probe(struct platform_device *pdev)
488485
ret = spi_bitbang_start(&xspi->bitbang);
489486
if (ret) {
490487
dev_err(&pdev->dev, "spi_bitbang_start FAILED\n");
491-
goto put_master;
488+
return ret;
492489
}
493490

494491
dev_info(&pdev->dev, "at %pR, irq=%d\n", res, xspi->irq);
@@ -500,11 +497,6 @@ static int xilinx_spi_probe(struct platform_device *pdev)
500497

501498
platform_set_drvdata(pdev, master);
502499
return 0;
503-
504-
put_master:
505-
spi_master_put(master);
506-
507-
return ret;
508500
}
509501

510502
static int xilinx_spi_remove(struct platform_device *pdev)

0 commit comments

Comments
 (0)