extcon: palmas: Use devm_extcon_dev_register()
Use the resource-managed extcon device register function (i.e. devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device is attached with this function, that extcon device is automatically unregistered on driver detach. That reduces tiresome managing code. Signed-off-by: Sangjung Woo <sangjung.woo@samsung.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
This commit is contained in:
parent
2923803d4f
commit
b4dad55abd
1 changed files with 5 additions and 10 deletions
|
@ -192,7 +192,7 @@ static int palmas_usb_probe(struct platform_device *pdev)
|
||||||
palmas_usb->edev.name = kstrdup(node->name, GFP_KERNEL);
|
palmas_usb->edev.name = kstrdup(node->name, GFP_KERNEL);
|
||||||
palmas_usb->edev.mutually_exclusive = mutually_exclusive;
|
palmas_usb->edev.mutually_exclusive = mutually_exclusive;
|
||||||
|
|
||||||
status = extcon_dev_register(&palmas_usb->edev);
|
status = devm_extcon_dev_register(&pdev->dev, &palmas_usb->edev);
|
||||||
if (status) {
|
if (status) {
|
||||||
dev_err(&pdev->dev, "failed to register extcon device\n");
|
dev_err(&pdev->dev, "failed to register extcon device\n");
|
||||||
kfree(palmas_usb->edev.name);
|
kfree(palmas_usb->edev.name);
|
||||||
|
@ -209,7 +209,8 @@ static int palmas_usb_probe(struct platform_device *pdev)
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
|
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
|
||||||
palmas_usb->id_irq, status);
|
palmas_usb->id_irq, status);
|
||||||
goto fail_extcon;
|
kfree(palmas_usb->edev.name);
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,26 +224,20 @@ static int palmas_usb_probe(struct platform_device *pdev)
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
|
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
|
||||||
palmas_usb->vbus_irq, status);
|
palmas_usb->vbus_irq, status);
|
||||||
goto fail_extcon;
|
kfree(palmas_usb->edev.name);
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
palmas_enable_irq(palmas_usb);
|
palmas_enable_irq(palmas_usb);
|
||||||
device_set_wakeup_capable(&pdev->dev, true);
|
device_set_wakeup_capable(&pdev->dev, true);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail_extcon:
|
|
||||||
extcon_dev_unregister(&palmas_usb->edev);
|
|
||||||
kfree(palmas_usb->edev.name);
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int palmas_usb_remove(struct platform_device *pdev)
|
static int palmas_usb_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
|
struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
extcon_dev_unregister(&palmas_usb->edev);
|
|
||||||
kfree(palmas_usb->edev.name);
|
kfree(palmas_usb->edev.name);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue