Skip to contentSkip to conversation

spi: davinci: Use devm_*() functions

PATCH Applied Jingoo Han 7 participants 31 messages Dec 9, 2013 – Dec 18, 2013 14 messages not in the archive

Subsystems (7)
lore
Share & tools
lore

Jingoo Han

author
#0 lore raw

PATCH 1/11 spi: davinci: Use devm_*() functions

Use devm_*() functions to make cleanup paths simpler.

---
 drivers/spi/spi-davinci.c |   41 +++++++++++------------------------------
 1 file changed, 11 insertions(+), 30 deletions(-)
drivers/spi/spi-davinci.c +11 -30
index d3f6386..79d40c8 100644
@@ -853,7 +853,7 @@ static int davinci_spi_probe(struct platform_device *pdev)
 	struct spi_master *master;
 	struct davinci_spi *dspi;
 	struct davinci_spi_platform_data *pdata;
-	struct resource *r, *mem;
+	struct resource *r;
 	resource_size_t dma_rx_chan = SPI_NO_RESOURCE;
 	resource_size_t	dma_tx_chan = SPI_NO_RESOURCE;
 	int i = 0, ret = 0;
@@ -894,39 +894,33 @@ static int davinci_spi_probe(struct platform_device *pdev)
 
 	dspi->pbase = r->start;
 
-	mem = request_mem_region(r->start, resource_size(r), pdev->name);
-	if (mem == NULL) {
-		ret = -EBUSY;
+	dspi->base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(dspi->base)) {
+		ret = PTR_ERR(dspi->base);
 		goto free_master;
 	}
 
-	dspi->base = ioremap(r->start, resource_size(r));
-	if (dspi->base == NULL) {
-		ret = -ENOMEM;
-		goto release_region;
-	}
-
 	dspi->irq = platform_get_irq(pdev, 0);
 	if (dspi->irq <= 0) {
 		ret = -EINVAL;
-		goto unmap_io;
+		goto free_master;
 	}
 
-	ret = request_threaded_irq(dspi->irq, davinci_spi_irq, dummy_thread_fn,
-				 0, dev_name(&pdev->dev), dspi);
+	ret = devm_request_threaded_irq(&pdev->dev, dspi->irq, davinci_spi_irq,
+				dummy_thread_fn, 0, dev_name(&pdev->dev), dspi);
 	if (ret)
-		goto unmap_io;
+		goto free_master;
 
 	dspi->bitbang.master = master;
 	if (dspi->bitbang.master == NULL) {
 		ret = -ENODEV;
-		goto irq_free;
+		goto free_master;
 	}
 
-	dspi->clk = clk_get(&pdev->dev, NULL);
+	dspi->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(dspi->clk)) {
 		ret = -ENODEV;
-		goto irq_free;
+		goto free_master;
 	}
 	clk_prepare_enable(dspi->clk);
 
@@ -1015,13 +1009,6 @@ free_dma:
 	dma_release_channel(dspi->dma_tx);
 free_clk:
 	clk_disable_unprepare(dspi->clk);
-	clk_put(dspi->clk);
-irq_free:
-	free_irq(dspi->irq, dspi);
-unmap_io:
-	iounmap(dspi->base);
-release_region:
-	release_mem_region(dspi->pbase, resource_size(r));
 free_master:
 	spi_master_put(master);
 err:
@@ -1041,7 +1028,6 @@ static int davinci_spi_remove(struct platform_device *pdev)
 {
 	struct davinci_spi *dspi;
 	struct spi_master *master;
-	struct resource *r;
 
 	master = platform_get_drvdata(pdev);
 	dspi = spi_master_get_devdata(master);
@@ -1049,11 +1035,6 @@ static int davinci_spi_remove(struct platform_device *pdev)
 	spi_bitbang_stop(&dspi->bitbang);
 
 	clk_disable_unprepare(dspi->clk);
-	clk_put(dspi->clk);
-	free_irq(dspi->irq, dspi);
-	iounmap(dspi->base);
-	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	release_mem_region(dspi->pbase, resource_size(r));
 	spi_master_put(master);
 
 	return 0;
Signature · 7 lines
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 000801cef4c7$1b84a470$528ded50$%[email protected]

author
#2 lore raw

PATCH 2/11 spi: mpc512x: Use devm_*() functions

Use devm_*() functions to make cleanup paths simpler.

---
 drivers/spi/spi-mpc512x-psc.c |   17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/spi/spi-mpc512x-psc.c +5 -12
index 2babea2..77c03e2 100644
@@ -503,7 +503,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
 	master->cleanup = mpc512x_psc_spi_cleanup;
 	master->dev.of_node = dev->of_node;
 
-	tempp = ioremap(regaddr, size);
+	tempp = devm_ioremap(dev, regaddr, size);
 	if (!tempp) {
 		dev_err(dev, "could not ioremap I/O port range\n");
 		ret = -EFAULT;
@@ -513,8 +513,8 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
 	mps->fifo =
 		(struct mpc512x_psc_fifo *)(tempp + sizeof(struct mpc52xx_psc));
 
-	ret = request_irq(mps->irq, mpc512x_psc_spi_isr, IRQF_SHARED,
-			  "mpc512x-psc-spi", mps);
+	ret = devm_request_irq(dev, mps->irq, mpc512x_psc_spi_isr, IRQF_SHARED,
+				"mpc512x-psc-spi", mps);
 	if (ret)
 		goto free_master;
 	init_completion(&mps->txisrdone);
@@ -522,11 +522,11 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
 	clk = devm_clk_get(dev, "mclk");
 	if (IS_ERR(clk)) {
 		ret = PTR_ERR(clk);
-		goto free_irq;
+		goto free_master;
 	}
 	ret = clk_prepare_enable(clk);
 	if (ret)
-		goto free_irq;
+		goto free_master;
 	mps->clk_mclk = clk;
 	mps->mclk_rate = clk_get_rate(clk);
 
@@ -554,11 +554,7 @@ free_ipg_clock:
 	clk_disable_unprepare(mps->clk_ipg);
 free_mclk_clock:
 	clk_disable_unprepare(mps->clk_mclk);
-free_irq:
-	free_irq(mps->irq, mps);
 free_master:
-	if (mps->psc)
-		iounmap(mps->psc);
 	spi_master_put(master);
 
 	return ret;
@@ -571,9 +567,6 @@ static int mpc512x_psc_spi_do_remove(struct device *dev)
 
 	clk_disable_unprepare(mps->clk_mclk);
 	clk_disable_unprepare(mps->clk_ipg);
-	free_irq(mps->irq, mps);
-	if (mps->psc)
-		iounmap(mps->psc);
 
 	return 0;
 }
Signature · 7 lines
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 000e01cef4c7$53d9e060$fb8da120$%[email protected]

#4 lore raw

Re: [PATCH 02/11] spi: mpc512x: Use devm_*() functions

Quoted 22 lines · Jingoo Han

Use devm_*() functions to make cleanup paths simpler.

---
 drivers/spi/spi-mpc512x-psc.c |   17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/spi/spi-mpc512x-psc.c +1 -1
index 2babea2..77c03e2 100644
@@ -503,7 +503,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
 	master->cleanup = mpc512x_psc_spi_cleanup;
 	master->dev.of_node = dev->of_node;
 
-	tempp = ioremap(regaddr, size);
+	tempp = devm_ioremap(dev, regaddr, size);
 	if (!tempp) {
 		dev_err(dev, "could not ioremap I/O port range\n");
 		ret = -EFAULT;

drivers/spi/spi-mpc512x-psc.c static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, · line 520

Quoted 10 lines
drivers/spi/spi-mpc512x-psc.c +2 -2
@@ -513,8 +513,8 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
 	mps->fifo =
 		(struct mpc512x_psc_fifo *)(tempp + sizeof(struct mpc52xx_psc));
 
-	ret = request_irq(mps->irq, mpc512x_psc_spi_isr, IRQF_SHARED,
-			  "mpc512x-psc-spi", mps);
+	ret = devm_request_irq(dev, mps->irq, mpc512x_psc_spi_isr, IRQF_SHARED,
+				"mpc512x-psc-spi", mps);
 	if (ret)
 		goto free_master;
 	init_completion(&mps->txisrdone);

nit: whitespace, indentation of the continued parameter list

everything else looks good (from looking at it, did not build/run-test)

Quoted 38 lines
drivers/spi/spi-mpc512x-psc.c +2 -9
@@ -522,11 +522,11 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
 	clk = devm_clk_get(dev, "mclk");
 	if (IS_ERR(clk)) {
 		ret = PTR_ERR(clk);
-		goto free_irq;
+		goto free_master;
 	}
 	ret = clk_prepare_enable(clk);
 	if (ret)
-		goto free_irq;
+		goto free_master;
 	mps->clk_mclk = clk;
 	mps->mclk_rate = clk_get_rate(clk);
 
@@ -554,11 +554,7 @@ free_ipg_clock:
 	clk_disable_unprepare(mps->clk_ipg);
 free_mclk_clock:
 	clk_disable_unprepare(mps->clk_mclk);
-free_irq:
-	free_irq(mps->irq, mps);
 free_master:
-	if (mps->psc)
-		iounmap(mps->psc);
 	spi_master_put(master);
 
 	return ret;
@@ -571,9 +567,6 @@ static int mpc512x_psc_spi_do_remove(struct device *dev)
 
 	clk_disable_unprepare(mps->clk_mclk);
 	clk_disable_unprepare(mps->clk_ipg);
-	free_irq(mps->irq, mps);
-	if (mps->psc)
-		iounmap(mps->psc);
 
 	return 0;
 }
Signature · 1 line
1.7.10.4

virtually yours
Gerhard Sittig

Signature · 7 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr. 5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: [email protected]
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20131209131213.GL2982-kDjWylLy9wD0K7fsECOQyeGNnDKD8DIp@public.gmane.org

author
#6 lore raw

Re: [PATCH 02/11] spi: mpc512x: Use devm_*() functions

Quoted 26 lines · Gerhard Sittig
Quoted 25 lines · Jingoo Han

Use devm_*() functions to make cleanup paths simpler.

---
 drivers/spi/spi-mpc512x-psc.c |   17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/spi/spi-mpc512x-psc.c +1 -1
index 2babea2..77c03e2 100644
@@ -503,7 +503,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
 	master->cleanup = mpc512x_psc_spi_cleanup;
 	master->dev.of_node = dev->of_node;
 
-	tempp = ioremap(regaddr, size);
+	tempp = devm_ioremap(dev, regaddr, size);
 	if (!tempp) {
 		dev_err(dev, "could not ioremap I/O port range\n");
 		ret = -EFAULT;
@@ -513,8 +513,8 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
 	mps->fifo =
 		(struct mpc512x_psc_fifo *)(tempp + sizeof(struct mpc52xx_psc));
 
Quoted 9 lines

drivers/spi/spi-mpc512x-psc.c static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, · line 520

Quoted 7 lines
drivers/spi/spi-mpc512x-psc.c +2 -2
-	ret = request_irq(mps->irq, mpc512x_psc_spi_isr, IRQF_SHARED,
-			  "mpc512x-psc-spi", mps);
+	ret = devm_request_irq(dev, mps->irq, mpc512x_psc_spi_isr, IRQF_SHARED,
+				"mpc512x-psc-spi", mps);
 	if (ret)
 		goto free_master;
 	init_completion(&mps->txisrdone);

nit: whitespace, indentation of the continued parameter list

Hi Gerhard Sittig,

Sorry, I cannot find the whitespace.
Also, there is no checkpatch warning.
Would you check it again? :-)
Thank you for your feedback.

Best regards,
Jingoo Han

Quoted 2 lines

everything else looks good (from looking at it, did not build/run-test)

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 005601cef54d$7c9b1bf0$75d153d0$%[email protected]

#8 lore raw

Re: [PATCH 02/11] spi: mpc512x: Use devm_*() functions

Quoted 20 lines · Jingoo Han
Quoted 8 lines · Gerhard Sittig
Quoted 1 line · Jingoo Han

[ ... ]

Quoted 4 lines
drivers/spi/spi-mpc512x-psc.c +0 -0
@@ -513,8 +513,8 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
 	mps->fifo =
 		(struct mpc512x_psc_fifo *)(tempp + sizeof(struct mpc52xx_psc));
 
Quoted 9 lines

drivers/spi/spi-mpc512x-psc.c static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, · line 520

Quoted 7 lines
drivers/spi/spi-mpc512x-psc.c +2 -2
-	ret = request_irq(mps->irq, mpc512x_psc_spi_isr, IRQF_SHARED,
-			  "mpc512x-psc-spi", mps);
+	ret = devm_request_irq(dev, mps->irq, mpc512x_psc_spi_isr, IRQF_SHARED,
+				"mpc512x-psc-spi", mps);
 	if (ret)
 		goto free_master;
 	init_completion(&mps->txisrdone);

nit: whitespace, indentation of the continued parameter list

Quoted 6 lines

Hi Gerhard Sittig,

Sorry, I cannot find the whitespace. Also, there is no checkpatch warning. Would you check it again? :-) Thank you for your feedback.

If you look very close at the added lines, you see that the continued line (the opening quote of the string) does not align with the start of the parameter list of the previous line (the 'dev' word). And it appears to not be a false positive due to the use of TABs, as in the above quote the "ret = " starts at position 8 as well.

But as mentioned, it's a nit. And if nobody else objects neither will I. It's just too minor, and does not affect operation.

virtually yours
Gerhard Sittig

Signature · 7 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr. 5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: [email protected]
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#11 lore raw

PATCH v2 1/1 spi: mpc512x: Use devm_*() functions

Use devm_*() functions to make cleanup paths simpler.

---
Re-based on the latest for-next branch of spi tree.

 drivers/spi/spi-mpc512x-psc.c |   18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)
drivers/spi/spi-mpc512x-psc.c +5 -13
index 8767658..46d2313 100644
@@ -504,7 +504,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
 	master->cleanup = mpc512x_psc_spi_cleanup;
 	master->dev.of_node = dev->of_node;
 
-	tempp = ioremap(regaddr, size);
+	tempp = devm_ioremap(dev, regaddr, size);
 	if (!tempp) {
 		dev_err(dev, "could not ioremap I/O port range\n");
 		ret = -EFAULT;
@@ -513,9 +513,8 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
 	mps->psc = tempp;
 	mps->fifo =
 		(struct mpc512x_psc_fifo *)(tempp + sizeof(struct mpc52xx_psc));
-
-	ret = request_irq(mps->irq, mpc512x_psc_spi_isr, IRQF_SHARED,
-			  "mpc512x-psc-spi", mps);
+	ret = devm_request_irq(dev, mps->irq, mpc512x_psc_spi_isr, IRQF_SHARED,
+				"mpc512x-psc-spi", mps);
 	if (ret)
 		goto free_master;
 	init_completion(&mps->txisrdone);
@@ -525,11 +524,11 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
 	clk = devm_clk_get(dev, clk_name);
 	if (IS_ERR(clk)) {
 		ret = PTR_ERR(clk);
-		goto free_irq;
+		goto free_master;
 	}
 	ret = clk_prepare_enable(clk);
 	if (ret)
-		goto free_irq;
+		goto free_master;
 	mps->clk_mclk = clk;
 	mps->mclk_rate = clk_get_rate(clk);
 
@@ -545,11 +544,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
 
 free_clock:
 	clk_disable_unprepare(mps->clk_mclk);
-free_irq:
-	free_irq(mps->irq, mps);
 free_master:
-	if (mps->psc)
-		iounmap(mps->psc);
 	spi_master_put(master);
 
 	return ret;
@@ -561,9 +556,6 @@ static int mpc512x_psc_spi_do_remove(struct device *dev)
 	struct mpc512x_psc_spi *mps = spi_master_get_devdata(master);
 
 	clk_disable_unprepare(mps->clk_mclk);
-	free_irq(mps->irq, mps);
-	if (mps->psc)
-		iounmap(mps->psc);
 
 	return 0;
 }
Signature · 7 lines
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 007001cefb90$d7b07050$871150f0$%[email protected]

author
#14 lore raw

PATCH 3/11 spi: ath79: Use devm_*() functions

In reply to a message not in the archive

Use devm_*() functions to make cleanup paths simpler.

---
 drivers/spi/spi-ath79.c |   14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/spi/spi-ath79.c +4 -10
index 821bf7a..31534b5 100644
@@ -243,21 +243,21 @@ static int ath79_spi_probe(struct platform_device *pdev)
 		goto err_put_master;
 	}
 
-	sp->base = ioremap(r->start, resource_size(r));
+	sp->base = devm_ioremap(&pdev->dev, r->start, resource_size(r));
 	if (!sp->base) {
 		ret = -ENXIO;
 		goto err_put_master;
 	}
 
-	sp->clk = clk_get(&pdev->dev, "ahb");
+	sp->clk = devm_clk_get(&pdev->dev, "ahb");
 	if (IS_ERR(sp->clk)) {
 		ret = PTR_ERR(sp->clk);
-		goto err_unmap;
+		goto err_put_master;
 	}
 
 	ret = clk_enable(sp->clk);
 	if (ret)
-		goto err_clk_put;
+		goto err_put_master;
 
 	rate = DIV_ROUND_UP(clk_get_rate(sp->clk), MHZ);
 	if (!rate) {
@@ -280,10 +280,6 @@ err_disable:
 	ath79_spi_disable(sp);
 err_clk_disable:
 	clk_disable(sp->clk);
-err_clk_put:
-	clk_put(sp->clk);
-err_unmap:
-	iounmap(sp->base);
 err_put_master:
 	spi_master_put(sp->bitbang.master);
 
@@ -297,8 +293,6 @@ static int ath79_spi_remove(struct platform_device *pdev)
 	spi_bitbang_stop(&sp->bitbang);
 	ath79_spi_disable(sp);
 	clk_disable(sp->clk);
-	clk_put(sp->clk);
-	iounmap(sp->base);
 	spi_master_put(sp->bitbang.master);
 
 	return 0;
Signature · 7 lines
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 000f01cef4c7$837d0180$8a770480$%[email protected]

Applied
#16 lore raw

Re: [PATCH 03/11] spi: ath79: Use devm_*() functions

Quoted 1 line · Jingoo Han

Use devm_*() functions to make cleanup paths simpler.

Applied, thanks.

author
#17 lore raw

PATCH 4/11 spi: designware: Use devm_*() functions

In reply to a message not in the archive

Use devm_*() functions to make cleanup paths simpler.

---
 drivers/spi/spi-dw-mmio.c |   57 +++++++++++----------------------------------
 1 file changed, 14 insertions(+), 43 deletions(-)
drivers/spi/spi-dw-mmio.c +14 -43
index 168c620..1107ca9 100644
@@ -30,14 +30,13 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
 {
 	struct dw_spi_mmio *dwsmmio;
 	struct dw_spi *dws;
-	struct resource *mem, *ioarea;
+	struct resource *mem;
 	int ret;
 
-	dwsmmio = kzalloc(sizeof(struct dw_spi_mmio), GFP_KERNEL);
-	if (!dwsmmio) {
-		ret = -ENOMEM;
-		goto err_end;
-	}
+	dwsmmio = devm_kzalloc(&pdev->dev, sizeof(struct dw_spi_mmio),
+				GFP_KERNEL);
+	if (!dwsmmio)
+		return -ENOMEM;
 
 	dws = &dwsmmio->dws;
 
@@ -45,37 +44,23 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!mem) {
 		dev_err(&pdev->dev, "no mem resource?\n");
-		ret = -EINVAL;
-		goto err_kfree;
-	}
-
-	ioarea = request_mem_region(mem->start, resource_size(mem),
-			pdev->name);
-	if (!ioarea) {
-		dev_err(&pdev->dev, "SPI region already claimed\n");
-		ret = -EBUSY;
-		goto err_kfree;
+		return -EINVAL;
 	}
 
-	dws->regs = ioremap_nocache(mem->start, resource_size(mem));
-	if (!dws->regs) {
-		dev_err(&pdev->dev, "SPI region already mapped\n");
-		ret = -ENOMEM;
-		goto err_release_reg;
-	}
+	mem->flags &= ~IORESOURCE_CACHEABLE;
+	dws->regs = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(dws->regs))
+		return PTR_ERR(dws->regs);
 
 	dws->irq = platform_get_irq(pdev, 0);
 	if (dws->irq < 0) {
 		dev_err(&pdev->dev, "no irq resource?\n");
-		ret = dws->irq; /* -ENXIO */
-		goto err_unmap;
+		return dws->irq; /* -ENXIO */
 	}
 
-	dwsmmio->clk = clk_get(&pdev->dev, NULL);
-	if (IS_ERR(dwsmmio->clk)) {
-		ret = PTR_ERR(dwsmmio->clk);
-		goto err_unmap;
-	}
+	dwsmmio->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(dwsmmio->clk))
+		return PTR_ERR(dwsmmio->clk);
 	clk_enable(dwsmmio->clk);
 
 	dws->parent_dev = &pdev->dev;
@@ -92,33 +77,19 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
 
 err_clk:
 	clk_disable(dwsmmio->clk);
-	clk_put(dwsmmio->clk);
 	dwsmmio->clk = NULL;
-err_unmap:
-	iounmap(dws->regs);
-err_release_reg:
-	release_mem_region(mem->start, resource_size(mem));
-err_kfree:
-	kfree(dwsmmio);
-err_end:
 	return ret;
 }
 
 static int dw_spi_mmio_remove(struct platform_device *pdev)
 {
 	struct dw_spi_mmio *dwsmmio = platform_get_drvdata(pdev);
-	struct resource *mem;
 
 	clk_disable(dwsmmio->clk);
-	clk_put(dwsmmio->clk);
 	dwsmmio->clk = NULL;
 
 	dw_spi_remove_host(&dwsmmio->dws);
-	iounmap(dwsmmio->dws.regs);
-	kfree(dwsmmio);
 
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	release_mem_region(mem->start, resource_size(mem));
 	return 0;
 }
 
Signature · 7 lines
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#18 lore raw

PATCH 5/11 spi: nuc900: Use devm_*() functions

In reply to a message not in the archive

Use devm_*() functions to make cleanup paths simpler.

---
 drivers/spi/spi-nuc900.c |   50 ++++++++++------------------------------------
 1 file changed, 10 insertions(+), 40 deletions(-)
drivers/spi/spi-nuc900.c +10 -40
index e0c32bc..43d340c 100644
@@ -57,7 +57,6 @@ struct nuc900_spi {
 	const unsigned char	*tx;
 	unsigned char		*rx;
 	struct clk		*clk;
-	struct resource		*ioarea;
 	struct spi_master	*master;
 	struct spi_device	*curdev;
 	struct device		*dev;
@@ -344,8 +343,7 @@ static int nuc900_spi_probe(struct platform_device *pdev)
 	master = spi_alloc_master(&pdev->dev, sizeof(struct nuc900_spi));
 	if (master == NULL) {
 		dev_err(&pdev->dev, "No memory for spi_master\n");
-		err = -ENOMEM;
-		goto err_nomem;
+		return -ENOMEM;
 	}
 
 	hw = spi_master_get_devdata(master);
@@ -376,40 +374,31 @@ static int nuc900_spi_probe(struct platform_device *pdev)
 		goto err_pdata;
 	}
 
-	hw->ioarea = request_mem_region(hw->res->start,
-					resource_size(hw->res), pdev->name);
-
-	if (hw->ioarea == NULL) {
-		dev_err(&pdev->dev, "Cannot reserve region\n");
-		err = -ENXIO;
+	hw->regs = devm_ioremap_resource(&pdev->dev, hw->res);
+	if (IS_ERR(hw->regs)) {
+		err = PTR_ERR(hw->regs);
 		goto err_pdata;
 	}
 
-	hw->regs = ioremap(hw->res->start, resource_size(hw->res));
-	if (hw->regs == NULL) {
-		dev_err(&pdev->dev, "Cannot map IO\n");
-		err = -ENXIO;
-		goto err_iomap;
-	}
-
 	hw->irq = platform_get_irq(pdev, 0);
 	if (hw->irq < 0) {
 		dev_err(&pdev->dev, "No IRQ specified\n");
 		err = -ENOENT;
-		goto err_irq;
+		goto err_pdata;
 	}
 
-	err = request_irq(hw->irq, nuc900_spi_irq, 0, pdev->name, hw);
+	err = devm_request_irq(&pdev->dev, hw->irq, nuc900_spi_irq, 0,
+				pdev->name, hw);
 	if (err) {
 		dev_err(&pdev->dev, "Cannot claim IRQ\n");
-		goto err_irq;
+		goto err_pdata;
 	}
 
-	hw->clk = clk_get(&pdev->dev, "spi");
+	hw->clk = devm_clk_get(&pdev->dev, "spi");
 	if (IS_ERR(hw->clk)) {
 		dev_err(&pdev->dev, "No clock for device\n");
 		err = PTR_ERR(hw->clk);
-		goto err_clk;
+		goto err_pdata;
 	}
 
 	mfp_set_groupg(&pdev->dev, NULL);
@@ -425,17 +414,8 @@ static int nuc900_spi_probe(struct platform_device *pdev)
 
 err_register:
 	clk_disable(hw->clk);
-	clk_put(hw->clk);
-err_clk:
-	free_irq(hw->irq, hw);
-err_irq:
-	iounmap(hw->regs);
-err_iomap:
-	release_mem_region(hw->res->start, resource_size(hw->res));
-	kfree(hw->ioarea);
 err_pdata:
 	spi_master_put(hw->master);
-err_nomem:
 	return err;
 }
 
@@ -443,18 +423,8 @@ static int nuc900_spi_remove(struct platform_device *dev)
 {
 	struct nuc900_spi *hw = platform_get_drvdata(dev);
 
-	free_irq(hw->irq, hw);
-
 	spi_bitbang_stop(&hw->bitbang);
-
 	clk_disable(hw->clk);
-	clk_put(hw->clk);
-
-	iounmap(hw->regs);
-
-	release_mem_region(hw->res->start, resource_size(hw->res));
-	kfree(hw->ioarea);
-
 	spi_master_put(hw->master);
 	return 0;
 }
Signature · 7 lines
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 001101cef4c7$fb071e20$f1155a60$%[email protected]

Acked-by
#20 lore raw

Re: [PATCH 05/11] spi: nuc900: Use devm_*() functions

2013/12/9 Jingoo Han <[email protected]>:

Quoted 106 lines

Use devm_*() functions to make cleanup paths simpler.

---
 drivers/spi/spi-nuc900.c |   50 ++++++++++------------------------------------
 1 file changed, 10 insertions(+), 40 deletions(-)
drivers/spi/spi-nuc900.c +10 -33
index e0c32bc..43d340c 100644
@@ -57,7 +57,6 @@ struct nuc900_spi {
        const unsigned char     *tx;
        unsigned char           *rx;
        struct clk              *clk;
-       struct resource         *ioarea;
        struct spi_master       *master;
        struct spi_device       *curdev;
        struct device           *dev;
@@ -344,8 +343,7 @@ static int nuc900_spi_probe(struct platform_device *pdev)
        master = spi_alloc_master(&pdev->dev, sizeof(struct nuc900_spi));
        if (master == NULL) {
                dev_err(&pdev->dev, "No memory for spi_master\n");
-               err = -ENOMEM;
-               goto err_nomem;
+               return -ENOMEM;
        }
 
        hw = spi_master_get_devdata(master);
@@ -376,40 +374,31 @@ static int nuc900_spi_probe(struct platform_device *pdev)
                goto err_pdata;
        }
 
-       hw->ioarea = request_mem_region(hw->res->start,
-                                       resource_size(hw->res), pdev->name);
-
-       if (hw->ioarea == NULL) {
-               dev_err(&pdev->dev, "Cannot reserve region\n");
-               err = -ENXIO;
+       hw->regs = devm_ioremap_resource(&pdev->dev, hw->res);
+       if (IS_ERR(hw->regs)) {
+               err = PTR_ERR(hw->regs);
                goto err_pdata;
        }
 
-       hw->regs = ioremap(hw->res->start, resource_size(hw->res));
-       if (hw->regs == NULL) {
-               dev_err(&pdev->dev, "Cannot map IO\n");
-               err = -ENXIO;
-               goto err_iomap;
-       }
-
        hw->irq = platform_get_irq(pdev, 0);
        if (hw->irq < 0) {
                dev_err(&pdev->dev, "No IRQ specified\n");
                err = -ENOENT;
-               goto err_irq;
+               goto err_pdata;
        }
 
-       err = request_irq(hw->irq, nuc900_spi_irq, 0, pdev->name, hw);
+       err = devm_request_irq(&pdev->dev, hw->irq, nuc900_spi_irq, 0,
+                               pdev->name, hw);
        if (err) {
                dev_err(&pdev->dev, "Cannot claim IRQ\n");
-               goto err_irq;
+               goto err_pdata;
        }
 
-       hw->clk = clk_get(&pdev->dev, "spi");
+       hw->clk = devm_clk_get(&pdev->dev, "spi");
        if (IS_ERR(hw->clk)) {
                dev_err(&pdev->dev, "No clock for device\n");
                err = PTR_ERR(hw->clk);
-               goto err_clk;
+               goto err_pdata;
        }
 
        mfp_set_groupg(&pdev->dev, NULL);
@@ -425,17 +414,8 @@ static int nuc900_spi_probe(struct platform_device *pdev)
 
 err_register:
        clk_disable(hw->clk);
-       clk_put(hw->clk);
-err_clk:
-       free_irq(hw->irq, hw);
-err_irq:
-       iounmap(hw->regs);
-err_iomap:
-       release_mem_region(hw->res->start, resource_size(hw->res));
-       kfree(hw->ioarea);
 err_pdata:
        spi_master_put(hw->master);
-err_nomem:
        return err;
 }
 
@@ -443,18 +423,8 @@ static int nuc900_spi_remove(struct platform_device *dev)
 {
        struct nuc900_spi *hw = platform_get_drvdata(dev);
 
-       free_irq(hw->irq, hw);
-
        spi_bitbang_stop(&hw->bitbang);
-
        clk_disable(hw->clk);

drivers/spi/spi-nuc900.c static int nuc900_spi_remove(struct platform_device *dev) · line 430

Quoted 10 lines
drivers/spi/spi-nuc900.c +0 -7
-       clk_put(hw->clk);
-
-       iounmap(hw->regs);
-
-       release_mem_region(hw->res->start, resource_size(hw->res));
-       kfree(hw->ioarea);
-
        spi_master_put(hw->master);
        return 0;
 }

Great, thanks for your help.

Quoted 4 lines

--
1.7.10.4

Signature · 6 lines
Wan ZongShun.
www.mcuos.com
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author Acked-by Wan ZongShun
#21 lore raw

Re: [PATCH 05/11] spi: nuc900: Use devm_*() functions

Quoted 7 lines · Wan ZongShun

2013/12/9 Jingoo Han <[email protected]>:

Quoted 6 lines

Use devm_*() functions to make cleanup paths simpler.

---
 drivers/spi/spi-nuc900.c |   50 ++++++++++------------------------------------
 1 file changed, 10 insertions(+), 40 deletions(-)

[.....]

Quoted 3 lines

Great, thanks for your help.

Hi Wan ZongShun,

I really appreciate your feedback.
For clarity, it can be the following. :-)

Best regards,
Jingoo Han

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#23 lore raw

PATCH 6/11 spi: s3c24xx: Use devm_*() functions

In reply to a message not in the archive

Use devm_*() functions to make cleanup paths simpler.

---
 drivers/spi/spi-s3c24xx.c |   67 ++++++++++-----------------------------------
 1 file changed, 14 insertions(+), 53 deletions(-)
drivers/spi/spi-s3c24xx.c +14 -53
index 0dc32a1..ebf80bb 100644
@@ -78,7 +78,6 @@ struct s3c24xx_spi {
 	unsigned char		*rx;
 
 	struct clk		*clk;
-	struct resource		*ioarea;
 	struct spi_master	*master;
 	struct spi_device	*curdev;
 	struct device		*dev;
@@ -517,8 +516,7 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
 	master = spi_alloc_master(&pdev->dev, sizeof(struct s3c24xx_spi));
 	if (master == NULL) {
 		dev_err(&pdev->dev, "No memory for spi_master\n");
-		err = -ENOMEM;
-		goto err_nomem;
+		return -ENOMEM;
 	}
 
 	hw = spi_master_get_devdata(master);
@@ -567,43 +565,34 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
 	if (res == NULL) {
 		dev_err(&pdev->dev, "Cannot get IORESOURCE_MEM\n");
 		err = -ENOENT;
-		goto err_no_iores;
-	}
-
-	hw->ioarea = request_mem_region(res->start, resource_size(res),
-					pdev->name);
-
-	if (hw->ioarea == NULL) {
-		dev_err(&pdev->dev, "Cannot reserve region\n");
-		err = -ENXIO;
-		goto err_no_iores;
+		goto err_no_pdata;
 	}
 
-	hw->regs = ioremap(res->start, resource_size(res));
-	if (hw->regs == NULL) {
-		dev_err(&pdev->dev, "Cannot map IO\n");
-		err = -ENXIO;
-		goto err_no_iomap;
+	hw->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(hw->regs)) {
+		err = PTR_ERR(hw->regs);
+		goto err_no_pdata;
 	}
 
 	hw->irq = platform_get_irq(pdev, 0);
 	if (hw->irq < 0) {
 		dev_err(&pdev->dev, "No IRQ specified\n");
 		err = -ENOENT;
-		goto err_no_irq;
+		goto err_no_pdata;
 	}
 
-	err = request_irq(hw->irq, s3c24xx_spi_irq, 0, pdev->name, hw);
+	err = devm_request_irq(&pdev->dev, hw->irq, s3c24xx_spi_irq, 0,
+				pdev->name, hw);
 	if (err) {
 		dev_err(&pdev->dev, "Cannot claim IRQ\n");
-		goto err_no_irq;
+		goto err_no_pdata;
 	}
 
-	hw->clk = clk_get(&pdev->dev, "spi");
+	hw->clk = devm_clk_get(&pdev->dev, "spi");
 	if (IS_ERR(hw->clk)) {
 		dev_err(&pdev->dev, "No clock for device\n");
 		err = PTR_ERR(hw->clk);
-		goto err_no_clk;
+		goto err_no_pdata;
 	}
 
 	/* setup any gpio we can */
@@ -615,7 +604,8 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
 			goto err_register;
 		}
 
-		err = gpio_request(pdata->pin_cs, dev_name(&pdev->dev));
+		err = devm_gpio_request(&pdev->dev, pdata->pin_cs,
+					dev_name(&pdev->dev));
 		if (err) {
 			dev_err(&pdev->dev, "Failed to get gpio for cs\n");
 			goto err_register;
@@ -639,27 +629,10 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
 	return 0;
 
  err_register:
-	if (hw->set_cs == s3c24xx_spi_gpiocs)
-		gpio_free(pdata->pin_cs);
-
 	clk_disable(hw->clk);
-	clk_put(hw->clk);
 
- err_no_clk:
-	free_irq(hw->irq, hw);
-
- err_no_irq:
-	iounmap(hw->regs);
-
- err_no_iomap:
-	release_resource(hw->ioarea);
-	kfree(hw->ioarea);
-
- err_no_iores:
  err_no_pdata:
 	spi_master_put(hw->master);
-
- err_nomem:
 	return err;
 }
 
@@ -668,19 +641,7 @@ static int s3c24xx_spi_remove(struct platform_device *dev)
 	struct s3c24xx_spi *hw = platform_get_drvdata(dev);
 
 	spi_bitbang_stop(&hw->bitbang);
-
 	clk_disable(hw->clk);
-	clk_put(hw->clk);
-
-	free_irq(hw->irq, hw);
-	iounmap(hw->regs);
-
-	if (hw->set_cs == s3c24xx_spi_gpiocs)
-		gpio_free(hw->pdata->pin_cs);
-
-	release_resource(hw->ioarea);
-	kfree(hw->ioarea);
-
 	spi_master_put(hw->master);
 	return 0;
 }
Signature · 7 lines
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 001201cef4c8$1b78a110$5269e330$%[email protected]

Applied
#25 lore raw

Re: [PATCH 06/11] spi: s3c24xx: Use devm_*() functions

Quoted 1 line · Jingoo Han

Use devm_*() functions to make cleanup paths simpler.

Applied, thanks.

author
#26 lore raw

PATCH 7/11 spi: bcm63xx: Use devm_clk_get()

In reply to a message not in the archive

Use devm_clk_get() to make cleanup paths simpler.

---
 drivers/spi/spi-bcm63xx.c |   15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/spi/spi-bcm63xx.c +4 -11
index 469ecd8..f44a9eb 100644
@@ -345,22 +345,19 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(dev, "no irq\n");
-		ret = -ENXIO;
-		goto out;
+		return -ENXIO;
 	}
 
-	clk = clk_get(dev, "spi");
+	clk = devm_clk_get(dev, "spi");
 	if (IS_ERR(clk)) {
 		dev_err(dev, "no clock for device\n");
-		ret = PTR_ERR(clk);
-		goto out;
+		return PTR_ERR(clk);
 	}
 
 	master = spi_alloc_master(dev, sizeof(*bs));
 	if (!master) {
 		dev_err(dev, "out of memory\n");
-		ret = -ENOMEM;
-		goto out_clk;
+		return -ENOMEM;
 	}
 
 	bs = spi_master_get_devdata(master);
@@ -427,9 +424,6 @@ out_clk_disable:
 	clk_disable_unprepare(clk);
 out_err:
 	spi_master_put(master);
-out_clk:
-	clk_put(clk);
-out:
 	return ret;
 }
 
@@ -443,7 +437,6 @@ static int bcm63xx_spi_remove(struct platform_device *pdev)
 
 	/* HW shutdown */
 	clk_disable_unprepare(bs->clk);
-	clk_put(bs->clk);
 
 	return 0;
 }
Signature · 7 lines
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 001301cef4c8$40d2b3b0$c2781b10$%[email protected]

Acked-by
#28 lore raw

Re: [PATCH 07/11] spi: bcm63xx: Use devm_clk_get()

Quoted 3 lines · Jingoo Han

Use devm_clk_get() to make cleanup paths simpler.

Looks good, thanks.

Quoted 57 lines
---
 drivers/spi/spi-bcm63xx.c |   15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/spi/spi-bcm63xx.c +4 -12
index 469ecd8..f44a9eb 100644
@@ -345,22 +345,19 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
        irq = platform_get_irq(pdev, 0);
        if (irq < 0) {
                dev_err(dev, "no irq\n");
-               ret = -ENXIO;
-               goto out;
+               return -ENXIO;
        }
 
-       clk = clk_get(dev, "spi");
+       clk = devm_clk_get(dev, "spi");
        if (IS_ERR(clk)) {
                dev_err(dev, "no clock for device\n");
-               ret = PTR_ERR(clk);
-               goto out;
+               return PTR_ERR(clk);
        }
 
        master = spi_alloc_master(dev, sizeof(*bs));
        if (!master) {
                dev_err(dev, "out of memory\n");
-               ret = -ENOMEM;
-               goto out_clk;
+               return -ENOMEM;
        }
 
        bs = spi_master_get_devdata(master);
@@ -427,9 +424,6 @@ out_clk_disable:
        clk_disable_unprepare(clk);
 out_err:
        spi_master_put(master);
-out_clk:
-       clk_put(clk);
-out:
        return ret;
 }
 
@@ -443,7 +437,6 @@ static int bcm63xx_spi_remove(struct platform_device *pdev)
 
        /* HW shutdown */
        clk_disable_unprepare(bs->clk);
-       clk_put(bs->clk);
 
        return 0;
 }
--

1.7.10.4

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#30 lore raw

PATCH 8/11 spi: bcm63xx-hsspi: Use devm_clk_get()

In reply to a message not in the archive

Use devm_clk_get() to make cleanup paths simpler.

---
 drivers/spi/spi-bcm63xx-hsspi.c |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/spi/spi-bcm63xx-hsspi.c +3 -9
index bc8d848..9742e11 100644
@@ -342,16 +342,14 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
 	if (IS_ERR(regs))
 		return PTR_ERR(regs);
 
-	clk = clk_get(dev, "hsspi");
+	clk = devm_clk_get(dev, "hsspi");
 
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
 	rate = clk_get_rate(clk);
-	if (!rate) {
-		ret = -EINVAL;
-		goto out_put_clk;
-	}
+	if (!rate)
+		return -EINVAL;
 
 	clk_prepare_enable(clk);
 
@@ -409,9 +407,6 @@ out_put_master:
 	spi_master_put(master);
 out_disable_clk:
 	clk_disable_unprepare(clk);
-out_put_clk:
-	clk_put(clk);
-
 	return ret;
 }
 
@@ -426,7 +421,6 @@ static int bcm63xx_hsspi_remove(struct platform_device *pdev)
 	/* reset the hardware and block queue progress */
 	__raw_writel(0, bs->regs + HSSPI_INT_MASK_REG);
 	clk_disable_unprepare(bs->clk);
-	clk_put(bs->clk);
 
 	return 0;
 }
Signature · 7 lines
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 001401cef4c8$52cf31b0$f86d9510$%[email protected]

Acked-by
#32 lore raw

Re: [PATCH 08/11] spi: bcm63xx-hsspi: Use devm_clk_get()

Quoted 3 lines · Jingoo Han

Use devm_clk_get() to make cleanup paths simpler.

Looks good, thanks.

Quoted 50 lines
---
 drivers/spi/spi-bcm63xx-hsspi.c |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/spi/spi-bcm63xx-hsspi.c +3 -10
index bc8d848..9742e11 100644
@@ -342,16 +342,14 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
        if (IS_ERR(regs))
                return PTR_ERR(regs);
 
-       clk = clk_get(dev, "hsspi");
+       clk = devm_clk_get(dev, "hsspi");
 
        if (IS_ERR(clk))
                return PTR_ERR(clk);
 
        rate = clk_get_rate(clk);
-       if (!rate) {
-               ret = -EINVAL;
-               goto out_put_clk;
-       }
+       if (!rate)
+               return -EINVAL;
 
        clk_prepare_enable(clk);
 
@@ -409,9 +407,6 @@ out_put_master:
        spi_master_put(master);
 out_disable_clk:
        clk_disable_unprepare(clk);
