From: Artem Shimko <artyom.shimko@gmail.com>
Improve handling of unsupported sensor types:
- Add default case in sensor type switch statement
- Log skipped sensors with debug information including:
* Sensor ID
* Sensor type
* Sensor name (if available)
- Use rate-limited dev_dbg for safety
Debug output format:
"Skipping unsupported sensor ID:%d Type:%d (%s)"
Signed-off-by: Artem Shimko <artyom.shimko@gmail.com>
---
drivers/hwmon/scmi-hwmon.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c
index 364199b332c0..a3b5b5c0ec25 100644
--- a/drivers/hwmon/scmi-hwmon.c
+++ b/drivers/hwmon/scmi-hwmon.c
@@ -275,6 +275,10 @@ static int scmi_hwmon_probe(struct scmi_device *sdev)
nr_count[type]++;
break;
}
+ default:
+ dev_dbg(dev, "Skipping unsupported sensor ID:%d Type:%d (%s)\n",
+ i, sensor->type, sensor->name ? sensor->name : "unnamed");
+ continue;
}
if (nr_count[hwmon_temp])
@@ -323,6 +327,10 @@ static int scmi_hwmon_probe(struct scmi_device *sdev)
idx = --nr_count[type];
*(scmi_sensors->info[type] + idx) = sensor;
break;
+ default:
+ dev_dbg(dev, "Skipping unsupported sensor ID:%d Type:%d (%s)\n",
+ i, sensor->type, sensor->name ? sensor->name : "unnamed");
+ continue;
}
}
--
2.43.0
On 8/5/25 05:43, a.shimko wrote: > From: Artem Shimko <artyom.shimko@gmail.com> > > Improve handling of unsupported sensor types: > - Add default case in sensor type switch statement > - Log skipped sensors with debug information including: > * Sensor ID > * Sensor type > * Sensor name (if available) > - Use rate-limited dev_dbg for safety > The code doesn't actually do that, and it would be pointless and make the message useless. > Debug output format: > "Skipping unsupported sensor ID:%d Type:%d (%s)" > > Signed-off-by: Artem Shimko <artyom.shimko@gmail.com> > --- > drivers/hwmon/scmi-hwmon.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c > index 364199b332c0..a3b5b5c0ec25 100644 > --- a/drivers/hwmon/scmi-hwmon.c > +++ b/drivers/hwmon/scmi-hwmon.c > @@ -275,6 +275,10 @@ static int scmi_hwmon_probe(struct scmi_device *sdev) > nr_count[type]++; > break; > } > + default: > + dev_dbg(dev, "Skipping unsupported sensor ID:%d Type:%d (%s)\n", > + i, sensor->type, sensor->name ? sensor->name : "unnamed"); > + continue; break; > } > > if (nr_count[hwmon_temp]) > @@ -323,6 +327,10 @@ static int scmi_hwmon_probe(struct scmi_device *sdev) > idx = --nr_count[type]; > *(scmi_sensors->info[type] + idx) = sensor; > break; > + default: > + dev_dbg(dev, "Skipping unsupported sensor ID:%d Type:%d (%s)\n", > + i, sensor->type, sensor->name ? sensor->name : "unnamed"); > + continue; break; > } > } >
Hi a.shimko, kernel test robot noticed the following build errors: [auto build test ERROR on groeck-staging/hwmon-next] [also build test ERROR on linus/master v6.16 next-20250806] [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/a-shimko/hwmon-scmi-Add-default-case-with-debug-output/20250806-122638 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next patch link: https://lore.kernel.org/r/20250805125003.12573-2-artyom.shimko%40gmail.com patch subject: [PATCH 1/3] hwmon: scmi: Add default case with debug output config: arc-randconfig-001-20250806 (https://download.01.org/0day-ci/archive/20250806/202508062201.bWDZGD03-lkp@intel.com/config) compiler: arc-linux-gcc (GCC) 12.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250806/202508062201.bWDZGD03-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/202508062201.bWDZGD03-lkp@intel.com/ All errors (new ones prefixed by >>): drivers/hwmon/scmi-hwmon.c: In function 'scmi_hwmon_probe': >> drivers/hwmon/scmi-hwmon.c:278:17: error: 'default' label not within a switch statement 278 | default: | ^~~~~~~ vim +/default +278 drivers/hwmon/scmi-hwmon.c 228 229 static int scmi_hwmon_probe(struct scmi_device *sdev) 230 { 231 int i, idx; 232 u16 nr_sensors; 233 enum hwmon_sensor_types type; 234 struct scmi_sensors *scmi_sensors; 235 const struct scmi_sensor_info *sensor; 236 int nr_count[hwmon_max] = {0}, nr_types = 0, nr_count_temp = 0; 237 const struct hwmon_chip_info *chip_info; 238 struct device *hwdev, *dev = &sdev->dev; 239 struct hwmon_channel_info *scmi_hwmon_chan; 240 const struct hwmon_channel_info **ptr_scmi_ci; 241 const struct scmi_handle *handle = sdev->handle; 242 struct scmi_protocol_handle *ph; 243 244 if (!handle) 245 return -ENODEV; 246 247 sensor_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_SENSOR, &ph); 248 if (IS_ERR(sensor_ops)) 249 return PTR_ERR(sensor_ops); 250 251 nr_sensors = sensor_ops->count_get(ph); 252 if (!nr_sensors) 253 return -EIO; 254 255 scmi_sensors = devm_kzalloc(dev, sizeof(*scmi_sensors), GFP_KERNEL); 256 if (!scmi_sensors) 257 return -ENOMEM; 258 259 scmi_sensors->ph = ph; 260 261 for (i = 0; i < nr_sensors; i++) { 262 sensor = sensor_ops->info_get(ph, i); 263 if (!sensor) 264 return -EINVAL; 265 266 switch (sensor->type) { 267 case TEMPERATURE_C: 268 case VOLTAGE: 269 case CURRENT: 270 case POWER: 271 case ENERGY: 272 type = scmi_types[sensor->type]; 273 if (!nr_count[type]) 274 nr_types++; 275 nr_count[type]++; 276 break; 277 } > 278 default: 279 dev_dbg(dev, "Skipping unsupported sensor ID:%d Type:%d (%s)\n", 280 i, sensor->type, sensor->name ? sensor->name : "unnamed"); 281 continue; 282 } 283 284 if (nr_count[hwmon_temp]) 285 nr_count_temp = nr_count[hwmon_temp]; 286 287 scmi_hwmon_chan = devm_kcalloc(dev, nr_types, sizeof(*scmi_hwmon_chan), 288 GFP_KERNEL); 289 if (!scmi_hwmon_chan) 290 return -ENOMEM; 291 292 ptr_scmi_ci = devm_kcalloc(dev, nr_types + 1, sizeof(*ptr_scmi_ci), 293 GFP_KERNEL); 294 if (!ptr_scmi_ci) 295 return -ENOMEM; 296 297 scmi_chip_info.info = ptr_scmi_ci; 298 chip_info = &scmi_chip_info; 299 300 for (type = 0; type < hwmon_max; type++) { 301 if (!nr_count[type]) 302 continue; 303 304 scmi_hwmon_add_chan_info(scmi_hwmon_chan, dev, nr_count[type], 305 type, hwmon_attributes[type]); 306 *ptr_scmi_ci++ = scmi_hwmon_chan++; 307 308 scmi_sensors->info[type] = 309 devm_kcalloc(dev, nr_count[type], 310 sizeof(*scmi_sensors->info), GFP_KERNEL); 311 if (!scmi_sensors->info[type]) 312 return -ENOMEM; 313 } 314 315 for (i = nr_sensors - 1; i >= 0 ; i--) { 316 sensor = sensor_ops->info_get(ph, i); 317 if (!sensor) 318 continue; 319 320 switch (sensor->type) { 321 case TEMPERATURE_C: 322 case VOLTAGE: 323 case CURRENT: 324 case POWER: 325 case ENERGY: 326 type = scmi_types[sensor->type]; 327 idx = --nr_count[type]; 328 *(scmi_sensors->info[type] + idx) = sensor; 329 break; 330 default: 331 dev_dbg(dev, "Skipping unsupported sensor ID:%d Type:%d (%s)\n", 332 i, sensor->type, sensor->name ? sensor->name : "unnamed"); 333 continue; 334 } 335 } 336 337 hwdev = devm_hwmon_device_register_with_info(dev, "scmi_sensors", 338 scmi_sensors, chip_info, 339 NULL); 340 if (IS_ERR(hwdev)) 341 return PTR_ERR(hwdev); 342 343 for (i = 0; i < nr_count_temp; i++) { 344 int ret; 345 346 sensor = *(scmi_sensors->info[hwmon_temp] + i); 347 if (!sensor) 348 continue; 349 350 /* 351 * Warn on any misconfiguration related to thermal zones but 352 * bail out of probing only on memory errors. 353 */ 354 ret = scmi_thermal_sensor_register(dev, ph, sensor); 355 if (ret) { 356 if (ret == -ENOMEM) 357 return ret; 358 dev_warn(dev, 359 "Thermal zone misconfigured for %s. err=%d\n", 360 sensor->name, ret); 361 } 362 } 363 364 return 0; 365 } 366 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
© 2016 - 2025 Red Hat, Inc.