diff mbox series

thermal/drivers/tsens: fix missing put_device error

Message ID 20210404043219.11334-1-zhuguangqing83@gmail.com (mailing list archive)
State New, archived
Delegated to: Daniel Lezcano
Headers show
Series thermal/drivers/tsens: fix missing put_device error | expand

Commit Message

guangqing zhu April 4, 2021, 4:32 a.m. UTC
From: Guangqing Zhu <zhuguangqing83@gmail.com>

Fixes coccicheck error:

drivers/thermal/qcom/tsens.c:759:4-10: ERROR: missing put_device; call
of_find_device_by_node on line 715, but without a corresponding object
release within this function.

Fixes: a7ff82976122 ("drivers: thermal: tsens: Merge tsens-common.c into
tsens.c")

Signed-off-by: Guangqing Zhu <zhuguangqing83@gmail.com>
---
 drivers/thermal/qcom/tsens.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

kernel test robot April 4, 2021, 5:56 a.m. UTC | #1
Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.12-rc5 next-20210401]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/zhuguangqing83-gmail-com/thermal-drivers-tsens-fix-missing-put_device-error/20210404-123439
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2023a53bdf41b7646b1d384b6816af06309f73a5
config: arm64-randconfig-r004-20210404 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/8c940b4ee5ee1d96be026eee71f0c682262f94e4
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review zhuguangqing83-gmail-com/thermal-drivers-tsens-fix-missing-put_device-error/20210404-123439
        git checkout 8c940b4ee5ee1d96be026eee71f0c682262f94e4
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   drivers/thermal/qcom/tsens.c: In function 'init_common':
>> drivers/thermal/qcom/tsens.c:856:12: error: invalid storage class for function 'tsens_get_temp'
     856 | static int tsens_get_temp(void *data, int *temp)
         |            ^~~~~~~~~~~~~~
>> drivers/thermal/qcom/tsens.c:856:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     856 | static int tsens_get_temp(void *data, int *temp)
         | ^~~~~~
>> drivers/thermal/qcom/tsens.c:864:12: error: invalid storage class for function 'tsens_get_trend'
     864 | static int tsens_get_trend(void *data, int trip, enum thermal_trend *trend)
         |            ^~~~~~~~~~~~~~~
>> drivers/thermal/qcom/tsens.c:875:28: error: invalid storage class for function 'tsens_suspend'
     875 | static int  __maybe_unused tsens_suspend(struct device *dev)
         |                            ^~~~~~~~~~~~~
>> drivers/thermal/qcom/tsens.c:885:27: error: invalid storage class for function 'tsens_resume'
     885 | static int __maybe_unused tsens_resume(struct device *dev)
         |                           ^~~~~~~~~~~~
   In file included from include/linux/device.h:25,
                    from include/linux/of_platform.h:9,
                    from drivers/thermal/qcom/tsens.c:14:
