[PATCH 4/8] extcon: max14577: Use devm_extcon_dev_register()

Sangjung Woo
2014-04-16T10:27:39Z

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>
---
drivers/extcon/extcon-max14577.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
index 1fef08d..c6166e7 100644
--- a/drivers/extcon/extcon-max14577.c
+++ b/drivers/extcon/extcon-max14577.c
@@ -675,7 +675,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
}
info->edev->name = DEV_NAME;
info->edev->supported_cable = max14577_extcon_cable;
- ret = extcon_dev_register(info->edev);
+ ret = devm_extcon_dev_register(&pdev->dev, info->edev);
if (ret) {
dev_err(&pdev->dev, "failed to register extcon device\n");
return ret;
@@ -694,7 +694,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
MAX14577_REG_DEVICEID, &id);
if (ret < 0) {
dev_err(&pdev->dev, "failed to read revision number\n");
- goto err_extcon;
+ return ret;
}
dev_info(info->dev, "device ID : 0x%x\n", id);

@@ -714,10 +714,6 @@ static int max14577_muic_probe(struct platform_device *pdev)
delay_jiffies);

return ret;
-
-err_extcon:
- extcon_dev_unregister(info->edev);
- return ret;
}

static int max14577_muic_remove(struct platform_device *pdev)
@@ -725,7 +721,6 @@ static int max14577_muic_remove(struct platform_device *pdev)
struct max14577_muic_info *info = platform_get_drvdata(pdev);

cancel_work_sync(&info->irq_work);
- extcon_dev_unregister(info->edev);

return 0;
}
--
1.7.9.5