diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2012-11-20 01:46:47 -0500 |
---|---|---|
committer | MyungJoo Ham <myungjoo.ham@samsung.com> | 2012-11-21 06:01:16 -0500 |
commit | 0b672e9b21942fdfa63519fb66df4a40d6fafe35 (patch) | |
tree | ed710976a10f890883e1ae2f4d3ed6afdf55f4a9 /drivers/extcon/extcon-max8997.c | |
parent | 2ca36f4afd0b0c3b9f99e1c03bbfafeb39516cf6 (diff) |
extcon: max8997: Use devm_kzalloc
devm_kzalloc() is a device managed function. It makes error handling
and cleanup code a bit simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
Diffstat (limited to 'drivers/extcon/extcon-max8997.c')
-rw-r--r-- | drivers/extcon/extcon-max8997.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c index ffdbe8c962ae..8059325ce7da 100644 --- a/drivers/extcon/extcon-max8997.c +++ b/drivers/extcon/extcon-max8997.c | |||
@@ -433,11 +433,11 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev) | |||
433 | struct max8997_muic_info *info; | 433 | struct max8997_muic_info *info; |
434 | int ret, i; | 434 | int ret, i; |
435 | 435 | ||
436 | info = kzalloc(sizeof(struct max8997_muic_info), GFP_KERNEL); | 436 | info = devm_kzalloc(&pdev->dev, sizeof(struct max8997_muic_info), |
437 | GFP_KERNEL); | ||
437 | if (!info) { | 438 | if (!info) { |
438 | dev_err(&pdev->dev, "failed to allocate memory\n"); | 439 | dev_err(&pdev->dev, "failed to allocate memory\n"); |
439 | ret = -ENOMEM; | 440 | return -ENOMEM; |
440 | goto err_kfree; | ||
441 | } | 441 | } |
442 | 442 | ||
443 | info->dev = &pdev->dev; | 443 | info->dev = &pdev->dev; |
@@ -471,7 +471,8 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev) | |||
471 | } | 471 | } |
472 | 472 | ||
473 | /* External connector */ | 473 | /* External connector */ |
474 | info->edev = kzalloc(sizeof(struct extcon_dev), GFP_KERNEL); | 474 | info->edev = devm_kzalloc(&pdev->dev, sizeof(struct extcon_dev), |
475 | GFP_KERNEL); | ||
475 | if (!info->edev) { | 476 | if (!info->edev) { |
476 | dev_err(&pdev->dev, "failed to allocate memory for extcon\n"); | 477 | dev_err(&pdev->dev, "failed to allocate memory for extcon\n"); |
477 | ret = -ENOMEM; | 478 | ret = -ENOMEM; |
@@ -482,7 +483,7 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev) | |||
482 | ret = extcon_dev_register(info->edev, NULL); | 483 | ret = extcon_dev_register(info->edev, NULL); |
483 | if (ret) { | 484 | if (ret) { |
484 | dev_err(&pdev->dev, "failed to register extcon device\n"); | 485 | dev_err(&pdev->dev, "failed to register extcon device\n"); |
485 | goto err_extcon; | 486 | goto err_irq; |
486 | } | 487 | } |
487 | 488 | ||
488 | /* Initialize registers according to platform data */ | 489 | /* Initialize registers according to platform data */ |
@@ -500,13 +501,9 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev) | |||
500 | 501 | ||
501 | return ret; | 502 | return ret; |
502 | 503 | ||
503 | err_extcon: | ||
504 | kfree(info->edev); | ||
505 | err_irq: | 504 | err_irq: |
506 | while (--i >= 0) | 505 | while (--i >= 0) |
507 | free_irq(muic_irqs[i].virq, info); | 506 | free_irq(muic_irqs[i].virq, info); |
508 | kfree(info); | ||
509 | err_kfree: | ||
510 | return ret; | 507 | return ret; |
511 | } | 508 | } |
512 | 509 | ||
@@ -521,9 +518,6 @@ static int __devexit max8997_muic_remove(struct platform_device *pdev) | |||
521 | 518 | ||
522 | extcon_dev_unregister(info->edev); | 519 | extcon_dev_unregister(info->edev); |
523 | 520 | ||
524 | kfree(info->edev); | ||
525 | kfree(info); | ||
526 | |||
527 | return 0; | 521 | return 0; |
528 | } | 522 | } |
529 | 523 | ||