aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/extcon
diff options
context:
space:
mode:
authorSangjung Woo <sangjung.woo@samsung.com>2014-04-21 06:10:14 -0400
committerChanwoo Choi <cw00.choi@samsung.com>2014-04-24 06:37:05 -0400
commitb4dad55abd47a23ca2c445d771c64204f7b12b49 (patch)
tree0185f45e805a9f390d522d8a703dd74c58ebbf48 /drivers/extcon
parent2923803d4f69fd8e4ed85786b8888986b2682154 (diff)
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>
Diffstat (limited to 'drivers/extcon')
-rw-r--r--drivers/extcon/extcon-palmas.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 51db5bcef720..1a770e0ee9ae 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -192,7 +192,7 @@ static int palmas_usb_probe(struct platform_device *pdev)
192 palmas_usb->edev.name = kstrdup(node->name, GFP_KERNEL); 192 palmas_usb->edev.name = kstrdup(node->name, GFP_KERNEL);
193 palmas_usb->edev.mutually_exclusive = mutually_exclusive; 193 palmas_usb->edev.mutually_exclusive = mutually_exclusive;
194 194
195 status = extcon_dev_register(&palmas_usb->edev); 195 status = devm_extcon_dev_register(&pdev->dev, &palmas_usb->edev);
196 if (status) { 196 if (status) {
197 dev_err(&pdev->dev, "failed to register extcon device\n"); 197 dev_err(&pdev->dev, "failed to register extcon device\n");
198 kfree(palmas_usb->edev.name); 198 kfree(palmas_usb->edev.name);
@@ -209,7 +209,8 @@ static int palmas_usb_probe(struct platform_device *pdev)
209 if (status < 0) { 209 if (status < 0) {
210 dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", 210 dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
211 palmas_usb->id_irq, status); 211 palmas_usb->id_irq, status);
212 goto fail_extcon; 212 kfree(palmas_usb->edev.name);
213 return status;
213 } 214 }
214 } 215 }
215 216
@@ -223,26 +224,20 @@ static int palmas_usb_probe(struct platform_device *pdev)
223 if (status < 0) { 224 if (status < 0) {
224 dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", 225 dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
225 palmas_usb->vbus_irq, status); 226 palmas_usb->vbus_irq, status);
226 goto fail_extcon; 227 kfree(palmas_usb->edev.name);
228 return status;
227 } 229 }
228 } 230 }
229 231
230 palmas_enable_irq(palmas_usb); 232 palmas_enable_irq(palmas_usb);
231 device_set_wakeup_capable(&pdev->dev, true); 233 device_set_wakeup_capable(&pdev->dev, true);
232 return 0; 234 return 0;
233
234fail_extcon:
235 extcon_dev_unregister(&palmas_usb->edev);
236 kfree(palmas_usb->edev.name);
237
238 return status;
239} 235}
240 236
241static int palmas_usb_remove(struct platform_device *pdev) 237static int palmas_usb_remove(struct platform_device *pdev)
242{ 238{
243 struct palmas_usb *palmas_usb = platform_get_drvdata(pdev); 239 struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
244 240
245 extcon_dev_unregister(&palmas_usb->edev);
246 kfree(palmas_usb->edev.name); 241 kfree(palmas_usb->edev.name);
247 242
248 return 0; 243 return 0;