>> drivers/thermal/qcom/tsens.c:895:40: error: initializer element is not constant
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |                                        ^~~~~~~~~~~~~
   include/linux/pm.h:306:13: note: in definition of macro 'SET_SYSTEM_SLEEP_PM_OPS'
     306 |  .suspend = suspend_fn, \
         |             ^~~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:8: note: in expansion of macro 'SIMPLE_DEV_PM_OPS'
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |        ^~~~~~~~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:40: note: (near initialization for 'tsens_pm_ops.suspend')
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |                                        ^~~~~~~~~~~~~
   include/linux/pm.h:306:13: note: in definition of macro 'SET_SYSTEM_SLEEP_PM_OPS'
     306 |  .suspend = suspend_fn, \
         |             ^~~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:8: note: in expansion of macro 'SIMPLE_DEV_PM_OPS'
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |        ^~~~~~~~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:55: error: initializer element is not constant
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |                                                       ^~~~~~~~~~~~
   include/linux/pm.h:307:12: note: in definition of macro 'SET_SYSTEM_SLEEP_PM_OPS'
     307 |  .resume = resume_fn, \
         |            ^~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:8: note: in expansion of macro 'SIMPLE_DEV_PM_OPS'
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |        ^~~~~~~~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:55: note: (near initialization for 'tsens_pm_ops.resume')
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |                                                       ^~~~~~~~~~~~
   include/linux/pm.h:307:12: note: in definition of macro 'SET_SYSTEM_SLEEP_PM_OPS'
     307 |  .resume = resume_fn, \
         |            ^~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:8: note: in expansion of macro 'SIMPLE_DEV_PM_OPS'
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |        ^~~~~~~~~~~~~~~~~
>> drivers/thermal/qcom/tsens.c:895:40: error: initializer element is not constant
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |                                        ^~~~~~~~~~~~~
   include/linux/pm.h:308:12: note: in definition of macro 'SET_SYSTEM_SLEEP_PM_OPS'
     308 |  .freeze = suspend_fn, \
         |            ^~~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:8: note: in expansion of macro 'SIMPLE_DEV_PM_OPS'
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |        ^~~~~~~~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:40: note: (near initialization for 'tsens_pm_ops.freeze')
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |                                        ^~~~~~~~~~~~~
   include/linux/pm.h:308:12: note: in definition of macro 'SET_SYSTEM_SLEEP_PM_OPS'
     308 |  .freeze = suspend_fn, \
         |            ^~~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:8: note: in expansion of macro 'SIMPLE_DEV_PM_OPS'
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |        ^~~~~~~~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:55: error: initializer element is not constant
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |                                                       ^~~~~~~~~~~~
   include/linux/pm.h:309:10: note: in definition of macro 'SET_SYSTEM_SLEEP_PM_OPS'
     309 |  .thaw = resume_fn, \
         |          ^~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:8: note: in expansion of macro 'SIMPLE_DEV_PM_OPS'
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |        ^~~~~~~~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:55: note: (near initialization for 'tsens_pm_ops.thaw')
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |                                                       ^~~~~~~~~~~~
   include/linux/pm.h:309:10: note: in definition of macro 'SET_SYSTEM_SLEEP_PM_OPS'
     309 |  .thaw = resume_fn, \
         |          ^~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:8: note: in expansion of macro 'SIMPLE_DEV_PM_OPS'
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |        ^~~~~~~~~~~~~~~~~
>> drivers/thermal/qcom/tsens.c:895:40: error: initializer element is not constant
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |                                        ^~~~~~~~~~~~~
   include/linux/pm.h:310:14: note: in definition of macro 'SET_SYSTEM_SLEEP_PM_OPS'
     310 |  .poweroff = suspend_fn, \
         |              ^~~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:8: note: in expansion of macro 'SIMPLE_DEV_PM_OPS'
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |        ^~~~~~~~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:40: note: (near initialization for 'tsens_pm_ops.poweroff')
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |                                        ^~~~~~~~~~~~~
   include/linux/pm.h:310:14: note: in definition of macro 'SET_SYSTEM_SLEEP_PM_OPS'
     310 |  .poweroff = suspend_fn, \
         |              ^~~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:8: note: in expansion of macro 'SIMPLE_DEV_PM_OPS'
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |        ^~~~~~~~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:55: error: initializer element is not constant
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |                                                       ^~~~~~~~~~~~
   include/linux/pm.h:311:13: note: in definition of macro 'SET_SYSTEM_SLEEP_PM_OPS'
     311 |  .restore = resume_fn,
         |             ^~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:8: note: in expansion of macro 'SIMPLE_DEV_PM_OPS'
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |        ^~~~~~~~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:55: note: (near initialization for 'tsens_pm_ops.restore')
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |                                                       ^~~~~~~~~~~~
   include/linux/pm.h:311:13: note: in definition of macro 'SET_SYSTEM_SLEEP_PM_OPS'
     311 |  .restore = resume_fn,
         |             ^~~~~~~~~
   drivers/thermal/qcom/tsens.c:895:8: note: in expansion of macro 'SIMPLE_DEV_PM_OPS'
     895 | static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
         |        ^~~~~~~~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:925:14: error: initializer element is not constant
     925 |  .get_temp = tsens_get_temp,
         |              ^~~~~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:925:14: note: (near initialization for 'tsens_of_ops.get_temp')
   drivers/thermal/qcom/tsens.c:926:15: error: initializer element is not constant
     926 |  .get_trend = tsens_get_trend,
         |               ^~~~~~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:926:15: note: (near initialization for 'tsens_of_ops.get_trend')
   drivers/thermal/qcom/tsens.c:924:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     924 | static const struct thermal_zone_of_device_ops tsens_of_ops = {
         | ^~~~~~
>> drivers/thermal/qcom/tsens.c:930:12: error: invalid storage class for function 'tsens_register_irq'
     930 | static int tsens_register_irq(struct tsens_priv *priv, char *irqname,
         |            ^~~~~~~~~~~~~~~~~~
>> drivers/thermal/qcom/tsens.c:962:12: error: invalid storage class for function 'tsens_register'
     962 | static int tsens_register(struct tsens_priv *priv)
         |            ^~~~~~~~~~~~~~
>> drivers/thermal/qcom/tsens.c:990:12: error: invalid storage class for function 'tsens_probe'
     990 | static int tsens_probe(struct platform_device *pdev)
         |            ^~~~~~~~~~~
>> drivers/thermal/qcom/tsens.c:1064:12: error: invalid storage class for function 'tsens_remove'
    1064 | static int tsens_remove(struct platform_device *pdev)
         |            ^~~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:1077:11: error: initializer element is not constant
    1077 |  .probe = tsens_probe,
         |           ^~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:1077:11: note: (near initialization for 'tsens_driver.probe')
   drivers/thermal/qcom/tsens.c:1078:12: error: initializer element is not constant
    1078 |  .remove = tsens_remove,
         |            ^~~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:1078:12: note: (near initialization for 'tsens_driver.remove')
   In file included from include/linux/device.h:32,
                    from include/linux/of_platform.h:9,
                    from drivers/thermal/qcom/tsens.c:14:
>> drivers/thermal/qcom/tsens.c:1085:24: error: invalid storage class for function 'tsens_driver_init'
    1085 | module_platform_driver(tsens_driver);
         |                        ^~~~~~~~~~~~
   include/linux/device/driver.h:259:19: note: in definition of macro 'module_driver'
     259 | static int __init __driver##_init(void) \
         |                   ^~~~~~~~
   drivers/thermal/qcom/tsens.c:1085:1: note: in expansion of macro 'module_platform_driver'
    1085 | module_platform_driver(tsens_driver);
         | ^~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/export.h:43,
                    from include/linux/linkage.h:7,
                    from include/linux/fs.h:5,
                    from include/linux/debugfs.h:15,
                    from drivers/thermal/qcom/tsens.c:7:
>> include/linux/compiler.h:226:46: error: initializer element is not constant
     226 |   __UNIQUE_ID(__PASTE(__addressable_,sym)) = (void *)&sym;
         |                                              ^
   include/linux/init.h:236:2: note: in expansion of macro '__ADDRESSABLE'
     236 |  __ADDRESSABLE(fn)
         |  ^~~~~~~~~~~~~
   include/linux/init.h:241:2: note: in expansion of macro '__define_initcall_stub'
     241 |  __define_initcall_stub(__stub, fn)   \
         |  ^~~~~~~~~~~~~~~~~~~~~~
   include/linux/init.h:253:2: note: in expansion of macro '____define_initcall'
     253 |  ____define_initcall(fn,     \
         |  ^~~~~~~~~~~~~~~~~~~
   include/linux/init.h:259:2: note: in expansion of macro '__unique_initcall'
     259 |  __unique_initcall(fn, id, __sec, __initcall_id(fn))
         |  ^~~~~~~~~~~~~~~~~
   include/linux/init.h:261:35: note: in expansion of macro '___define_initcall'
     261 | #define __define_initcall(fn, id) ___define_initcall(fn, id, .initcall##id)
         |                                   ^~~~~~~~~~~~~~~~~~
   include/linux/init.h:290:30: note: in expansion of macro '__define_initcall'
     290 | #define device_initcall(fn)  __define_initcall(fn, 6)
         |                              ^~~~~~~~~~~~~~~~~
   include/linux/init.h:295:24: note: in expansion of macro 'device_initcall'
     295 | #define __initcall(fn) device_initcall(fn)
         |                        ^~~~~~~~~~~~~~~
   include/linux/module.h:86:24: note: in expansion of macro '__initcall'
      86 | #define module_init(x) __initcall(x);
         |                        ^~~~~~~~~~
   include/linux/device/driver.h:263:1: note: in expansion of macro 'module_init'
     263 | module_init(__driver##_init); \
         | ^~~~~~~~~~~
   include/linux/platform_device.h:257:2: note: in expansion of macro 'module_driver'
     257 |  module_driver(__platform_driver, platform_driver_register, \
         |  ^~~~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:1085:1: note: in expansion of macro 'module_platform_driver'
    1085 | module_platform_driver(tsens_driver);
         | ^~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/device.h:32,
                    from include/linux/of_platform.h:9,
                    from drivers/thermal/qcom/tsens.c:14:
>> drivers/thermal/qcom/tsens.c:1085:24: error: invalid storage class for function 'tsens_driver_exit'
    1085 | module_platform_driver(tsens_driver);
         |                        ^~~~~~~~~~~~
   include/linux/device/driver.h:264:20: note: in definition of macro 'module_driver'
     264 | static void __exit __driver##_exit(void) \
         |                    ^~~~~~~~
   drivers/thermal/qcom/tsens.c:1085:1: note: in expansion of macro 'module_platform_driver'
    1085 | module_platform_driver(tsens_driver);
         | ^~~~~~~~~~~~~~~~~~~~~~
>> include/linux/device/driver.h:264:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     264 | static void __exit __driver##_exit(void) \
         | ^~~~~~
   include/linux/platform_device.h:257:2: note: in expansion of macro 'module_driver'
     257 |  module_driver(__platform_driver, platform_driver_register, \
         |  ^~~~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:1085:1: note: in expansion of macro 'module_platform_driver'
    1085 | module_platform_driver(tsens_driver);
         | ^~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/printk.h:6,
                    from include/linux/kernel.h:16,
                    from include/linux/list.h:9,
                    from include/linux/wait.h:7,
                    from include/linux/wait_bit.h:8,
                    from include/linux/fs.h:6,
                    from include/linux/debugfs.h:15,
                    from drivers/thermal/qcom/tsens.c:7:
   drivers/thermal/qcom/tsens.c:1085:24: error: initializer element is not constant
    1085 | module_platform_driver(tsens_driver);
         |                        ^~~~~~~~~~~~
   include/linux/init.h:298:50: note: in definition of macro '__exitcall'
     298 |  static exitcall_t __exitcall_##fn __exit_call = fn
         |                                                  ^~
   include/linux/device/driver.h:268:1: note: in expansion of macro 'module_exit'
     268 | module_exit(__driver##_exit);
         | ^~~~~~~~~~~
   include/linux/platform_device.h:257:2: note: in expansion of macro 'module_driver'
     257 |  module_driver(__platform_driver, platform_driver_register, \
         |  ^~~~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:1085:1: note: in expansion of macro 'module_platform_driver'
    1085 | module_platform_driver(tsens_driver);
         | ^~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/module.h:21,
                    from drivers/thermal/qcom/tsens.c:10:
>> include/linux/moduleparam.h:24:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
      24 |  static const char __UNIQUE_ID(name)[]      \
         |  ^~~~~~
   include/linux/module.h:160:32: note: in expansion of macro '__MODULE_INFO'
     160 | #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
         |                                ^~~~~~~~~~~~~
   include/linux/module.h:177:21: note: in expansion of macro 'MODULE_INFO'
     177 | #define MODULE_FILE MODULE_INFO(file, KBUILD_MODFILE);
         |                     ^~~~~~~~~~~
   include/linux/module.h:224:34: note: in expansion of macro 'MODULE_FILE'
     224 | #define MODULE_LICENSE(_license) MODULE_FILE MODULE_INFO(license, _license)
         |                                  ^~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:1087:1: note: in expansion of macro 'MODULE_LICENSE'
    1087 | MODULE_LICENSE("GPL v2");
         | ^~~~~~~~~~~~~~
>> drivers/thermal/qcom/tsens.c:1089:1: error: expected declaration or statement at end of input
    1089 | MODULE_ALIAS("platform:qcom-tsens");
         | ^~~~~~~~~~~~
   drivers/thermal/qcom/tsens.c:1089:1: error: control reaches end of non-void function [-Werror=return-type]
    1089 | MODULE_ALIAS("platform:qcom-tsens");
         | ^~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +/tsens_get_temp +856 drivers/thermal/qcom/tsens.c

a7ff82976122eb Amit Kucheria              2020-04-29   855  
9066073c6c2799 Rajendra Nayak             2016-05-05  @856  static int tsens_get_temp(void *data, int *temp)
9066073c6c2799 Rajendra Nayak             2016-05-05   857  {
8b71bce407b3f1 Amit Kucheria              2019-11-01   858  	struct tsens_sensor *s = data;
69b628ac71f07d Amit Kucheria              2019-03-20   859  	struct tsens_priv *priv = s->priv;
9066073c6c2799 Rajendra Nayak             2016-05-05   860  
8b71bce407b3f1 Amit Kucheria              2019-11-01   861  	return priv->ops->get_temp(s, temp);
9066073c6c2799 Rajendra Nayak             2016-05-05   862  }
9066073c6c2799 Rajendra Nayak             2016-05-05   863  
2cbcd2eab01b28 Amit Kucheria              2019-03-20  @864  static int tsens_get_trend(void *data, int trip, enum thermal_trend *trend)
9066073c6c2799 Rajendra Nayak             2016-05-05   865  {
8b71bce407b3f1 Amit Kucheria              2019-11-01   866  	struct tsens_sensor *s = data;
69b628ac71f07d Amit Kucheria              2019-03-20   867  	struct tsens_priv *priv = s->priv;
9066073c6c2799 Rajendra Nayak             2016-05-05   868  
69b628ac71f07d Amit Kucheria              2019-03-20   869  	if (priv->ops->get_trend)
8b71bce407b3f1 Amit Kucheria              2019-11-01   870  		return priv->ops->get_trend(s, trend);
9066073c6c2799 Rajendra Nayak             2016-05-05   871  
9066073c6c2799 Rajendra Nayak             2016-05-05   872  	return -ENOTSUPP;
9066073c6c2799 Rajendra Nayak             2016-05-05   873  }
9066073c6c2799 Rajendra Nayak             2016-05-05   874  
5b97469a55872a Arnd Bergmann              2016-07-04  @875  static int  __maybe_unused tsens_suspend(struct device *dev)
9066073c6c2799 Rajendra Nayak             2016-05-05   876  {
69b628ac71f07d Amit Kucheria              2019-03-20   877  	struct tsens_priv *priv = dev_get_drvdata(dev);
9066073c6c2799 Rajendra Nayak             2016-05-05   878  
69b628ac71f07d Amit Kucheria              2019-03-20   879  	if (priv->ops && priv->ops->suspend)
69b628ac71f07d Amit Kucheria              2019-03-20   880  		return priv->ops->suspend(priv);
9066073c6c2799 Rajendra Nayak             2016-05-05   881  
9066073c6c2799 Rajendra Nayak             2016-05-05   882  	return 0;
9066073c6c2799 Rajendra Nayak             2016-05-05   883  }
9066073c6c2799 Rajendra Nayak             2016-05-05   884  
5b97469a55872a Arnd Bergmann              2016-07-04  @885  static int __maybe_unused tsens_resume(struct device *dev)
9066073c6c2799 Rajendra Nayak             2016-05-05   886  {
69b628ac71f07d Amit Kucheria              2019-03-20   887  	struct tsens_priv *priv = dev_get_drvdata(dev);
9066073c6c2799 Rajendra Nayak             2016-05-05   888  
69b628ac71f07d Amit Kucheria              2019-03-20   889  	if (priv->ops && priv->ops->resume)
69b628ac71f07d Amit Kucheria              2019-03-20   890  		return priv->ops->resume(priv);
9066073c6c2799 Rajendra Nayak             2016-05-05   891  
9066073c6c2799 Rajendra Nayak             2016-05-05   892  	return 0;
9066073c6c2799 Rajendra Nayak             2016-05-05   893  }
9066073c6c2799 Rajendra Nayak             2016-05-05   894  
9066073c6c2799 Rajendra Nayak             2016-05-05  @895  static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
9066073c6c2799 Rajendra Nayak             2016-05-05   896  
9066073c6c2799 Rajendra Nayak             2016-05-05   897  static const struct of_device_id tsens_table[] = {
9066073c6c2799 Rajendra Nayak             2016-05-05   898  	{
9066073c6c2799 Rajendra Nayak             2016-05-05   899  		.compatible = "qcom,msm8916-tsens",
840a5bd3ed3fdd Rajendra Nayak             2016-05-05   900  		.data = &data_8916,
332bc8ebab2c0d Shawn Guo                  2020-06-29   901  	}, {
332bc8ebab2c0d Shawn Guo                  2020-06-29   902  		.compatible = "qcom,msm8939-tsens",
332bc8ebab2c0d Shawn Guo                  2020-06-29   903  		.data = &data_8939,
9066073c6c2799 Rajendra Nayak             2016-05-05   904  	}, {
9066073c6c2799 Rajendra Nayak             2016-05-05   905  		.compatible = "qcom,msm8974-tsens",
5e6703bd2d8354 Rajendra Nayak             2016-05-05   906  		.data = &data_8974,
0e580290170dfb AngeloGioacchino Del Regno 2019-10-05   907  	}, {
0e580290170dfb AngeloGioacchino Del Regno 2019-10-05   908  		.compatible = "qcom,msm8976-tsens",
0e580290170dfb AngeloGioacchino Del Regno 2019-10-05   909  		.data = &data_8976,
d059c739aacfbd Rajendra Nayak             2016-05-05   910  	}, {
d059c739aacfbd Rajendra Nayak             2016-05-05   911  		.compatible = "qcom,msm8996-tsens",
d059c739aacfbd Rajendra Nayak             2016-05-05   912  		.data = &data_8996,
e8c24c6f5d1c7a Amit Kucheria              2019-03-20   913  	}, {
e8c24c6f5d1c7a Amit Kucheria              2019-03-20   914  		.compatible = "qcom,tsens-v1",
e8c24c6f5d1c7a Amit Kucheria              2019-03-20   915  		.data = &data_tsens_v1,
191dc74bad60e1 Amit Kucheria              2018-07-18   916  	}, {
191dc74bad60e1 Amit Kucheria              2018-07-18   917  		.compatible = "qcom,tsens-v2",
191dc74bad60e1 Amit Kucheria              2018-07-18   918  		.data = &data_tsens_v2,
9066073c6c2799 Rajendra Nayak             2016-05-05   919  	},
9066073c6c2799 Rajendra Nayak             2016-05-05   920  	{}
9066073c6c2799 Rajendra Nayak             2016-05-05   921  };
9066073c6c2799 Rajendra Nayak             2016-05-05   922  MODULE_DEVICE_TABLE(of, tsens_table);
9066073c6c2799 Rajendra Nayak             2016-05-05   923  
9066073c6c2799 Rajendra Nayak             2016-05-05  @924  static const struct thermal_zone_of_device_ops tsens_of_ops = {
9066073c6c2799 Rajendra Nayak             2016-05-05  @925  	.get_temp = tsens_get_temp,
9066073c6c2799 Rajendra Nayak             2016-05-05  @926  	.get_trend = tsens_get_trend,
634e11d5b450a9 Amit Kucheria              2019-11-01   927  	.set_trips = tsens_set_trips,
9066073c6c2799 Rajendra Nayak             2016-05-05   928  };
9066073c6c2799 Rajendra Nayak             2016-05-05   929  
79125e03dbfc71 Amit Kucheria              2020-03-12  @930  static int tsens_register_irq(struct tsens_priv *priv, char *irqname,
79125e03dbfc71 Amit Kucheria              2020-03-12   931  			      irq_handler_t thread_fn)
9066073c6c2799 Rajendra Nayak             2016-05-05   932  {
634e11d5b450a9 Amit Kucheria              2019-11-01   933  	struct platform_device *pdev;
79125e03dbfc71 Amit Kucheria              2020-03-12   934  	int ret, irq;
634e11d5b450a9 Amit Kucheria              2019-11-01   935  
634e11d5b450a9 Amit Kucheria              2019-11-01   936  	pdev = of_find_device_by_node(priv->dev->of_node);
634e11d5b450a9 Amit Kucheria              2019-11-01   937  	if (!pdev)
634e11d5b450a9 Amit Kucheria              2019-11-01   938  		return -ENODEV;
634e11d5b450a9 Amit Kucheria              2019-11-01   939  
79125e03dbfc71 Amit Kucheria              2020-03-12   940  	irq = platform_get_irq_byname(pdev, irqname);
634e11d5b450a9 Amit Kucheria              2019-11-01   941  	if (irq < 0) {
634e11d5b450a9 Amit Kucheria              2019-11-01   942  		ret = irq;
344fa0bad69322 Amit Kucheria              2019-12-12   943  		/* For old DTs with no IRQ defined */
344fa0bad69322 Amit Kucheria              2019-12-12   944  		if (irq == -ENXIO)
344fa0bad69322 Amit Kucheria              2019-12-12   945  			ret = 0;
79125e03dbfc71 Amit Kucheria              2020-03-12   946  	} else {
634e11d5b450a9 Amit Kucheria              2019-11-01   947  		ret = devm_request_threaded_irq(&pdev->dev, irq,
79125e03dbfc71 Amit Kucheria              2020-03-12   948  						NULL, thread_fn,
8d3a6d4f433701 Amit Kucheria              2020-03-12   949  						IRQF_ONESHOT,
634e11d5b450a9 Amit Kucheria              2019-11-01   950  						dev_name(&pdev->dev), priv);
79125e03dbfc71 Amit Kucheria              2020-03-12   951  		if (ret)
79125e03dbfc71 Amit Kucheria              2020-03-12   952  			dev_err(&pdev->dev, "%s: failed to get irq\n",
79125e03dbfc71 Amit Kucheria              2020-03-12   953  				__func__);
79125e03dbfc71 Amit Kucheria              2020-03-12   954  		else
634e11d5b450a9 Amit Kucheria              2019-11-01   955  			enable_irq_wake(irq);
79125e03dbfc71 Amit Kucheria              2020-03-12   956  	}
634e11d5b450a9 Amit Kucheria              2019-11-01   957  
634e11d5b450a9 Amit Kucheria              2019-11-01   958  	put_device(&pdev->dev);
634e11d5b450a9 Amit Kucheria              2019-11-01   959  	return ret;
9066073c6c2799 Rajendra Nayak             2016-05-05   960  }
9066073c6c2799 Rajendra Nayak             2016-05-05   961  
79125e03dbfc71 Amit Kucheria              2020-03-12  @962  static int tsens_register(struct tsens_priv *priv)
79125e03dbfc71 Amit Kucheria              2020-03-12   963  {
79125e03dbfc71 Amit Kucheria              2020-03-12   964  	int i, ret;
79125e03dbfc71 Amit Kucheria              2020-03-12   965  	struct thermal_zone_device *tzd;
79125e03dbfc71 Amit Kucheria              2020-03-12   966  
79125e03dbfc71 Amit Kucheria              2020-03-12   967  	for (i = 0;  i < priv->num_sensors; i++) {
79125e03dbfc71 Amit Kucheria              2020-03-12   968  		priv->sensor[i].priv = priv;
79125e03dbfc71 Amit Kucheria              2020-03-12   969  		tzd = devm_thermal_zone_of_sensor_register(priv->dev, priv->sensor[i].hw_id,
79125e03dbfc71 Amit Kucheria              2020-03-12   970  							   &priv->sensor[i],
79125e03dbfc71 Amit Kucheria              2020-03-12   971  							   &tsens_of_ops);
79125e03dbfc71 Amit Kucheria              2020-03-12   972  		if (IS_ERR(tzd))
79125e03dbfc71 Amit Kucheria              2020-03-12   973  			continue;
79125e03dbfc71 Amit Kucheria              2020-03-12   974  		priv->sensor[i].tzd = tzd;
79125e03dbfc71 Amit Kucheria              2020-03-12   975  		if (priv->ops->enable)
79125e03dbfc71 Amit Kucheria              2020-03-12   976  			priv->ops->enable(priv, i);
79125e03dbfc71 Amit Kucheria              2020-03-12   977  	}
79125e03dbfc71 Amit Kucheria              2020-03-12   978  
79125e03dbfc71 Amit Kucheria              2020-03-12   979  	ret = tsens_register_irq(priv, "uplow", tsens_irq_thread);
79125e03dbfc71 Amit Kucheria              2020-03-12   980  	if (ret < 0)
79125e03dbfc71 Amit Kucheria              2020-03-12   981  		return ret;
79125e03dbfc71 Amit Kucheria              2020-03-12   982  
79125e03dbfc71 Amit Kucheria              2020-03-12   983  	if (priv->feat->crit_int)
79125e03dbfc71 Amit Kucheria              2020-03-12   984  		ret = tsens_register_irq(priv, "critical",
79125e03dbfc71 Amit Kucheria              2020-03-12   985  					 tsens_critical_irq_thread);
79125e03dbfc71 Amit Kucheria              2020-03-12   986  
79125e03dbfc71 Amit Kucheria              2020-03-12   987  	return ret;
79125e03dbfc71 Amit Kucheria              2020-03-12   988  }
79125e03dbfc71 Amit Kucheria              2020-03-12   989  
9066073c6c2799 Rajendra Nayak             2016-05-05  @990  static int tsens_probe(struct platform_device *pdev)
9066073c6c2799 Rajendra Nayak             2016-05-05   991  {
9066073c6c2799 Rajendra Nayak             2016-05-05   992  	int ret, i;
9066073c6c2799 Rajendra Nayak             2016-05-05   993  	struct device *dev;
9066073c6c2799 Rajendra Nayak             2016-05-05   994  	struct device_node *np;
69b628ac71f07d Amit Kucheria              2019-03-20   995  	struct tsens_priv *priv;
3c040ce087a2e8 Amit Kucheria              2019-03-20   996  	const struct tsens_plat_data *data;
9066073c6c2799 Rajendra Nayak             2016-05-05   997  	const struct of_device_id *id;
6d7c70d1cd6526 Bjorn Andersson            2018-05-07   998  	u32 num_sensors;
9066073c6c2799 Rajendra Nayak             2016-05-05   999  
9066073c6c2799 Rajendra Nayak             2016-05-05  1000  	if (pdev->dev.of_node)
9066073c6c2799 Rajendra Nayak             2016-05-05  1001  		dev = &pdev->dev;
9066073c6c2799 Rajendra Nayak             2016-05-05  1002  	else
9066073c6c2799 Rajendra Nayak             2016-05-05  1003  		dev = pdev->dev.parent;
9066073c6c2799 Rajendra Nayak             2016-05-05  1004  
9066073c6c2799 Rajendra Nayak             2016-05-05  1005  	np = dev->of_node;
9066073c6c2799 Rajendra Nayak             2016-05-05  1006  
9066073c6c2799 Rajendra Nayak             2016-05-05  1007  	id = of_match_node(tsens_table, np);
20d4fd84bf524a Rajendra Nayak             2016-05-05  1008  	if (id)
9066073c6c2799 Rajendra Nayak             2016-05-05  1009  		data = id->data;
20d4fd84bf524a Rajendra Nayak             2016-05-05  1010  	else
20d4fd84bf524a Rajendra Nayak             2016-05-05  1011  		data = &data_8960;
9066073c6c2799 Rajendra Nayak             2016-05-05  1012  
6d7c70d1cd6526 Bjorn Andersson            2018-05-07  1013  	num_sensors = data->num_sensors;
6d7c70d1cd6526 Bjorn Andersson            2018-05-07  1014  
6d7c70d1cd6526 Bjorn Andersson            2018-05-07  1015  	if (np)
6d7c70d1cd6526 Bjorn Andersson            2018-05-07  1016  		of_property_read_u32(np, "#qcom,sensors", &num_sensors);
6d7c70d1cd6526 Bjorn Andersson            2018-05-07  1017  
6d7c70d1cd6526 Bjorn Andersson            2018-05-07  1018  	if (num_sensors <= 0) {
3795ad5e266908 Amit Kucheria              2019-11-01  1019  		dev_err(dev, "%s: invalid number of sensors\n", __func__);
9066073c6c2799 Rajendra Nayak             2016-05-05  1020  		return -EINVAL;
9066073c6c2799 Rajendra Nayak             2016-05-05  1021  	}
9066073c6c2799 Rajendra Nayak             2016-05-05  1022  
69b628ac71f07d Amit Kucheria              2019-03-20  1023  	priv = devm_kzalloc(dev,
69b628ac71f07d Amit Kucheria              2019-03-20  1024  			     struct_size(priv, sensor, num_sensors),
0ed2dd03b94b7b Kees Cook                  2018-05-08  1025  			     GFP_KERNEL);
69b628ac71f07d Amit Kucheria              2019-03-20  1026  	if (!priv)
9066073c6c2799 Rajendra Nayak             2016-05-05  1027  		return -ENOMEM;
9066073c6c2799 Rajendra Nayak             2016-05-05  1028  
69b628ac71f07d Amit Kucheria              2019-03-20  1029  	priv->dev = dev;
69b628ac71f07d Amit Kucheria              2019-03-20  1030  	priv->num_sensors = num_sensors;
69b628ac71f07d Amit Kucheria              2019-03-20  1031  	priv->ops = data->ops;
69b628ac71f07d Amit Kucheria              2019-03-20  1032  	for (i = 0;  i < priv->num_sensors; i++) {
9066073c6c2799 Rajendra Nayak             2016-05-05  1033  		if (data->hw_ids)
69b628ac71f07d Amit Kucheria              2019-03-20  1034  			priv->sensor[i].hw_id = data->hw_ids[i];
9066073c6c2799 Rajendra Nayak             2016-05-05  1035  		else
69b628ac71f07d Amit Kucheria              2019-03-20  1036  			priv->sensor[i].hw_id = i;
9066073c6c2799 Rajendra Nayak             2016-05-05  1037  	}
c19970548edc35 Amit Kucheria              2019-03-20  1038  	priv->feat = data->feat;
c19970548edc35 Amit Kucheria              2019-03-20  1039  	priv->fields = data->fields;
9066073c6c2799 Rajendra Nayak             2016-05-05  1040  
0e9c0bc7308240 Amit Kucheria              2019-11-01  1041  	platform_set_drvdata(pdev, priv);
0e9c0bc7308240 Amit Kucheria              2019-11-01  1042  
69b628ac71f07d Amit Kucheria              2019-03-20  1043  	if (!priv->ops || !priv->ops->init || !priv->ops->get_temp)
9066073c6c2799 Rajendra Nayak             2016-05-05  1044  		return -EINVAL;
9066073c6c2799 Rajendra Nayak             2016-05-05  1045  
69b628ac71f07d Amit Kucheria              2019-03-20  1046  	ret = priv->ops->init(priv);
9066073c6c2799 Rajendra Nayak             2016-05-05  1047  	if (ret < 0) {
3795ad5e266908 Amit Kucheria              2019-11-01  1048  		dev_err(dev, "%s: init failed\n", __func__);
9066073c6c2799 Rajendra Nayak             2016-05-05  1049  		return ret;
9066073c6c2799 Rajendra Nayak             2016-05-05  1050  	}
9066073c6c2799 Rajendra Nayak             2016-05-05  1051  
69b628ac71f07d Amit Kucheria              2019-03-20  1052  	if (priv->ops->calibrate) {
69b628ac71f07d Amit Kucheria              2019-03-20  1053  		ret = priv->ops->calibrate(priv);
9066073c6c2799 Rajendra Nayak             2016-05-05  1054  		if (ret < 0) {
fc7d18cf6a923c Amit Kucheria              2019-03-20  1055  			if (ret != -EPROBE_DEFER)
3795ad5e266908 Amit Kucheria              2019-11-01  1056  				dev_err(dev, "%s: calibration failed\n", __func__);
9066073c6c2799 Rajendra Nayak             2016-05-05  1057  			return ret;
9066073c6c2799 Rajendra Nayak             2016-05-05  1058  		}
9066073c6c2799 Rajendra Nayak             2016-05-05  1059  	}
9066073c6c2799 Rajendra Nayak             2016-05-05  1060  
0e9c0bc7308240 Amit Kucheria              2019-11-01  1061  	return tsens_register(priv);
9066073c6c2799 Rajendra Nayak             2016-05-05  1062  }
9066073c6c2799 Rajendra Nayak             2016-05-05  1063  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Krzysztof Kozlowski April 16, 2021, 9 a.m. UTC | #2
On Sun, 4 Apr 2021 at 06:34, <zhuguangqing83@gmail.com> wrote:
>
> From: Guangqing Zhu <zhuguangqing83@gmail.com>
>
> Fixes coccicheck error:
>
> drivers/thermal/qcom/tsens.c:759:4-10: ERROR: missing put_device; call
> of_find_device_by_node on line 715, but without a corresponding object
> release within this function.
>
> Fixes: a7ff82976122 ("drivers: thermal: tsens: Merge tsens-common.c into
> tsens.c")
>
> Signed-off-by: Guangqing Zhu <zhuguangqing83@gmail.com>
> ---
>  drivers/thermal/qcom/tsens.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
> index d8ce3a687b80..cc4c6a9853a4 100644
> --- a/drivers/thermal/qcom/tsens.c
> +++ b/drivers/thermal/qcom/tsens.c
> @@ -755,9 +755,10 @@ int __init init_common(struct tsens_priv *priv)
>                 for (i = VER_MAJOR; i <= VER_STEP; i++) {
>                         priv->rf[i] = devm_regmap_field_alloc(dev, priv->srot_map,
>                                                               priv->fields[i]);
> -                       if (IS_ERR(priv->rf[i]))
> -                               return PTR_ERR(priv->rf[i]);
> -               }
> +                       if (IS_ERR(priv->rf[i])) {
> +                               ret = PTR_ERR(priv->rf[i]);
> +                               goto err_put_device;
> +                       }

As kbuild robot pointed out - this does not even compile. Please at
least build all your patches before sending.

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index d8ce3a687b80..cc4c6a9853a4 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -755,9 +755,10 @@  int __init init_common(struct tsens_priv *priv)
 		for (i = VER_MAJOR; i <= VER_STEP; i++) {
 			priv->rf[i] = devm_regmap_field_alloc(dev, priv->srot_map,
 							      priv->fields[i]);
-			if (IS_ERR(priv->rf[i]))
-				return PTR_ERR(priv->rf[i]);
-		}
+			if (IS_ERR(priv->rf[i])) {
+				ret = PTR_ERR(priv->rf[i]);
+				goto err_put_device;
+			}
 		ret = regmap_field_read(priv->rf[VER_MINOR], &ver_minor);
 		if (ret)
 			goto err_put_device;