linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Russell King <linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: Alessandro Rubini <rubini-9wsNiZum9E8@public.gmane.org>,
	Linus Walleij
	<linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
	Chris Ball <chris-OsFVWbfNK3isTnJN9+BGXg@public.gmane.org>,
	Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Ulf Hansson <ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: [PATCH 11/17] i2c: nomadik: Convert to devm functions
Date: Tue,  4 Feb 2014 16:58:52 +0100	[thread overview]
Message-ID: <1391529538-21685-12-git-send-email-ulf.hansson@linaro.org> (raw)
In-Reply-To: <1391529538-21685-1-git-send-email-ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

Use devm_* functions to simplify code and error handling.

Cc: Alessandro Rubini <rubini-9wsNiZum9E8@public.gmane.org>
Cc: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
Signed-off-by: Ulf Hansson <ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 drivers/i2c/busses/i2c-nomadik.c |   29 +++++++++--------------------
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 4443613..840bcf9 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -1015,7 +1015,7 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
 		pdata->rft = max_fifo_threshold;
 	}
 
-	dev = kzalloc(sizeof(struct nmk_i2c_dev), GFP_KERNEL);
+	dev = devm_kzalloc(&adev->dev, sizeof(struct nmk_i2c_dev), GFP_KERNEL);
 	if (!dev) {
 		dev_err(&adev->dev, "cannot allocate memory\n");
 		ret = -ENOMEM;
@@ -1031,27 +1031,28 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
 	/* If possible, let's go to idle until the first transfer */
 	pinctrl_pm_select_idle_state(&adev->dev);
 
-	dev->virtbase = ioremap(adev->res.start, resource_size(&adev->res));
+	dev->virtbase = devm_ioremap(&adev->dev, adev->res.start,
+				resource_size(&adev->res));
 	if (!dev->virtbase) {
 		ret = -ENOMEM;
-		goto err_no_ioremap;
+		goto err_no_mem;
 	}
 
 	dev->irq = adev->irq[0];
-	ret = request_irq(dev->irq, i2c_irq_handler, 0,
+	ret = devm_request_irq(&adev->dev, dev->irq, i2c_irq_handler, 0,
 				DRIVER_NAME, dev);
 	if (ret) {
 		dev_err(&adev->dev, "cannot claim the irq %d\n", dev->irq);
-		goto err_irq;
+		goto err_no_mem;
 	}
 
 	pm_suspend_ignore_children(&adev->dev, true);
 
-	dev->clk = clk_get(&adev->dev, NULL);
+	dev->clk = devm_clk_get(&adev->dev, NULL);
 	if (IS_ERR(dev->clk)) {
 		dev_err(&adev->dev, "could not get i2c clock\n");
 		ret = PTR_ERR(dev->clk);
-		goto err_no_clk;
+		goto err_no_mem;
 	}
 
 	adap = &dev->adap;
@@ -1079,21 +1080,13 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
 	ret = i2c_add_adapter(adap);
 	if (ret) {
 		dev_err(&adev->dev, "failed to add adapter\n");
-		goto err_add_adap;
+		goto err_no_mem;
 	}
 
 	pm_runtime_put(&adev->dev);
 
 	return 0;
 
- err_add_adap:
-	clk_put(dev->clk);
- err_no_clk:
-	free_irq(dev->irq, dev);
- err_irq:
-	iounmap(dev->virtbase);
- err_no_ioremap:
-	kfree(dev);
  err_no_mem:
 
 	return ret;
@@ -1110,13 +1103,9 @@ static int nmk_i2c_remove(struct amba_device *adev)
 	clear_all_interrupts(dev);
 	/* disable the controller */
 	i2c_clr_bit(dev->virtbase + I2C_CR, I2C_CR_PE);
-	free_irq(dev->irq, dev);
-	iounmap(dev->virtbase);
 	if (res)
 		release_mem_region(res->start, resource_size(res));
-	clk_put(dev->clk);
 	pm_runtime_disable(&adev->dev);
-	kfree(dev);
 
 	return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2014-02-04 15:58 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-04 15:58 [PATCH 00/17] amba: PM fixups for amba bus and some amba drivers Ulf Hansson
2014-02-04 15:58 ` [PATCH 01/17] amba: Let runtime PM callbacks be available for CONFIG_PM Ulf Hansson
     [not found]   ` <1391529538-21685-2-git-send-email-ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-02-19  9:40     ` Russell King - ARM Linux
     [not found]       ` <20140219094037.GQ21483-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-02-19 11:40         ` Ulf Hansson
2014-02-04 15:58 ` [PATCH 02/17] amba: Add late and early PM callbacks Ulf Hansson
2014-02-04 15:58 ` [PATCH 03/17] mmc: mmci: Mask IRQs for all variants during runtime suspend Ulf Hansson
     [not found]   ` <1391529538-21685-4-git-send-email-ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-02-18 16:05     ` Russell King - ARM Linux
     [not found]       ` <20140218160542.GH21483-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-02-18 16:36         ` Ulf Hansson
     [not found]           ` <CAPDyKFq3uAoo7p-7hZgBmMJ4jf9A7dC0aUZJYUE0z1Qq5W=0bw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-02-18 16:46             ` Russell King - ARM Linux
2014-02-18 17:02               ` Ulf Hansson
2014-02-24 14:54           ` Linus Walleij
2014-02-04 15:58 ` [PATCH 04/17] mmc: mmci: Let runtime PM callbacks be available for CONFIG_PM Ulf Hansson
2014-02-04 15:58 ` [PATCH 05/17] mmc: mmci: Put the device into low power state at system suspend Ulf Hansson
     [not found]   ` <1391529538-21685-6-git-send-email-ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-02-04 19:22     ` Kevin Hilman
2014-02-05 12:49       ` Linus Walleij
     [not found]         ` <CACRpkdZt5+t7b0_a__2kJP4V9PS2cyXmguWrST+fzbKCnosi7g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-02-05 14:13           ` Mark Brown
2014-02-05 20:08         ` Kevin Hilman
2014-02-10 11:11       ` Ulf Hansson
2014-02-10 18:03         ` Kevin Hilman
2014-02-04 15:58 ` [PATCH 06/17] spi: pl022: Let runtime PM callbacks be available for CONFIG_PM Ulf Hansson
2014-02-19 14:20   ` Ulf Hansson
     [not found]     ` <CAPDyKFombL2-Rt46QpXPNWe5PeGQnOGmQQNfYd5MdYdEePn-4w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-02-19 15:10       ` Mark Brown
     [not found]         ` <20140219151040.GH2669-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-02-19 18:02           ` Ulf Hansson
2014-02-04 15:58 ` [PATCH 07/17] spi: pl022: Don't ignore power domain and amba bus at system suspend Ulf Hansson
2014-02-04 19:16   ` Mark Brown
2014-02-10 12:33     ` Ulf Hansson
2014-02-10 12:51       ` Mark Brown
2014-02-19 14:15         ` Ulf Hansson
2014-02-04 15:58 ` [PATCH 08/17] spi: pl022: Fully gate clocks at request inactivity Ulf Hansson
2014-02-04 17:07   ` Mark Brown
2014-02-10 10:36     ` Ulf Hansson
2014-02-04 15:58 ` [PATCH 12/17] i2c: nomadik: Remove redundant call to pm_runtime_disable Ulf Hansson
2014-02-04 15:58 ` [PATCH 13/17] i2c: nomadik: Leave probe with the device in active state Ulf Hansson
2014-02-04 15:58 ` [PATCH 14/17] i2c: nomadik: Fixup deployment of runtime PM Ulf Hansson
     [not found]   ` <1391529538-21685-15-git-send-email-ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-02-05 14:34     ` Linus Walleij
     [not found]       ` <CACRpkdZwoXf5ovmQEAN6Ugvz91+_i5uGqStR3MGXQeJGHitj3Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-02-10 10:14         ` Ulf Hansson
2014-02-13 14:12           ` Ulf Hansson
2014-02-05 14:45     ` Fabio Estevam
     [not found]       ` <CAOMZO5CzUuQrmbk6FpFGR56jHBtW-1d_AGcdgB2xyMG0Nkf+Fw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-02-10 10:16         ` Ulf Hansson
     [not found] ` <1391529538-21685-1-git-send-email-ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-02-04 15:58   ` [PATCH 09/17] spi: pl022: Simplify clock handling Ulf Hansson
2014-02-04 19:19     ` Mark Brown
     [not found]       ` <20140204191947.GV22609-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-02-10 10:42         ` Ulf Hansson
2014-02-04 15:58   ` [PATCH 10/17] spi: pl022: Remove redundant pinctrl to default state in probe Ulf Hansson
     [not found]     ` <1391529538-21685-11-git-send-email-ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-02-04 19:20       ` Mark Brown
2014-02-05 12:53       ` Linus Walleij
2014-02-04 15:58   ` Ulf Hansson [this message]
2014-02-05 14:32     ` [PATCH 11/17] i2c: nomadik: Convert to devm functions Linus Walleij
2014-02-04 15:58   ` [PATCH 15/17] i2c: nomadik: Convert to late and early system PM callbacks Ulf Hansson
2014-02-04 15:58   ` [PATCH 16/17] i2c: nomadik: Remove busy check for transfers at suspend late Ulf Hansson
2014-02-04 15:58   ` [PATCH 17/17] i2c: nomadik: Fixup system suspend Ulf Hansson
2014-02-04 18:49   ` [PATCH 00/17] amba: PM fixups for amba bus and some amba drivers Mark Brown
2014-02-10 10:25     ` Ulf Hansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1391529538-21685-12-git-send-email-ulf.hansson@linaro.org \
    --to=ulf.hansson-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=chris-OsFVWbfNK3isTnJN9+BGXg@public.gmane.org \
    --cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org \
    --cc=linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=rubini-9wsNiZum9E8@public.gmane.org \
    --cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).