Re: [PATCH] driver: thermal: simplify the traverse of sensor in thermal_zone.

From: kernel test robot
Date: Thu Nov 02 2023 - 05:18:36 EST


Hi xinglong.yang,

kernel test robot noticed the following build warnings:

[auto build test WARNING on rafael-pm/thermal]
[also build test WARNING on linus/master v6.6 next-20231102]
[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#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/xinglong-yang/driver-thermal-simplify-the-traverse-of-sensor-in-thermal_zone/20231102-135739
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git thermal
patch link: https://lore.kernel.org/r/20231102055120.1192015-1-xinglong.yang%40cixtech.com
patch subject: [PATCH] driver: thermal: simplify the traverse of sensor in thermal_zone.
config: loongarch-randconfig-001-20231102 (https://download.01.org/0day-ci/archive/20231102/202311021624.jfMQm3Ox-lkp@xxxxxxxxx/config)
compiler: loongarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231102/202311021624.jfMQm3Ox-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311021624.jfMQm3Ox-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

drivers/thermal/thermal_of.c: In function 'of_thermal_zone_find':
>> drivers/thermal/thermal_of.c:187:28: warning: unused variable 'i' [-Wunused-variable]
187 | int count, i;
| ^


vim +/i +187 drivers/thermal/thermal_of.c

d0c75fa2c17f08 Daniel Lezcano 2022-07-22 169
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 170 static struct device_node *of_thermal_zone_find(struct device_node *sensor, int id)
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 171 {
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 172 struct device_node *np, *tz;
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 173 struct of_phandle_args sensor_specs;
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 174
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 175 np = of_find_node_by_name(NULL, "thermal-zones");
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 176 if (!np) {
9d6792df07367a Daniel Lezcano 2022-08-09 177 pr_debug("No thermal zones description\n");
9d6792df07367a Daniel Lezcano 2022-08-09 178 return ERR_PTR(-ENODEV);
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 179 }
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 180
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 181 /*
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 182 * Search for each thermal zone, a defined sensor
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 183 * corresponding to the one passed as parameter
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 184 */
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 185 for_each_available_child_of_node(np, tz) {
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 186
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 @187 int count, i;
d8c9a37137332e xinglong.yang 2023-11-02 188 int ret;
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 189
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 190 count = of_count_phandle_with_args(tz, "thermal-sensors",
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 191 "#thermal-sensor-cells");
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 192 if (count <= 0) {
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 193 pr_err("%pOFn: missing thermal sensor\n", tz);
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 194 tz = ERR_PTR(-EINVAL);
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 195 goto out;
d8c9a37137332e xinglong.yang 2023-11-02 196 } else if (count > 1) {
d8c9a37137332e xinglong.yang 2023-11-02 197 pr_err("%pOFn: number of thermal sensor greater than one\n", tz);
d8c9a37137332e xinglong.yang 2023-11-02 198 tz = ERR_PTR(-EINVAL);
d8c9a37137332e xinglong.yang 2023-11-02 199 goto out;
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 200 }
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 201
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 202 ret = of_parse_phandle_with_args(tz, "thermal-sensors",
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 203 "#thermal-sensor-cells",
d8c9a37137332e xinglong.yang 2023-11-02 204 0, &sensor_specs);
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 205 if (ret < 0) {
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 206 pr_err("%pOFn: Failed to read thermal-sensors cells: %d\n", tz, ret);
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 207 tz = ERR_PTR(ret);
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 208 goto out;
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 209 }
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 210
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 211 if ((sensor == sensor_specs.np) && id == (sensor_specs.args_count ?
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 212 sensor_specs.args[0] : 0)) {
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 213 pr_debug("sensor %pOFn id=%d belongs to %pOFn\n", sensor, id, tz);
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 214 goto out;
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 215 }
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 216 }
9d6792df07367a Daniel Lezcano 2022-08-09 217 tz = ERR_PTR(-ENODEV);
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 218 out:
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 219 of_node_put(np);
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 220 return tz;
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 221 }
3fd6d6e2b4e80f Daniel Lezcano 2022-08-05 222

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki