diff options
| author | Sangjung Woo <sangjung.woo@samsung.com> | 2014-04-21 06:10:10 -0400 |
|---|---|---|
| committer | Chanwoo Choi <cw00.choi@samsung.com> | 2014-04-24 06:37:03 -0400 |
| commit | d92c2f12f8a940444f28795ccbfa845fc358963e (patch) | |
| tree | daf8d12fd907198089ef7ca145f2cdfa40f7295f | |
| parent | 4b5dd738837aaac9cca98db1a39dc5ba1c802e45 (diff) | |
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>
| -rw-r--r-- | drivers/extcon/extcon-gpio.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index 13d522255d81..43af34c4a518 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c | |||
| @@ -121,34 +121,27 @@ static int gpio_extcon_probe(struct platform_device *pdev) | |||
| 121 | msecs_to_jiffies(pdata->debounce); | 121 | msecs_to_jiffies(pdata->debounce); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | ret = extcon_dev_register(&extcon_data->edev); | 124 | ret = devm_extcon_dev_register(&pdev->dev, &extcon_data->edev); |
| 125 | if (ret < 0) | 125 | if (ret < 0) |
| 126 | return ret; | 126 | return ret; |
| 127 | 127 | ||
| 128 | INIT_DELAYED_WORK(&extcon_data->work, gpio_extcon_work); | 128 | INIT_DELAYED_WORK(&extcon_data->work, gpio_extcon_work); |
| 129 | 129 | ||
| 130 | extcon_data->irq = gpio_to_irq(extcon_data->gpio); | 130 | extcon_data->irq = gpio_to_irq(extcon_data->gpio); |
| 131 | if (extcon_data->irq < 0) { | 131 | if (extcon_data->irq < 0) |
| 132 | ret = extcon_data->irq; | 132 | return extcon_data->irq; |
| 133 | goto err; | ||
| 134 | } | ||
| 135 | 133 | ||
| 136 | ret = request_any_context_irq(extcon_data->irq, gpio_irq_handler, | 134 | ret = request_any_context_irq(extcon_data->irq, gpio_irq_handler, |
| 137 | pdata->irq_flags, pdev->name, | 135 | pdata->irq_flags, pdev->name, |
| 138 | extcon_data); | 136 | extcon_data); |
| 139 | if (ret < 0) | 137 | if (ret < 0) |
| 140 | goto err; | 138 | return ret; |
| 141 | 139 | ||
| 142 | platform_set_drvdata(pdev, extcon_data); | 140 | platform_set_drvdata(pdev, extcon_data); |
| 143 | /* Perform initial detection */ | 141 | /* Perform initial detection */ |
| 144 | gpio_extcon_work(&extcon_data->work.work); | 142 | gpio_extcon_work(&extcon_data->work.work); |
| 145 | 143 | ||
| 146 | return 0; | 144 | return 0; |
| 147 | |||
| 148 | err: | ||
| 149 | extcon_dev_unregister(&extcon_data->edev); | ||
| 150 | |||
| 151 | return ret; | ||
| 152 | } | 145 | } |
| 153 | 146 | ||
| 154 | static int gpio_extcon_remove(struct platform_device *pdev) | 147 | static int gpio_extcon_remove(struct platform_device *pdev) |
| @@ -157,7 +150,6 @@ static int gpio_extcon_remove(struct platform_device *pdev) | |||
| 157 | 150 | ||
| 158 | cancel_delayed_work_sync(&extcon_data->work); | 151 | cancel_delayed_work_sync(&extcon_data->work); |
| 159 | free_irq(extcon_data->irq, extcon_data); | 152 | free_irq(extcon_data->irq, extcon_data); |
| 160 | extcon_dev_unregister(&extcon_data->edev); | ||
| 161 | 153 | ||
| 162 | return 0; | 154 | return 0; |
| 163 | } | 155 | } |
