Commit 0e4f336f authored by Jonathan Cameron's avatar Jonathan Cameron

iio: chemical: atlas-sensor: Balance runtime pm + pm_runtime_resume_and_get()

The pm_runtime_put_noidle() call in remove isn't balanced with any get, so
drop it.  Note this isn't a bug as the runtime pm core will not allow the
reference count to go negative, making this a noop. However, it is
confusing to the reader so let's drop it.

pm_runtime_resume_and_get() replacement found using the coccicheck script
under review at:
https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/

As pm_runtime_resume_and_get() returns <= 0 take advantage of that to
change the error checking to if (ret) which is more in keeping with the
rest of this driver.

This is a prequel to taking a closer look at the runtime pm in IIO drivers
in general.
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Matt Ranostay <matt.ranostay@konsulko.com>
Acked-by: default avatarMatt Ranostay <matt.ranostay@konsulko.com>
Reviewed-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210516162103.1332291-4-jic23@kernel.org
parent 17181d4d
...@@ -410,11 +410,9 @@ static int atlas_buffer_postenable(struct iio_dev *indio_dev) ...@@ -410,11 +410,9 @@ static int atlas_buffer_postenable(struct iio_dev *indio_dev)
struct atlas_data *data = iio_priv(indio_dev); struct atlas_data *data = iio_priv(indio_dev);
int ret; int ret;
ret = pm_runtime_get_sync(&data->client->dev); ret = pm_runtime_resume_and_get(&data->client->dev);
if (ret < 0) { if (ret)
pm_runtime_put_noidle(&data->client->dev);
return ret; return ret;
}
return atlas_set_interrupt(data, true); return atlas_set_interrupt(data, true);
} }
...@@ -487,11 +485,9 @@ static int atlas_read_measurement(struct atlas_data *data, int reg, __be32 *val) ...@@ -487,11 +485,9 @@ static int atlas_read_measurement(struct atlas_data *data, int reg, __be32 *val)
int suspended = pm_runtime_suspended(dev); int suspended = pm_runtime_suspended(dev);
int ret; int ret;
ret = pm_runtime_get_sync(dev); ret = pm_runtime_resume_and_get(dev);
if (ret < 0) { if (ret)
pm_runtime_put_noidle(dev);
return ret; return ret;
}
if (suspended) if (suspended)
msleep(data->chip->delay); msleep(data->chip->delay);
...@@ -741,7 +737,6 @@ static int atlas_remove(struct i2c_client *client) ...@@ -741,7 +737,6 @@ static int atlas_remove(struct i2c_client *client)
pm_runtime_disable(&client->dev); pm_runtime_disable(&client->dev);
pm_runtime_set_suspended(&client->dev); pm_runtime_set_suspended(&client->dev);
pm_runtime_put_noidle(&client->dev);
return atlas_set_powermode(data, 0); return atlas_set_powermode(data, 0);
} }
......
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