Commit 8edb79af authored by Dinghao Liu's avatar Dinghao Liu Committed by Jonathan Cameron

iio: light: gp2ap002: Fix rumtime PM imbalance on error

When devm_request_threaded_irq() fails, we should decrease the
runtime PM counter to keep the counter balanced. But when
iio_device_register() fails, we need not to decrease it because
we have already decreased it before.
Signed-off-by: default avatarDinghao Liu <dinghao.liu@zju.edu.cn>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Fixes: 97d642e2 ("iio: light: Add a driver for Sharp GP2AP002x00F")
Link: https://lore.kernel.org/r/20210407034927.16882-1-dinghao.liu@zju.edu.cnSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 6efb943b
...@@ -582,7 +582,7 @@ static int gp2ap002_probe(struct i2c_client *client, ...@@ -582,7 +582,7 @@ static int gp2ap002_probe(struct i2c_client *client,
"gp2ap002", indio_dev); "gp2ap002", indio_dev);
if (ret) { if (ret) {
dev_err(dev, "unable to request IRQ\n"); dev_err(dev, "unable to request IRQ\n");
goto out_disable_vio; goto out_put_pm;
} }
gp2ap002->irq = client->irq; gp2ap002->irq = client->irq;
...@@ -612,8 +612,9 @@ static int gp2ap002_probe(struct i2c_client *client, ...@@ -612,8 +612,9 @@ static int gp2ap002_probe(struct i2c_client *client,
return 0; return 0;
out_disable_pm: out_put_pm:
pm_runtime_put_noidle(dev); pm_runtime_put_noidle(dev);
out_disable_pm:
pm_runtime_disable(dev); pm_runtime_disable(dev);
out_disable_vio: out_disable_vio:
regulator_disable(gp2ap002->vio); regulator_disable(gp2ap002->vio);
......
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