* [PATCH V3 11/17] i2c: nomadik: Convert to devm functions
@ 2014-02-17 15:20 Ulf Hansson
[not found] ` <1392650418-14820-1-git-send-email-ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Ulf Hansson @ 2014-02-17 15:20 UTC (permalink / raw)
To: Alessandro Rubini, Linus Walleij, Wolfram Sang,
linux-i2c-u79uwXL29TY76Z2rM5mHXA
Cc: Russell King, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
Mark Brown, Ulf Hansson
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 | 31 ++++++++++---------------------
1 file changed, 10 insertions(+), 21 deletions(-)
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index bc8ba02..cd15c03 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -981,7 +981,7 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
return -ENODEV;
}
- 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;
@@ -1011,27 +1011,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));
- if (!dev->virtbase) {
+ dev->virtbase = devm_ioremap(&adev->dev, adev->res.start,
+ resource_size(&adev->res));
+ if (IS_ERR(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;
@@ -1053,21 +1054,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;
@@ -1084,13 +1077,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
^ permalink raw reply related [flat|nested] 6+ messages in thread[parent not found: <1392650418-14820-1-git-send-email-ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>]
* Re: [PATCH V3 11/17] i2c: nomadik: Convert to devm functions [not found] ` <1392650418-14820-1-git-send-email-ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> @ 2014-02-18 11:01 ` Wolfram Sang 2014-02-18 11:43 ` Ulf Hansson 0 siblings, 1 reply; 6+ messages in thread From: Wolfram Sang @ 2014-02-18 11:01 UTC (permalink / raw) To: Ulf Hansson Cc: Alessandro Rubini, Linus Walleij, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Russell King, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Mark Brown [-- Attachment #1: Type: text/plain, Size: 475 bytes --] On Mon, Feb 17, 2014 at 04:20:18PM +0100, Ulf Hansson wrote: > 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> What has changed in V3? I didn't get the cover letter. [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH V3 11/17] i2c: nomadik: Convert to devm functions 2014-02-18 11:01 ` Wolfram Sang @ 2014-02-18 11:43 ` Ulf Hansson [not found] ` <CAPDyKFpRaAAer00dqcXR-qOT9S8-SDTnaMUHRwWCZ93w-wnTDA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Ulf Hansson @ 2014-02-18 11:43 UTC (permalink / raw) To: Wolfram Sang Cc: Russell King, Linus Walleij, Mark Brown, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Alessandro Rubini On 18 February 2014 12:01, Wolfram Sang <wsa@the-dreams.de> wrote: > On Mon, Feb 17, 2014 at 04:20:18PM +0100, Ulf Hansson wrote: >> Use devm_* functions to simplify code and error handling. >> >> Cc: Alessandro Rubini <rubini@unipv.it> >> Cc: Linus Walleij <linus.walleij@linaro.org> >> Cc: Wolfram Sang <wsa@the-dreams.de> >> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> > > What has changed in V3? I didn't get the cover letter. I added the IS_ERR, check as you suggested. That caused a rebase of the other patches as well. Sorry if it was unclear. Kind regards Uffe ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <CAPDyKFpRaAAer00dqcXR-qOT9S8-SDTnaMUHRwWCZ93w-wnTDA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH V3 11/17] i2c: nomadik: Convert to devm functions [not found] ` <CAPDyKFpRaAAer00dqcXR-qOT9S8-SDTnaMUHRwWCZ93w-wnTDA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2014-02-18 18:43 ` Wolfram Sang 2014-02-18 20:50 ` Ulf Hansson 0 siblings, 1 reply; 6+ messages in thread From: Wolfram Sang @ 2014-02-18 18:43 UTC (permalink / raw) To: Ulf Hansson Cc: Alessandro Rubini, Linus Walleij, linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Russell King, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, Mark Brown [-- Attachment #1: Type: text/plain, Size: 339 bytes --] > I added the IS_ERR, check as you suggested. That caused a rebase of > the other patches as well. > > Sorry if it was unclear. No problem. I am about to apply all patches except 17 as you suggested. It fails here, however, although I applied Linus' patch first. What exactly is your base? Any chance to publish your branch? [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH V3 11/17] i2c: nomadik: Convert to devm functions 2014-02-18 18:43 ` Wolfram Sang @ 2014-02-18 20:50 ` Ulf Hansson [not found] ` <CAPDyKFrBPy+QxgU-PpcGsvy8n=GLEWZHA+0FLfhnV780tt8YWQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Ulf Hansson @ 2014-02-18 20:50 UTC (permalink / raw) To: Wolfram Sang Cc: Alessandro Rubini, Linus Walleij, linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Russell King, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, Mark Brown On 18 February 2014 19:43, Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org> wrote: > >> I added the IS_ERR, check as you suggested. That caused a rebase of >> the other patches as well. >> >> Sorry if it was unclear. > > No problem. I am about to apply all patches except 17 as you suggested. > It fails here, however, although I applied Linus' patch first. What > exactly is your base? Any chance to publish your branch? > I have several branches. :-) My patches applies on top 3.14-rc1 + Linus' patch. It also applies on "git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-nomadik.git" on the i2c-nomadik, which already holds Linus's patch. This is what I thought was important due what's stated in the MAINATAINERS file. Now, I guess I should use your tree instead, "git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git". Any particular branch I should use? Maybe it's also better if I just resend the patches in a new patchset, once I rebased them towards your tree? Kind regards Uffe ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <CAPDyKFrBPy+QxgU-PpcGsvy8n=GLEWZHA+0FLfhnV780tt8YWQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH V3 11/17] i2c: nomadik: Convert to devm functions [not found] ` <CAPDyKFrBPy+QxgU-PpcGsvy8n=GLEWZHA+0FLfhnV780tt8YWQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2014-02-18 22:02 ` Ulf Hansson 0 siblings, 0 replies; 6+ messages in thread From: Ulf Hansson @ 2014-02-18 22:02 UTC (permalink / raw) To: Wolfram Sang Cc: Alessandro Rubini, Linus Walleij, linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Russell King, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, Mark Brown On 18 February 2014 21:50, Ulf Hansson <ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote: > On 18 February 2014 19:43, Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org> wrote: >> >>> I added the IS_ERR, check as you suggested. That caused a rebase of >>> the other patches as well. >>> >>> Sorry if it was unclear. >> >> No problem. I am about to apply all patches except 17 as you suggested. >> It fails here, however, although I applied Linus' patch first. What >> exactly is your base? Any chance to publish your branch? >> > > I have several branches. :-) > > My patches applies on top 3.14-rc1 + Linus' patch. > > It also applies on > "git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-nomadik.git" > on the i2c-nomadik, which already holds Linus's patch. This is what I > thought was important due what's stated in the MAINATAINERS file. > > Now, I guess I should use your tree instead, > "git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git". Any > particular branch I should use? Maybe it's also better if I just > resend the patches in a new patchset, once I rebased them towards your > tree? Sorry, I have taken Linus v1 patch as base, it should have been v2 of course. Sorry for wasting your time. I will rebase and send v4 patches asap. Kind regards Uffe > > Kind regards > Uffe ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-02-18 22:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-17 15:20 [PATCH V3 11/17] i2c: nomadik: Convert to devm functions Ulf Hansson
[not found] ` <1392650418-14820-1-git-send-email-ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-02-18 11:01 ` Wolfram Sang
2014-02-18 11:43 ` Ulf Hansson
[not found] ` <CAPDyKFpRaAAer00dqcXR-qOT9S8-SDTnaMUHRwWCZ93w-wnTDA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-02-18 18:43 ` Wolfram Sang
2014-02-18 20:50 ` Ulf Hansson
[not found] ` <CAPDyKFrBPy+QxgU-PpcGsvy8n=GLEWZHA+0FLfhnV780tt8YWQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-02-18 22:02 ` Ulf Hansson
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).