-out_put_clk:
-       clk_put(clk);
-
        return ret;
 }
 
@@ -426,7 +421,6 @@ static int bcm63xx_hsspi_remove(struct platform_device *pdev)
        /* reset the hardware and block queue progress */
        __raw_writel(0, bs->regs + HSSPI_INT_MASK_REG);
        clk_disable_unprepare(bs->clk);
-       clk_put(bs->clk);
 
        return 0;
 }
--

1.7.10.4

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#34 lore raw

PATCH 9/11 spi: orion: Use devm_clk_get()

In reply to a message not in the archive

Use devm_clk_get() to make cleanup paths simpler.

---
 drivers/spi/spi-orion.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/spi/spi-orion.c +1 -3
index 744841e..7f2121f 100644
@@ -434,7 +434,7 @@ static int orion_spi_probe(struct platform_device *pdev)
 	spi = spi_master_get_devdata(master);
 	spi->master = master;
 
-	spi->clk = clk_get(&pdev->dev, NULL);
+	spi->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(spi->clk)) {
 		status = PTR_ERR(spi->clk);
 		goto out;
@@ -465,7 +465,6 @@ static int orion_spi_probe(struct platform_device *pdev)
 
 out_rel_clk:
 	clk_disable_unprepare(spi->clk);
-	clk_put(spi->clk);
 out:
 	spi_master_put(master);
 	return status;
@@ -481,7 +480,6 @@ static int orion_spi_remove(struct platform_device *pdev)
 	spi = spi_master_get_devdata(master);
 
 	clk_disable_unprepare(spi->clk);
-	clk_put(spi->clk);
 
 	return 0;
 }
Signature · 7 lines
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 001501cef4c8$68a7b160$39f71420$%[email protected]

Acked-by
#36 lore raw

Re: [PATCH 09/11] spi: orion: Use devm_clk_get()

Quoted 6 lines · Jingoo Han

Use devm_clk_get() to make cleanup paths simpler.

---
 drivers/spi/spi-orion.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

thx,

Jason.
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#37 lore raw

PATCH 10/11 spi: txx9: Use devm_clk_get()

In reply to a message not in the archive

Use devm_clk_get() to make cleanup paths simpler.

---
 drivers/spi/spi-txx9.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/spi/spi-txx9.c +2 -5
index 18c9bb2..ffbe03d 100644
@@ -348,7 +348,7 @@ static int txx9spi_probe(struct platform_device *dev)
 	INIT_LIST_HEAD(&c->queue);
 	init_waitqueue_head(&c->waitq);
 
-	c->clk = clk_get(&dev->dev, "spi-baseclk");
+	c->clk = devm_clk_get(&dev->dev, "spi-baseclk");
 	if (IS_ERR(c->clk)) {
 		ret = PTR_ERR(c->clk);
 		c->clk = NULL;
@@ -415,10 +415,8 @@ exit_busy:
 exit:
 	if (c->workqueue)
 		destroy_workqueue(c->workqueue);
-	if (c->clk) {
+	if (c->clk)
 		clk_disable(c->clk);
-		clk_put(c->clk);
-	}
 	spi_master_put(master);
 	return ret;
 }
@@ -430,7 +428,6 @@ static int txx9spi_remove(struct platform_device *dev)
 
 	destroy_workqueue(c->workqueue);
 	clk_disable(c->clk);
-	clk_put(c->clk);
 	return 0;
 }
 
Signature · 7 lines
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 001601cef4c8$aa1f7d30$fe5e7790$%[email protected]

Applied
#39 lore raw

Re: [PATCH 10/11] spi: txx9: Use devm_clk_get()

Quoted 1 line · Jingoo Han

Use devm_clk_get() to make cleanup paths simpler.

Applied, thanks.

author
#40 lore raw

PATCH 11/11 spi: bcm2835: Use devm_request_irq()

In reply to a message not in the archive

Use devm_request_irq() to make cleanup paths simpler.

---
 drivers/spi/spi-bcm2835.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/spi/spi-bcm2835.c +3 -7
index 9025edd..8a89dd1 100644
@@ -347,8 +347,8 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
 
 	clk_prepare_enable(bs->clk);
 
-	err = request_irq(bs->irq, bcm2835_spi_interrupt, 0,
-			dev_name(&pdev->dev), master);
+	err = devm_request_irq(&pdev->dev, bs->irq, bcm2835_spi_interrupt, 0,
+				dev_name(&pdev->dev), master);
 	if (err) {
 		dev_err(&pdev->dev, "could not request IRQ: %d\n", err);
 		goto out_clk_disable;
@@ -361,13 +361,11 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
 	err = devm_spi_register_master(&pdev->dev, master);
 	if (err) {
 		dev_err(&pdev->dev, "could not register SPI master: %d\n", err);
-		goto out_free_irq;
+		goto out_clk_disable;
 	}
 
 	return 0;
 
-out_free_irq:
-	free_irq(bs->irq, master);
 out_clk_disable:
 	clk_disable_unprepare(bs->clk);
 out_master_put:
@@ -380,8 +378,6 @@ static int bcm2835_spi_remove(struct platform_device *pdev)
 	struct spi_master *master = platform_get_drvdata(pdev);
 	struct bcm2835_spi *bs = spi_master_get_devdata(master);
 
-	free_irq(bs->irq, master);
-
 	/* Clear FIFOs, and disable the HW block */
 	bcm2835_wr(bs, BCM2835_SPI_CS,
 		   BCM2835_SPI_CS_CLEAR_RX | BCM2835_SPI_CS_CLEAR_TX);
Signature · 7 lines
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 001701cef4c8$eaa87c30$bff97490$%[email protected]

Applied
#42 lore raw

Re: [PATCH 11/11] spi: bcm2835: Use devm_request_irq()

Quoted 1 line · Jingoo Han

Use devm_request_irq() to make cleanup paths simpler.

Applied, thanks.

#43 lore raw

Re: [PATCH 11/11] spi: bcm2835: Use devm_request_irq()

In reply to a message not in the archive
Quoted 1 line · Jingoo Han

Use devm_request_irq() to make cleanup paths simpler.

Sorry for the slow response. This is likely fine, since the SPI controller has a dedicated interrupt.
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html