iio: proximity: pulsedlight: Fix rumtime PM imbalance on error
authorDinghao Liu <dinghao.liu@zju.edu.cn>
Mon, 12 Apr 2021 05:32:02 +0000 (13:32 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 May 2021 08:40:32 +0000 (10:40 +0200)
[ Upstream commit a2fa9242e89f27696515699fe0f0296bf1ac1815 ]

When lidar_write_control() fails, a pairing PM usage counter
decrement is needed to keep the counter balanced.

Fixes: 4ac4e086fd8c5 ("iio: pulsedlight-lidar-lite: add runtime PM")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210412053204.4889-1-dinghao.liu@zju.edu.cn
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c

index 3141c3c161bb4335cae5bc16f40c72339c474948..46e969a3a9b7e7ff306bffe6ad2badb6e173004a 100644 (file)
@@ -166,6 +166,7 @@ static int lidar_get_measurement(struct lidar_data *data, u16 *reg)
        ret = lidar_write_control(data, LIDAR_REG_CONTROL_ACQUIRE);
        if (ret < 0) {
                dev_err(&client->dev, "cannot send start measurement command");
+               pm_runtime_put_noidle(&client->dev);
                return ret;
        }