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

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: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Matt Ranostay <matt.ranostay@konsulko.com>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210516162103.1332291-4-jic23@kernel.org

+4 -9
+4 -9
drivers/iio/chemical/atlas-sensor.c
··· 410 410 struct atlas_data *data = iio_priv(indio_dev); 411 411 int ret; 412 412 413 - ret = pm_runtime_get_sync(&data->client->dev); 414 - if (ret < 0) { 415 - pm_runtime_put_noidle(&data->client->dev); 413 + ret = pm_runtime_resume_and_get(&data->client->dev); 414 + if (ret) 416 415 return ret; 417 - } 418 416 419 417 return atlas_set_interrupt(data, true); 420 418 } ··· 485 487 int suspended = pm_runtime_suspended(dev); 486 488 int ret; 487 489 488 - ret = pm_runtime_get_sync(dev); 489 - if (ret < 0) { 490 - pm_runtime_put_noidle(dev); 490 + ret = pm_runtime_resume_and_get(dev); 491 + if (ret) 491 492 return ret; 492 - } 493 493 494 494 if (suspended) 495 495 msleep(data->chip->delay); ··· 737 741 738 742 pm_runtime_disable(&client->dev); 739 743 pm_runtime_set_suspended(&client->dev); 740 - pm_runtime_put_noidle(&client->dev); 741 744 742 745 return atlas_set_powermode(data, 0); 743 746 }