diff options
author | Bryan Wu <bryan.wu@canonical.com> | 2012-07-04 00:04:48 -0400 |
---|---|---|
committer | Bryan Wu <bryan.wu@canonical.com> | 2012-07-23 19:52:39 -0400 |
commit | 234699a8f3228754fa4c0dfe90170c8a043fedab (patch) | |
tree | a1bca2fd48a75468127ce4b3ff2e2ac8eb09538f /drivers/leds | |
parent | 0f4630c90b2c00dfb005d239d8926ec310fd560a (diff) |
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')
-rw-r--r-- | drivers/leds/leds-sunfire.c | 21 |
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, | |||
132 | if (pdev->num_resources != 1) { | 132 | if (pdev->num_resources != 1) { |
133 | printk(KERN_ERR PFX "Wrong number of resources %d, should be 1\n", | 133 | printk(KERN_ERR PFX "Wrong number of resources %d, should be 1\n", |
134 | pdev->num_resources); | 134 | pdev->num_resources); |
135 | err = -EINVAL; | 135 | return -EINVAL; |
136 | goto out; | ||
137 | } | 136 | } |
138 | 137 | ||
139 | p = kzalloc(sizeof(*p), GFP_KERNEL); | 138 | p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); |
140 | if (!p) { | 139 | if (!p) { |
141 | printk(KERN_ERR PFX "Could not allocate struct sunfire_drvdata\n"); | 140 | printk(KERN_ERR PFX "Could not allocate struct sunfire_drvdata\n"); |
142 | err = -ENOMEM; | 141 | return -ENOMEM; |
143 | goto out; | ||
144 | } | 142 | } |
145 | 143 | ||
146 | for (i = 0; i < NUM_LEDS_PER_BOARD; i++) { | 144 | for (i = 0; i < NUM_LEDS_PER_BOARD; i++) { |
@@ -156,20 +154,15 @@ static int __devinit sunfire_led_generic_probe(struct platform_device *pdev, | |||
156 | if (err) { | 154 | if (err) { |
157 | printk(KERN_ERR PFX "Could not register %s LED\n", | 155 | printk(KERN_ERR PFX "Could not register %s LED\n", |
158 | lp->name); | 156 | lp->name); |
159 | goto out_unregister_led_cdevs; | 157 | for (i--; i >= 0; i--) |
158 | led_classdev_unregister(&p->leds[i].led_cdev); | ||
159 | return err; | ||
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | dev_set_drvdata(&pdev->dev, p); | 163 | dev_set_drvdata(&pdev->dev, p); |
164 | 164 | ||
165 | return 0; | 165 | return 0; |
166 | |||
167 | out_unregister_led_cdevs: | ||
168 | for (i--; i >= 0; i--) | ||
169 | led_classdev_unregister(&p->leds[i].led_cdev); | ||
170 | kfree(p); | ||
171 | out: | ||
172 | return err; | ||
173 | } | 166 | } |
174 | 167 | ||
175 | static int __devexit sunfire_led_generic_remove(struct platform_device *pdev) | 168 | 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) | |||
180 | for (i = 0; i < NUM_LEDS_PER_BOARD; i++) | 173 | for (i = 0; i < NUM_LEDS_PER_BOARD; i++) |
181 | led_classdev_unregister(&p->leds[i].led_cdev); | 174 | led_classdev_unregister(&p->leds[i].led_cdev); |
182 | 175 | ||
183 | kfree(p); | ||
184 | |||
185 | return 0; | 176 | return 0; |
186 | } | 177 | } |
187 | 178 | ||