Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: pressure: icp10100: Balance runtime pm + use pm_runtime_resume_and_get()

The devm_ handled runtime pm disable calls pm_runtime_put_sync_suspend()
which isn't balancing a matching get call. It isn't a bug as such,
because the runtime pm core doesn't decrement the reference count below
zero, but it is missleading so let's drop it.

Using pm_runtime_resume_and_get() new call makes it easy to handle
failures in resume as it doesn't hold a reference count if it exits
with an error.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210516162103.1332291-7-jic23@kernel.org

+3 -2
+3 -2
drivers/iio/pressure/icp10100.c
··· 250 250 __be16 measures[3]; 251 251 int ret; 252 252 253 - pm_runtime_get_sync(&st->client->dev); 253 + ret = pm_runtime_resume_and_get(&st->client->dev); 254 + if (ret < 0) 255 + return ret; 254 256 255 257 mutex_lock(&st->lock); 256 258 cmd = &icp10100_cmd_measure[st->mode]; ··· 527 525 { 528 526 struct device *dev = data; 529 527 530 - pm_runtime_put_sync_suspend(dev); 531 528 pm_runtime_disable(dev); 532 529 } 533 530