summaryrefslogtreecommitdiff
path: root/drivers/extcon/extcon-usb-gpio.c
diff options
context:
space:
mode:
authorRobert Baldyga <r.baldyga@samsung.com>2015-04-02 15:13:02 +0200
committerChanwoo Choi <cw00.choi@samsung.com>2015-04-27 11:06:05 +0900
commitbc1aabad39f42fa293f2a944fd9327bba27b59cd (patch)
treef7f4527037d92b73b54e1a4c151c6447aa016761 /drivers/extcon/extcon-usb-gpio.c
parentb787f68c36d49bb1d9236f403813641efa74a031 (diff)
extcon: usb-gpio: register extcon device before IRQ registration
IRQ handler touches info->edev, so if interrupt occurs before extcon device initialization it can cause NULL pointer dereference. Doing extcon initialization before IRQ handler registration fixes this problem. Signed-off-by: Robert Baldyga <r.baldyga@samsung.com> Acked-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Diffstat (limited to 'drivers/extcon/extcon-usb-gpio.c')
-rw-r--r--drivers/extcon/extcon-usb-gpio.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c
index de67fce18984..e45d1f13f445 100644
--- a/drivers/extcon/extcon-usb-gpio.c
+++ b/drivers/extcon/extcon-usb-gpio.c
@@ -119,6 +119,18 @@ static int usb_extcon_probe(struct platform_device *pdev)
return PTR_ERR(info->id_gpiod);
}
+ info->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable);
+ if (IS_ERR(info->edev)) {
+ dev_err(dev, "failed to allocate extcon device\n");
+ return -ENOMEM;
+ }
+
+ ret = devm_extcon_dev_register(dev, info->edev);
+ if (ret < 0) {
+ dev_err(dev, "failed to register extcon device\n");
+ return ret;
+ }
+
ret = gpiod_set_debounce(info->id_gpiod,
USB_GPIO_DEBOUNCE_MS * 1000);
if (ret < 0)
@@ -142,18 +154,6 @@ static int usb_extcon_probe(struct platform_device *pdev)
return ret;
}
- info->edev = devm_extcon_dev_allocate(dev, usb_extcon_cable);
- if (IS_ERR(info->edev)) {
- dev_err(dev, "failed to allocate extcon device\n");
- return -ENOMEM;
- }
-
- ret = devm_extcon_dev_register(dev, info->edev);
- if (ret < 0) {
- dev_err(dev, "failed to register extcon device\n");
- return ret;
- }
-
platform_set_drvdata(pdev, info);
device_init_wakeup(dev, 1);