Commit b2e5575a authored by Dinghao Liu's avatar Dinghao Liu Committed by Chanwoo Choi

extcon: arizona: Fix runtime PM imbalance on error

When arizona_request_irq() returns an error code, a
pairing runtime PM usage counter decrement is needed
to keep the counter balanced. For error paths after
this function, things are the same.

Also, remove calls to pm_runtime_disable() when
pm_runtime_enable() has not been executed.
Signed-off-by: default avatarDinghao Liu <dinghao.liu@zju.edu.cn>
Signed-off-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
parent 3d6954dd
...@@ -1460,7 +1460,7 @@ static int arizona_extcon_probe(struct platform_device *pdev) ...@@ -1460,7 +1460,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
if (!info->input) { if (!info->input) {
dev_err(arizona->dev, "Can't allocate input dev\n"); dev_err(arizona->dev, "Can't allocate input dev\n");
ret = -ENOMEM; ret = -ENOMEM;
goto err_register; return ret;
} }
info->input->name = "Headset"; info->input->name = "Headset";
...@@ -1492,7 +1492,7 @@ static int arizona_extcon_probe(struct platform_device *pdev) ...@@ -1492,7 +1492,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
if (ret != 0) { if (ret != 0) {
dev_err(arizona->dev, "Failed to request GPIO%d: %d\n", dev_err(arizona->dev, "Failed to request GPIO%d: %d\n",
pdata->micd_pol_gpio, ret); pdata->micd_pol_gpio, ret);
goto err_register; return ret;
} }
info->micd_pol_gpio = gpio_to_desc(pdata->micd_pol_gpio); info->micd_pol_gpio = gpio_to_desc(pdata->micd_pol_gpio);
...@@ -1515,7 +1515,7 @@ static int arizona_extcon_probe(struct platform_device *pdev) ...@@ -1515,7 +1515,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
dev_err(arizona->dev, dev_err(arizona->dev,
"Failed to get microphone polarity GPIO: %d\n", "Failed to get microphone polarity GPIO: %d\n",
ret); ret);
goto err_register; return ret;
} }
} }
...@@ -1672,7 +1672,7 @@ static int arizona_extcon_probe(struct platform_device *pdev) ...@@ -1672,7 +1672,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "Failed to get JACKDET rise IRQ: %d\n", dev_err(&pdev->dev, "Failed to get JACKDET rise IRQ: %d\n",
ret); ret);
goto err_gpio; goto err_pm;
} }
ret = arizona_set_irq_wake(arizona, jack_irq_rise, 1); ret = arizona_set_irq_wake(arizona, jack_irq_rise, 1);
...@@ -1721,14 +1721,14 @@ static int arizona_extcon_probe(struct platform_device *pdev) ...@@ -1721,14 +1721,14 @@ static int arizona_extcon_probe(struct platform_device *pdev)
dev_warn(arizona->dev, "Failed to set MICVDD to bypass: %d\n", dev_warn(arizona->dev, "Failed to set MICVDD to bypass: %d\n",
ret); ret);
pm_runtime_put(&pdev->dev);
ret = input_register_device(info->input); ret = input_register_device(info->input);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Can't register input device: %d\n", ret); dev_err(&pdev->dev, "Can't register input device: %d\n", ret);
goto err_hpdet; goto err_hpdet;
} }
pm_runtime_put(&pdev->dev);
return 0; return 0;
err_hpdet: err_hpdet:
...@@ -1743,10 +1743,11 @@ static int arizona_extcon_probe(struct platform_device *pdev) ...@@ -1743,10 +1743,11 @@ static int arizona_extcon_probe(struct platform_device *pdev)
arizona_set_irq_wake(arizona, jack_irq_rise, 0); arizona_set_irq_wake(arizona, jack_irq_rise, 0);
err_rise: err_rise:
arizona_free_irq(arizona, jack_irq_rise, info); arizona_free_irq(arizona, jack_irq_rise, info);
err_pm:
pm_runtime_put(&pdev->dev);
pm_runtime_disable(&pdev->dev);
err_gpio: err_gpio:
gpiod_put(info->micd_pol_gpio); gpiod_put(info->micd_pol_gpio);
err_register:
pm_runtime_disable(&pdev->dev);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment