summaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-sunfire.c
diff options
context:
space:
mode:
authorBryan Wu <bryan.wu@canonical.com>2012-07-04 06:04:48 +0200
committerBryan Wu <bryan.wu@canonical.com>2012-07-24 01:52:39 +0200
commit234699a8f3228754fa4c0dfe90170c8a043fedab (patch)
treea1bca2fd48a75468127ce4b3ff2e2ac8eb09538f /drivers/leds/leds-sunfire.c
parentleds: convert PCA9532 LED driver to devm_kzalloc() (diff)
downloadlinux-234699a8f3228754fa4c0dfe90170c8a043fedab.tar.xz
linux-234699a8f3228754fa4c0dfe90170c8a043fedab.zip
leds: convert Sun Fire LED driver to devm_kzalloc() and cleanup error exit path
Cc: David S. Miller <davem@davemloft.net> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers/leds/leds-sunfire.c')
-rw-r--r--drivers/leds/leds-sunfire.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/drivers/leds/leds-sunfire.c b/drivers/leds/leds-sunfire.c
index 1757396b20b3..134d9a4b34f1 100644
--- a/drivers/leds/leds-sunfire.c
+++ b/drivers/leds/leds-sunfire.c
@@ -132,15 +132,13 @@ static int __devinit sunfire_led_generic_probe(struct platform_device *pdev,
if (pdev->num_resources != 1) {
printk(KERN_ERR PFX "Wrong number of resources %d, should be 1\n",
pdev->num_resources);
- err = -EINVAL;
- goto out;
+ return -EINVAL;
}
- p = kzalloc(sizeof(*p), GFP_KERNEL);
+ p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
if (!p) {
printk(KERN_ERR PFX "Could not allocate struct sunfire_drvdata\n");
- err = -ENOMEM;
- goto out;
+ return -ENOMEM;
}
for (i = 0; i < NUM_LEDS_PER_BOARD; i++) {
@@ -156,20 +154,15 @@ static int __devinit sunfire_led_generic_probe(struct platform_device *pdev,
if (err) {
printk(KERN_ERR PFX "Could not register %s LED\n",
lp->name);
- goto out_unregister_led_cdevs;
+ for (i--; i >= 0; i--)
+ led_classdev_unregister(&p->leds[i].led_cdev);
+ return err;
}
}
dev_set_drvdata(&pdev->dev, p);
return 0;
-
-out_unregister_led_cdevs:
- for (i--; i >= 0; i--)
- led_classdev_unregister(&p->leds[i].led_cdev);
- kfree(p);
-out:
- return err;
}
static int __devexit sunfire_led_generic_remove(struct platform_device *pdev)
@@ -180,8 +173,6 @@ static int __devexit sunfire_led_generic_remove(struct platform_device *pdev)
for (i = 0; i < NUM_LEDS_PER_BOARD; i++)
led_classdev_unregister(&p->leds[i].led_cdev);
- kfree(p);
-
return 0;
}