Skip to content

Commit 478cc2f

Browse files
Yang Yingliangbroonie
authored andcommitted
spi: xtensa-xtfpga: 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]> Tested-by: Max Filippov <[email protected]> Acked-by: Max Filippov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 077dac3 commit 478cc2f

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

drivers/spi/spi-xtensa-xtfpga.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static int xtfpga_spi_probe(struct platform_device *pdev)
8383
int ret;
8484
struct spi_master *master;
8585

86-
master = spi_alloc_master(&pdev->dev, sizeof(struct xtfpga_spi));
86+
master = devm_spi_alloc_master(&pdev->dev, sizeof(struct xtfpga_spi));
8787
if (!master)
8888
return -ENOMEM;
8989

@@ -97,30 +97,24 @@ static int xtfpga_spi_probe(struct platform_device *pdev)
9797
xspi->bitbang.chipselect = xtfpga_spi_chipselect;
9898
xspi->bitbang.txrx_word[SPI_MODE_0] = xtfpga_spi_txrx_word;
9999
xspi->regs = devm_platform_ioremap_resource(pdev, 0);
100-
if (IS_ERR(xspi->regs)) {
101-
ret = PTR_ERR(xspi->regs);
102-
goto err;
103-
}
100+
if (IS_ERR(xspi->regs))
101+
return PTR_ERR(xspi->regs);
104102

105103
xtfpga_spi_write32(xspi, XTFPGA_SPI_START, 0);
106104
usleep_range(1000, 2000);
107105
if (xtfpga_spi_read32(xspi, XTFPGA_SPI_BUSY)) {
108106
dev_err(&pdev->dev, "Device stuck in busy state\n");
109-
ret = -EBUSY;
110-
goto err;
107+
return -EBUSY;
111108
}
112109

113110
ret = spi_bitbang_start(&xspi->bitbang);
114111
if (ret < 0) {
115112
dev_err(&pdev->dev, "spi_bitbang_start failed\n");
116-
goto err;
113+
return ret;
117114
}
118115

119116
platform_set_drvdata(pdev, master);
120117
return 0;
121-
err:
122-
spi_master_put(master);
123-
return ret;
124118
}
125119

126120
static int xtfpga_spi_remove(struct platform_device *pdev)

0 commit comments

Comments
 (0)