From: Bryan Wu <bryan.wu@canonical.com>
To: linux-leds@vger.kernel.org, rpurdie@rpsys.net,
linux-kernel@vger.kernel.org
Subject: [PATCH 10/25] leds: convert Renesas TPU LED driver to devm_kzalloc() and cleanup error exit path
Date: Wed, 4 Jul 2012 13:10:02 +0800 [thread overview]
Message-ID: <1341378617-10386-11-git-send-email-bryan.wu@canonical.com> (raw)
In-Reply-To: <1341378617-10386-1-git-send-email-bryan.wu@canonical.com>
Cc: Magnus Damm <damm@opensource.se>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
---
drivers/leds/leds-renesas-tpu.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/drivers/leds/leds-renesas-tpu.c b/drivers/leds/leds-renesas-tpu.c
index 32fe337..9ee12c2 100644
--- a/drivers/leds/leds-renesas-tpu.c
+++ b/drivers/leds/leds-renesas-tpu.c
@@ -243,31 +243,30 @@ static int __devinit r_tpu_probe(struct platform_device *pdev)
struct led_renesas_tpu_config *cfg = pdev->dev.platform_data;
struct r_tpu_priv *p;
struct resource *res;
- int ret = -ENXIO;
+ int ret;
if (!cfg) {
dev_err(&pdev->dev, "missing platform data\n");
goto err0;
}
- p = kzalloc(sizeof(*p), GFP_KERNEL);
+ p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
if (p == NULL) {
dev_err(&pdev->dev, "failed to allocate driver data\n");
- ret = -ENOMEM;
- goto err0;
+ return -ENOMEM;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(&pdev->dev, "failed to get I/O memory\n");
- goto err1;
+ return -ENXIO;
}
/* map memory, let mapbase point to our channel */
p->mapbase = ioremap_nocache(res->start, resource_size(res));
if (p->mapbase == NULL) {
dev_err(&pdev->dev, "failed to remap I/O memory\n");
- goto err1;
+ return -ENXIO;
}
/* get hold of clock */
@@ -275,7 +274,7 @@ static int __devinit r_tpu_probe(struct platform_device *pdev)
if (IS_ERR(p->clk)) {
dev_err(&pdev->dev, "cannot get clock\n");
ret = PTR_ERR(p->clk);
- goto err2;
+ goto err0;
}
p->pdev = pdev;
@@ -294,7 +293,7 @@ static int __devinit r_tpu_probe(struct platform_device *pdev)
p->ldev.flags |= LED_CORE_SUSPENDRESUME;
ret = led_classdev_register(&pdev->dev, &p->ldev);
if (ret < 0)
- goto err3;
+ goto err1;
/* max_brightness may be updated by the LED core code */
p->min_rate = p->ldev.max_brightness * p->refresh_rate;
@@ -302,14 +301,11 @@ static int __devinit r_tpu_probe(struct platform_device *pdev)
pm_runtime_enable(&pdev->dev);
return 0;
- err3:
+ err1:
r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF);
clk_put(p->clk);
- err2:
- iounmap(p->mapbase);
- err1:
- kfree(p);
err0:
+ iounmap(p->mapbase);
return ret;
}
@@ -327,7 +323,6 @@ static int __devexit r_tpu_remove(struct platform_device *pdev)
clk_put(p->clk);
iounmap(p->mapbase);
- kfree(p);
return 0;
}
--
1.7.10.4
next prev parent reply other threads:[~2012-07-04 5:11 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-04 5:09 [PATCH 00/25] leds: convert all kzalloc() to devm_kzalloc() Bryan Wu
2012-07-04 5:09 ` [PATCH 01/25] leds: convert Big Networks LED driver " Bryan Wu
2012-07-04 5:09 ` [PATCH 02/25] leds: convert HTC ASIC3 LED driver to devm_kzalloc() and cleanup error exit path Bryan Wu
2012-07-04 5:09 ` [PATCH 03/25] leds: convert Atmel PWM LED driver to devm_kzalloc() Bryan Wu
2012-07-04 5:09 ` [PATCH 04/25] leds: convert LP3944 " Bryan Wu
2012-07-04 7:34 ` Bryan Wu
2012-07-04 5:09 ` [PATCH 05/25] leds: convert DA9030/DA9034 LED driver to devm_kzalloc() and cleanup error exit path Bryan Wu
2012-07-04 5:09 ` [PATCH 06/25] leds: convert LP5521 " Bryan Wu
2012-07-04 7:35 ` Bryan Wu
2012-07-04 5:09 ` [PATCH 07/25] leds: convert BD2802 RGB " Bryan Wu
2012-07-04 5:10 ` [PATCH 08/25] leds: convert PCA9633 LED driver to devm_kzalloc() Bryan Wu
2012-07-04 5:10 ` [PATCH 09/25] leds: convert LP5523 LED driver to devm_kzalloc() and cleanup error exit path Bryan Wu
2012-07-04 5:10 ` Bryan Wu [this message]
2012-07-04 5:10 ` [PATCH 11/25] leds: convert LT3593 LED driver to devm_kzalloc() Bryan Wu
2012-07-04 5:10 ` [PATCH 12/25] leds: convert PCA9532 " Bryan Wu
2012-07-04 5:10 ` [PATCH 13/25] leds: convert Sun Fire LED driver to devm_kzalloc() and cleanup error exit path Bryan Wu
2012-07-04 5:10 ` [PATCH 14/25] leds: convert PCA955x " Bryan Wu
2012-07-04 5:10 ` [PATCH 15/25] leds: convert ADP5520 " Bryan Wu
2012-07-04 7:40 ` Bryan Wu
2012-07-04 5:10 ` [PATCH 16/25] leds: convert Freescale MC13783 " Bryan Wu
2012-07-04 5:10 ` [PATCH 17/25] leds: convert TCA6507 LED driver to devm_kzalloc() Bryan Wu
2012-07-04 5:10 ` [PATCH 18/25] leds: convert LM3530 LED driver to devm_kzalloc() and cleanup error exit path Bryan Wu
2012-07-05 0:01 ` Linus Walleij
2012-07-04 5:10 ` [PATCH 19/25] leds: convert DAC124S085 LED driver to devm_kzalloc() Bryan Wu
2012-07-04 5:10 ` [PATCH 20/25] leds: convert Network Space v2 LED driver to devm_kzalloc() and cleanup error exit path Bryan Wu
2012-07-04 5:10 ` [PATCH 21/25] leds: convert transient LED trigger driver to devm_kzalloc() Bryan Wu
2012-07-05 16:42 ` Shuah Khan
2012-07-04 5:10 ` [PATCH 22/25] leds: convert GPIO LED trigger driver to devm_kzalloc() and cleanup error exit path Bryan Wu
2012-07-05 16:45 ` Shuah Khan
2012-07-04 5:10 ` [PATCH 23/25] leds: convert Backlight emulation " Bryan Wu
2012-07-05 16:46 ` Shuah Khan
2012-07-04 5:10 ` [PATCH 24/25] leds: convert Heartbeat LED trigger driver to devm_kzalloc() Bryan Wu
2012-07-05 16:46 ` Shuah Khan
2012-07-04 5:10 ` [PATCH 25/25] leds: convert One-shot LED trigger driver to devm_kzalloc() and cleanup error exit path Bryan Wu
2012-07-05 16:47 ` Shuah Khan
2012-07-05 19:48 ` Fabio Baltieri
2012-07-05 20:35 ` Shuah Khan
2012-07-06 4:02 ` Bryan Wu
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=1341378617-10386-11-git-send-email-bryan.wu@canonical.com \
--to=bryan.wu@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=rpurdie@rpsys.net \
/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
all inboxes | Powered by JetHome®