extcon: gpio: 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
4b5dd73883
commit
d92c2f12f8
|
@ -121,34 +121,27 @@ static int gpio_extcon_probe(struct platform_device *pdev)
|
||||||
msecs_to_jiffies(pdata->debounce);
|
msecs_to_jiffies(pdata->debounce);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = extcon_dev_register(&extcon_data->edev);
|
ret = devm_extcon_dev_register(&pdev->dev, &extcon_data->edev);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
INIT_DELAYED_WORK(&extcon_data->work, gpio_extcon_work);
|
INIT_DELAYED_WORK(&extcon_data->work, gpio_extcon_work);
|
||||||
|
|
||||||
extcon_data->irq = gpio_to_irq(extcon_data->gpio);
|
extcon_data->irq = gpio_to_irq(extcon_data->gpio);
|
||||||
if (extcon_data->irq < 0) {
|
if (extcon_data->irq < 0)
|
||||||
ret = extcon_data->irq;
|
return extcon_data->irq;
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = request_any_context_irq(extcon_data->irq, gpio_irq_handler,
|
ret = request_any_context_irq(extcon_data->irq, gpio_irq_handler,
|
||||||
pdata->irq_flags, pdev->name,
|
pdata->irq_flags, pdev->name,
|
||||||
extcon_data);
|
extcon_data);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err;
|
return ret;
|
||||||
|
|
||||||
platform_set_drvdata(pdev, extcon_data);
|
platform_set_drvdata(pdev, extcon_data);
|
||||||
/* Perform initial detection */
|
/* Perform initial detection */
|
||||||
gpio_extcon_work(&extcon_data->work.work);
|
gpio_extcon_work(&extcon_data->work.work);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err:
|
|
||||||
extcon_dev_unregister(&extcon_data->edev);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gpio_extcon_remove(struct platform_device *pdev)
|
static int gpio_extcon_remove(struct platform_device *pdev)
|
||||||
|
@ -157,7 +150,6 @@ static int gpio_extcon_remove(struct platform_device *pdev)
|
||||||
|
|
||||||
cancel_delayed_work_sync(&extcon_data->work);
|
cancel_delayed_work_sync(&extcon_data->work);
|
||||||
free_irq(extcon_data->irq, extcon_data);
|
free_irq(extcon_data->irq, extcon_data);
|
||||||
extcon_dev_unregister(&extcon_data->edev);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue