diff options
author | Bryan Wu <bryan.wu@canonical.com> | 2012-07-04 00:24:40 -0400 |
---|---|---|
committer | Bryan Wu <bryan.wu@canonical.com> | 2012-07-23 19:52:40 -0400 |
commit | 0b873f3d507b43f7381fb6c377d0034ed6696d46 (patch) | |
tree | c1e7f76e3159b147d0aef19af4fa4a533cd28d88 /drivers/leds | |
parent | 6770fc60c4fb3fac9578013103012b7cd0355e44 (diff) |
leds: convert LM3530 LED driver to devm_kzalloc() and cleanup error exit path
Cc: Shreshtha Kumar SAHU <shreshthakumar.sahu@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/leds-lm3530.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c index 84ba6de8039c..23637bdb275d 100644 --- a/drivers/leds/leds-lm3530.c +++ b/drivers/leds/leds-lm3530.c | |||
@@ -386,28 +386,24 @@ static int __devinit lm3530_probe(struct i2c_client *client, | |||
386 | 386 | ||
387 | if (pdata == NULL) { | 387 | if (pdata == NULL) { |
388 | dev_err(&client->dev, "platform data required\n"); | 388 | dev_err(&client->dev, "platform data required\n"); |
389 | err = -ENODEV; | 389 | return -ENODEV; |
390 | goto err_out; | ||
391 | } | 390 | } |
392 | 391 | ||
393 | /* BL mode */ | 392 | /* BL mode */ |
394 | if (pdata->mode > LM3530_BL_MODE_PWM) { | 393 | if (pdata->mode > LM3530_BL_MODE_PWM) { |
395 | dev_err(&client->dev, "Illegal Mode request\n"); | 394 | dev_err(&client->dev, "Illegal Mode request\n"); |
396 | err = -EINVAL; | 395 | return -EINVAL; |
397 | goto err_out; | ||
398 | } | 396 | } |
399 | 397 | ||
400 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { | 398 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { |
401 | dev_err(&client->dev, "I2C_FUNC_I2C not supported\n"); | 399 | dev_err(&client->dev, "I2C_FUNC_I2C not supported\n"); |
402 | err = -EIO; | 400 | return -EIO; |
403 | goto err_out; | ||
404 | } | 401 | } |
405 | 402 | ||
406 | drvdata = kzalloc(sizeof(struct lm3530_data), GFP_KERNEL); | 403 | drvdata = devm_kzalloc(&client->dev, sizeof(struct lm3530_data), |
407 | if (drvdata == NULL) { | 404 | GFP_KERNEL); |
408 | err = -ENOMEM; | 405 | if (drvdata == NULL) |
409 | goto err_out; | 406 | return -ENOMEM; |
410 | } | ||
411 | 407 | ||
412 | drvdata->mode = pdata->mode; | 408 | drvdata->mode = pdata->mode; |
413 | drvdata->client = client; | 409 | drvdata->client = client; |
@@ -425,7 +421,7 @@ static int __devinit lm3530_probe(struct i2c_client *client, | |||
425 | dev_err(&client->dev, "regulator get failed\n"); | 421 | dev_err(&client->dev, "regulator get failed\n"); |
426 | err = PTR_ERR(drvdata->regulator); | 422 | err = PTR_ERR(drvdata->regulator); |
427 | drvdata->regulator = NULL; | 423 | drvdata->regulator = NULL; |
428 | goto err_regulator_get; | 424 | return err; |
429 | } | 425 | } |
430 | 426 | ||
431 | if (drvdata->pdata->brt_val) { | 427 | if (drvdata->pdata->brt_val) { |
@@ -458,9 +454,6 @@ err_create_file: | |||
458 | err_class_register: | 454 | err_class_register: |
459 | err_reg_init: | 455 | err_reg_init: |
460 | regulator_put(drvdata->regulator); | 456 | regulator_put(drvdata->regulator); |
461 | err_regulator_get: | ||
462 | kfree(drvdata); | ||
463 | err_out: | ||
464 | return err; | 457 | return err; |
465 | } | 458 | } |
466 | 459 | ||
@@ -474,7 +467,6 @@ static int __devexit lm3530_remove(struct i2c_client *client) | |||
474 | regulator_disable(drvdata->regulator); | 467 | regulator_disable(drvdata->regulator); |
475 | regulator_put(drvdata->regulator); | 468 | regulator_put(drvdata->regulator); |
476 | led_classdev_unregister(&drvdata->led_dev); | 469 | led_classdev_unregister(&drvdata->led_dev); |
477 | kfree(drvdata); | ||
478 | return 0; | 470 | return 0; |
479 | } | 471 | } |
480 | 472 | ||