Message ID | 20231102055120.1192015-1-xinglong.yang@cixtech.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | driver: thermal: simplify the traverse of sensor in thermal_zone. | expand |
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@intel.com/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@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311021624.jfMQm3Ox-lkp@intel.com/
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
diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index e615f735f4c0..a405754c42cd 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -186,6 +186,7 @@ static struct device_node *of_thermal_zone_find(struct device_node *sensor, int for_each_available_child_of_node(np, tz) { int count, i; + int ret; count = of_count_phandle_with_args(tz, "thermal-sensors", "#thermal-sensor-cells"); @@ -193,26 +194,25 @@ static struct device_node *of_thermal_zone_find(struct device_node *sensor, int pr_err("%pOFn: missing thermal sensor\n", tz); tz = ERR_PTR(-EINVAL); goto out; + } else if (count > 1) { + pr_err("%pOFn: number of thermal sensor greater than one\n", tz); + tz = ERR_PTR(-EINVAL); + goto out; } - for (i = 0; i < count; i++) { - - int ret; - - ret = of_parse_phandle_with_args(tz, "thermal-sensors", - "#thermal-sensor-cells", - i, &sensor_specs); - if (ret < 0) { - pr_err("%pOFn: Failed to read thermal-sensors cells: %d\n", tz, ret); - tz = ERR_PTR(ret); - goto out; - } + ret = of_parse_phandle_with_args(tz, "thermal-sensors", + "#thermal-sensor-cells", + 0, &sensor_specs); + if (ret < 0) { + pr_err("%pOFn: Failed to read thermal-sensors cells: %d\n", tz, ret); + tz = ERR_PTR(ret); + goto out; + } - if ((sensor == sensor_specs.np) && id == (sensor_specs.args_count ? - sensor_specs.args[0] : 0)) { - pr_debug("sensor %pOFn id=%d belongs to %pOFn\n", sensor, id, tz); - goto out; - } + if ((sensor == sensor_specs.np) && id == (sensor_specs.args_count ? + sensor_specs.args[0] : 0)) { + pr_debug("sensor %pOFn id=%d belongs to %pOFn\n", sensor, id, tz); + goto out; } } tz = ERR_PTR(-ENODEV);
The number of sensor in a thermal zone needs to be greater than zero and equal to one. Add the opinion when the number of sensor is greater than one in a thermal zone. There is also no need to traverse the sensor in the thermal zone, because there is only one sensor on one thermal zone. Signed-off-by: xinglong.yang <xinglong.yang@cixtech.com> --- drivers/thermal/thermal_of.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)