aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-pca955x.c
diff options
context:
space:
mode:
authorBryan Wu <bryan.wu@canonical.com>2012-07-04 00:09:05 -0400
committerBryan Wu <bryan.wu@canonical.com>2012-07-23 19:52:39 -0400
commit73759f6ab3620d605a5ce07d5316df1abb7edf18 (patch)
treef7d92a0e03187fa9489f7cb999c3fa816e0e0bac /drivers/leds/leds-pca955x.c
parent234699a8f3228754fa4c0dfe90170c8a043fedab (diff)
leds: convert PCA955x LED driver to devm_kzalloc() and cleanup error exit path
Cc: Nate Case <ncase@xes-inc.com> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers/leds/leds-pca955x.c')
-rw-r--r--drivers/leds/leds-pca955x.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
index 5f462dbf0dbb..aef3cf0432fe 100644
--- a/drivers/leds/leds-pca955x.c
+++ b/drivers/leds/leds-pca955x.c
@@ -293,15 +293,14 @@ static int __devinit pca955x_probe(struct i2c_client *client,
293 } 293 }
294 } 294 }
295 295
296 pca955x = kzalloc(sizeof(*pca955x), GFP_KERNEL); 296 pca955x = devm_kzalloc(&client->dev, sizeof(*pca955x), GFP_KERNEL);
297 if (!pca955x) 297 if (!pca955x)
298 return -ENOMEM; 298 return -ENOMEM;
299 299
300 pca955x->leds = kzalloc(sizeof(*pca955x_led) * chip->bits, GFP_KERNEL); 300 pca955x->leds = devm_kzalloc(&client->dev,
301 if (!pca955x->leds) { 301 sizeof(*pca955x_led) * chip->bits, GFP_KERNEL);
302 err = -ENOMEM; 302 if (!pca955x->leds)
303 goto exit_nomem; 303 return -ENOMEM;
304 }
305 304
306 i2c_set_clientdata(client, pca955x); 305 i2c_set_clientdata(client, pca955x);
307 306
@@ -361,10 +360,6 @@ exit:
361 cancel_work_sync(&pca955x->leds[i].work); 360 cancel_work_sync(&pca955x->leds[i].work);
362 } 361 }
363 362
364 kfree(pca955x->leds);
365exit_nomem:
366 kfree(pca955x);
367
368 return err; 363 return err;
369} 364}
370 365
@@ -378,9 +373,6 @@ static int __devexit pca955x_remove(struct i2c_client *client)
378 cancel_work_sync(&pca955x->leds[i].work); 373 cancel_work_sync(&pca955x->leds[i].work);
379 } 374 }
380 375
381 kfree(pca955x->leds);
382 kfree(pca955x);
383
384 return 0; 376 return 0;
385} 377}
386 378