mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-05 00:20:32 +00:00
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>
This commit is contained in:
parent
2ca36f4afd
commit
0b672e9b21
1 changed files with 6 additions and 12 deletions
|
@ -433,11 +433,11 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev)
|
||||||
struct max8997_muic_info *info;
|
struct max8997_muic_info *info;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
|
||||||
info = kzalloc(sizeof(struct max8997_muic_info), GFP_KERNEL);
|
info = devm_kzalloc(&pdev->dev, sizeof(struct max8997_muic_info),
|
||||||
|
GFP_KERNEL);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
dev_err(&pdev->dev, "failed to allocate memory\n");
|
dev_err(&pdev->dev, "failed to allocate memory\n");
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto err_kfree;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
info->dev = &pdev->dev;
|
info->dev = &pdev->dev;
|
||||||
|
@ -471,7 +471,8 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* External connector */
|
/* External connector */
|
||||||
info->edev = kzalloc(sizeof(struct extcon_dev), GFP_KERNEL);
|
info->edev = devm_kzalloc(&pdev->dev, sizeof(struct extcon_dev),
|
||||||
|
GFP_KERNEL);
|
||||||
if (!info->edev) {
|
if (!info->edev) {
|
||||||
dev_err(&pdev->dev, "failed to allocate memory for extcon\n");
|
dev_err(&pdev->dev, "failed to allocate memory for extcon\n");
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
@ -482,7 +483,7 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev)
|
||||||
ret = extcon_dev_register(info->edev, NULL);
|
ret = extcon_dev_register(info->edev, NULL);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "failed to register extcon device\n");
|
dev_err(&pdev->dev, "failed to register extcon device\n");
|
||||||
goto err_extcon;
|
goto err_irq;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize registers according to platform data */
|
/* Initialize registers according to platform data */
|
||||||
|
@ -500,13 +501,9 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
err_extcon:
|
|
||||||
kfree(info->edev);
|
|
||||||
err_irq:
|
err_irq:
|
||||||
while (--i >= 0)
|
while (--i >= 0)
|
||||||
free_irq(muic_irqs[i].virq, info);
|
free_irq(muic_irqs[i].virq, info);
|
||||||
kfree(info);
|
|
||||||
err_kfree:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,9 +518,6 @@ static int __devexit max8997_muic_remove(struct platform_device *pdev)
|
||||||
|
|
||||||
extcon_dev_unregister(info->edev);
|
extcon_dev_unregister(info->edev);
|
||||||
|
|
||||||
kfree(info->edev);
|
|
||||||
kfree(info);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue