[PATCH -next 5/6] spi: sh-sci: Switch to use devm_spi_alloc_master()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Switch to use devm_spi_alloc_master() to simpify error path.

Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
---
 drivers/spi/spi-sh-sci.c | 34 +++++++++++++---------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/drivers/spi/spi-sh-sci.c b/drivers/spi/spi-sh-sci.c
index 8f30531e1418..2cd5cd23e37c 100644
--- a/drivers/spi/spi-sh-sci.c
+++ b/drivers/spi/spi-sh-sci.c
@@ -118,11 +118,10 @@ static int sh_sci_spi_probe(struct platform_device *dev)
 	struct sh_sci_spi *sp;
 	int ret;
 
-	master = spi_alloc_master(&dev->dev, sizeof(struct sh_sci_spi));
+	master = devm_spi_alloc_master(&dev->dev, sizeof(struct sh_sci_spi));
 	if (master == NULL) {
 		dev_err(&dev->dev, "failed to allocate spi master\n");
-		ret = -ENOMEM;
-		goto err0;
+		return -ENOMEM;
 	}
 
 	sp = spi_master_get_devdata(master);
@@ -131,8 +130,7 @@ static int sh_sci_spi_probe(struct platform_device *dev)
 	sp->info = dev_get_platdata(&dev->dev);
 	if (!sp->info) {
 		dev_err(&dev->dev, "platform data is missing\n");
-		ret = -ENOENT;
-		goto err1;
+		return -ENOENT;
 	}
 
 	/* setup spi bitbang adaptor */
@@ -147,28 +145,22 @@ static int sh_sci_spi_probe(struct platform_device *dev)
 	sp->bitbang.txrx_word[SPI_MODE_3] = sh_sci_spi_txrx_mode3;
 
 	r = platform_get_resource(dev, IORESOURCE_MEM, 0);
-	if (r == NULL) {
-		ret = -ENOENT;
-		goto err1;
-	}
+	if (r == NULL)
+		return -ENOENT;
 	sp->membase = ioremap(r->start, resource_size(r));
-	if (!sp->membase) {
-		ret = -ENXIO;
-		goto err1;
-	}
+	if (!sp->membase)
+		return -ENXIO;
 	sp->val = ioread8(SCSPTR(sp));
 	setbits(sp, PIN_INIT, 1);
 
 	ret = spi_bitbang_start(&sp->bitbang);
-	if (!ret)
-		return 0;
+	if (ret) {
+		setbits(sp, PIN_INIT, 0);
+		iounmap(sp->membase);
+		return ret;
+	}
 
-	setbits(sp, PIN_INIT, 0);
-	iounmap(sp->membase);
- err1:
-	spi_master_put(sp->bitbang.master);
- err0:
-	return ret;
+	return 0;
 }
 
 static int sh_sci_spi_remove(struct platform_device *dev)
-- 
2.25.1




[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux