extcon: Set platform drvdata in gpio_extcon_probe() and fix irq leak
PATCH 1/2 extcon: Set platform drvdata in gpio_extcon_probe() and fix irq leak
Add missing platform_set_drvdata() in gpio_extcon_probe(), otherwise calling platform_get_drvdata in gpio_extcon_remove() returns NULL.
Also add missing free_irq call in gpio_extcon_remove().
Signed-off-by Axel Lin <[email protected]>
--- drivers/extcon/extcon_gpio.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/extcon/extcon_gpio.c +2 -0
@@ -125,6 +125,7 @@ static int __devinit gpio_extcon_probe(struct platform_device *pdev)if (ret <0 ) goto err_request_irq; +platform_set_drvdata (pdev, extcon_data);/* Perform initial detection */ gpio_extcon_work (&extcon_data->work.work);
@@ -146,6 +147,7 @@ static int __devexit gpio_extcon_remove(struct platform_device *pdev)struct gpio_extcon_data *extcon_data =platform_get_drvdata (pdev);cancel_delayed_work_sync (&extcon_data->work); +free_irq (extcon_data->irq, extcon_data);gpio_free (extcon_data->gpio);extcon_dev_unregister (&extcon_data->edev);devm_kfree (&pdev->dev, extcon_data);
Signature · 1 line
1.7.9.5
PATCH 2/2 extcon: Convert extcon_gpio to devm_gpio_request_one
Also remove unneeded devm_kfree calls.
Signed-off-by Axel Lin <[email protected]>
--- drivers/extcon/extcon_gpio.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/extcon/extcon_gpio.c +5 -12
@@ -105,25 +105,25 @@ static int __devinit gpio_extcon_probe(struct platform_device *pdev) ret =extcon_dev_register (&extcon_data->edev, &pdev->dev);if (ret <0 ) - goto err_extcon_dev_register; +return ret; ret =gpio_request_one (extcon_data->gpio,GPIOF_DIR_IN , pdev->name);if (ret <0 ) - goto err_request_gpio; + goto err;INIT_DELAYED_WORK (&extcon_data->work, gpio_extcon_work); extcon_data->irq =gpio_to_irq (extcon_data->gpio);if (extcon_data->irq <0 ) { ret = extcon_data->irq; - goto err_detect_irq_num_failed; + goto err; } ret =request_any_context_irq (extcon_data->irq, gpio_irq_handler, pdata->irq_flags, pdev->name, extcon_data);if (ret <0 ) - goto err_request_irq; + goto err;platform_set_drvdata (pdev, extcon_data);/* Perform initial detection */
@@ -131,13 +131,8 @@ static int __devinit gpio_extcon_probe(struct platform_device *pdev)return 0 ; -err_request_irq: -err_detect_irq_num_failed: -gpio_free (extcon_data->gpio); -err_request_gpio: +err:extcon_dev_unregister (&extcon_data->edev); -err_extcon_dev_register: -devm_kfree (&pdev->dev, extcon_data);return ret; }
@@ -148,9 +143,7 @@ static int __devexit gpio_extcon_remove(struct platform_device *pdev)cancel_delayed_work_sync (&extcon_data->work);free_irq (extcon_data->irq, extcon_data); -gpio_free (extcon_data->gpio);extcon_dev_unregister (&extcon_data->edev); -devm_kfree (&pdev->dev, extcon_data);return 0 ; }
Signature · 1 line
1.7.9.5