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

iio: gyro: fxa21002c: Balance runtime pm + use pm_runtime_resume_and_get().

In both the probe() error path and remove() pm_runtime_put_noidle()
is called which will decrement the runtime pm reference count.
However, there is no matching function to have raised the reference count.
Not this isn't a fix as the runtime pm core will stop the reference count
going negative anyway.

An alternative would have been to raise the count in these paths, but
it is not clear why that would be necessary.

Whilst we are here replace some boilerplate with pm_runtime_resume_and_get()
Found using coccicheck script under review at:
https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-2-jic23@kernel.org

+1 -10
+1 -10
drivers/iio/gyro/fxas21002c_core.c
··· 366 366 367 367 static int fxas21002c_pm_get(struct fxas21002c_data *data) 368 368 { 369 - struct device *dev = regmap_get_device(data->regmap); 370 - int ret; 371 - 372 - ret = pm_runtime_get_sync(dev); 373 - if (ret < 0) 374 - pm_runtime_put_noidle(dev); 375 - 376 - return ret; 369 + return pm_runtime_resume_and_get(regmap_get_device(data->regmap)); 377 370 } 378 371 379 372 static int fxas21002c_pm_put(struct fxas21002c_data *data) ··· 995 1002 pm_disable: 996 1003 pm_runtime_disable(dev); 997 1004 pm_runtime_set_suspended(dev); 998 - pm_runtime_put_noidle(dev); 999 1005 1000 1006 return ret; 1001 1007 } ··· 1008 1016 1009 1017 pm_runtime_disable(dev); 1010 1018 pm_runtime_set_suspended(dev); 1011 - pm_runtime_put_noidle(dev); 1012 1019 } 1013 1020 EXPORT_SYMBOL_GPL(fxas21002c_core_remove); 1014 1021