summaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorYang Yingliang <yangyingliang@huawei.com>2022-09-20 19:44:48 +0800
committerMark Brown <broonie@kernel.org>2022-09-22 14:39:50 +0100
commit478cc2fc3dd782f7935bc0ab84c198691ea83fa3 (patch)
tree459c29ef330dc8593dbb1fe137b1efa219f0ba07 /drivers/spi
parent077dac343b54babfd56b1a52cf1f091518118957 (diff)
downloadlinux-stable-478cc2fc3dd782f7935bc0ab84c198691ea83fa3.tar.gz
linux-stable-478cc2fc3dd782f7935bc0ab84c198691ea83fa3.tar.bz2
linux-stable-478cc2fc3dd782f7935bc0ab84c198691ea83fa3.zip
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 <yangyingliang@huawei.com> Tested-by: Max Filippov <jcmvbkbc@gmail.com> Acked-by: Max Filippov <jcmvbkbc@gmail.com> Link: https://lore.kernel.org/r/20220920114448.2681053-1-yangyingliang@huawei.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-xtensa-xtfpga.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/spi/spi-xtensa-xtfpga.c b/drivers/spi/spi-xtensa-xtfpga.c
index fc2b5eb7d614..2fa7608f94cd 100644
--- a/drivers/spi/spi-xtensa-xtfpga.c
+++ b/drivers/spi/spi-xtensa-xtfpga.c
@@ -83,7 +83,7 @@ static int xtfpga_spi_probe(struct platform_device *pdev)
int ret;
struct spi_master *master;
- master = spi_alloc_master(&pdev->dev, sizeof(struct xtfpga_spi));
+ master = devm_spi_alloc_master(&pdev->dev, sizeof(struct xtfpga_spi));
if (!master)
return -ENOMEM;
@@ -97,30 +97,24 @@ static int xtfpga_spi_probe(struct platform_device *pdev)
xspi->bitbang.chipselect = xtfpga_spi_chipselect;
xspi->bitbang.txrx_word[SPI_MODE_0] = xtfpga_spi_txrx_word;
xspi->regs = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(xspi->regs)) {
- ret = PTR_ERR(xspi->regs);
- goto err;
- }
+ if (IS_ERR(xspi->regs))
+ return PTR_ERR(xspi->regs);
xtfpga_spi_write32(xspi, XTFPGA_SPI_START, 0);
usleep_range(1000, 2000);
if (xtfpga_spi_read32(xspi, XTFPGA_SPI_BUSY)) {
dev_err(&pdev->dev, "Device stuck in busy state\n");
- ret = -EBUSY;
- goto err;
+ return -EBUSY;
}
ret = spi_bitbang_start(&xspi->bitbang);
if (ret < 0) {
dev_err(&pdev->dev, "spi_bitbang_start failed\n");
- goto err;
+ return ret;
}
platform_set_drvdata(pdev, master);
return 0;
-err:
- spi_master_put(master);
- return ret;
}
static int xtfpga_spi_remove(struct platform_device *pdev)