Re: [PATCH 2/2] thermal: add a virtual sensor to aggregate temperatures

From: kernel test robot
Date: Tue Sep 07 2021 - 01:15:01 EST


Hi Alexandre,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on robh/for-next]
[also build test ERROR on linus/master v5.14 next-20210906]
[cannot apply to thermal/next soc-thermal/next]
[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/Alexandre-Bailon/Add-a-generic-virtual-thermal-sensor/20210907-030547
base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: riscv-allmodconfig (attached as .config)
compiler: riscv64-linux-gcc (GCC) 11.2.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/2e3e80b0ee6c69039ada990aaf0380e8c6c024c0
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Alexandre-Bailon/Add-a-generic-virtual-thermal-sensor/20210907-030547
git checkout 2e3e80b0ee6c69039ada990aaf0380e8c6c024c0
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=riscv SHELL=/bin/bash drivers/

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

All errors (new ones prefixed by >>):

In file included from drivers/thermal/virtual_sensor.c:18:
drivers/thermal/virtual-sensor.h:32:6: warning: no previous prototype for 'thermal_virtual_sensor_unregister' [-Wmissing-prototypes]
32 | void thermal_virtual_sensor_unregister(struct device *dev,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/thermal/virtual_sensor.c:8:
>> drivers/thermal/virtual_sensor.c:235:25: error: 'thermal_aggr_of_match' undeclared here (not in a function)
235 | MODULE_DEVICE_TABLE(of, thermal_aggr_of_match);
| ^~~~~~~~~~~~~~~~~~~~~
include/linux/module.h:244:15: note: in definition of macro 'MODULE_DEVICE_TABLE'
244 | extern typeof(name) __mod_##type##__##name##_device_table \
| ^~~~
>> drivers/thermal/virtual_sensor.c:267:29: error: redefinition of 'thermal_virtual_sensor_register'
267 | struct virtual_sensor_data *thermal_virtual_sensor_register(
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/thermal/virtual_sensor.c:18:
drivers/thermal/virtual-sensor.h:26:1: note: previous definition of 'thermal_virtual_sensor_register' with type 'struct virtual_sensor_data *(struct device *, int, void *, const struct thermal_zone_of_device_ops *)'
26 | thermal_virtual_sensor_register(struct device *dev, int sensor_id, void *data,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/thermal/virtual_sensor.c:295:6: error: redefinition of 'thermal_virtual_sensor_unregister'
295 | void thermal_virtual_sensor_unregister(struct device *dev,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/thermal/virtual_sensor.c:18:
drivers/thermal/virtual-sensor.h:32:6: note: previous definition of 'thermal_virtual_sensor_unregister' with type 'void(struct device *, struct virtual_sensor_data *)'
32 | void thermal_virtual_sensor_unregister(struct device *dev,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/thermal/virtual_sensor.c:354:29: error: redefinition of 'devm_thermal_virtual_sensor_register'
354 | struct virtual_sensor_data *devm_thermal_virtual_sensor_register(
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/thermal/virtual_sensor.c:18:
drivers/thermal/virtual-sensor.h:38:1: note: previous definition of 'devm_thermal_virtual_sensor_register' with type 'struct virtual_sensor_data *(struct device *, int, void *, const struct thermal_zone_of_device_ops *)'
38 | devm_thermal_virtual_sensor_register(struct device *dev, int sensor_id, void *data,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/thermal/virtual_sensor.c:389:6: error: redefinition of 'devm_thermal_virtual_sensor_unregister'
389 | void devm_thermal_virtual_sensor_unregister(struct device *dev,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/thermal/virtual_sensor.c:18:
drivers/thermal/virtual-sensor.h:45:6: note: previous definition of 'devm_thermal_virtual_sensor_unregister' with type 'void(struct device *, struct virtual_sensor *)'
45 | void devm_thermal_virtual_sensor_unregister(struct device *dev,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/thermal/virtual_sensor.c:8:
>> include/linux/module.h:244:21: error: '__mod_of__thermal_aggr_of_match_device_table' aliased to undefined symbol 'thermal_aggr_of_match'
244 | extern typeof(name) __mod_##type##__##name##_device_table \
| ^~~~~~
drivers/thermal/virtual_sensor.c:235:1: note: in expansion of macro 'MODULE_DEVICE_TABLE'
235 | MODULE_DEVICE_TABLE(of, thermal_aggr_of_match);
| ^~~~~~~~~~~~~~~~~~~


vim +/thermal_aggr_of_match +235 drivers/thermal/virtual_sensor.c

227
228 static const struct of_device_id virtual_sensor_of_match[] = {
229 {
230 .compatible = "virtual,thermal-sensor",
231 },
232 {
233 },
234 };
> 235 MODULE_DEVICE_TABLE(of, thermal_aggr_of_match);
236
237 static struct platform_driver virtual_sensor = {
238 .probe = virtual_sensor_probe,
239 .remove = virtual_sensor_remove,
240 .driver = {
241 .name = "virtual-sensor",
242 .of_match_table = virtual_sensor_of_match,
243 },
244 };
245
246 /**
247 * thermal_virtual_sensor_register - registers a sensor that could by a virtual
248 * sensor
249 * @dev: a valid struct device pointer of a sensor device. Must contain
250 * a valid .of_node, for the sensor node.
251 * @sensor_id: a sensor identifier, in case the sensor IP has more
252 * than one sensors
253 * @data: a private pointer (owned by the caller) that will be passed
254 * back, when a temperature reading is needed.
255 * @ops: struct thermal_zone_of_device_ops *. Must contain at least .get_temp.
256 *
257 * This function will register a thermal sensor to make it available for later
258 * usage by a virtual sensor.
259 *
260 * The thermal zone temperature is provided by the @get_temp function
261 * pointer. When called, it will have the private pointer @data back.
262 *
263 * Return: On success returns a valid struct thermal_zone_device,
264 * otherwise, it returns a corresponding ERR_PTR(). Caller must
265 * check the return value with help of IS_ERR() helper.
266 */
> 267 struct virtual_sensor_data *thermal_virtual_sensor_register(
268 struct device *dev, int sensor_id, void *data,
269 const struct thermal_zone_of_device_ops *ops)
270 {
271 struct virtual_sensor_data *sensor_data;
272
273 sensor_data = devm_kzalloc(dev, sizeof(*sensor_data), GFP_KERNEL);
274 if (!sensor_data)
275 return ERR_PTR(-ENOMEM);
276
277 sensor_data->id = sensor_id;
278 sensor_data->sensor_data = data;
279 sensor_data->ops = ops;
280
281 list_add(&sensor_data->node, &thermal_sensors);
282
283 return sensor_data;
284 }
285 EXPORT_SYMBOL_GPL(thermal_virtual_sensor_register);
286
287 /**
288 * thermal_virtual_sensor_unregister - unregisters a sensor
289 * @dev: a valid struct device pointer of a sensor device.
290 * @sensor_data: a pointer to struct virtual_sensor_data to unregister.
291 *
292 * This function removes the sensor from the list of available thermal sensors.
293 * If the sensor is in use, then the next call to .get_temp will return -ENODEV.
294 */
> 295 void thermal_virtual_sensor_unregister(struct device *dev,
296 struct virtual_sensor_data *sensor_data)
297 {
298 struct virtual_sensor_data *temp;
299 struct virtual_sensor *sensor;
300 int i;
301
302 list_del(&sensor_data->node);
303
304 list_for_each_entry(sensor, &virtual_sensors, node) {
305 for (i = 0; i < sensor->count; i++) {
306 temp = &sensor->sensors[i];
307 if (temp->id == sensor_data->id &&
308 temp->sensor_data == sensor_data->sensor_data) {
309 temp->ops = NULL;
310 }
311 }
312 }
313 devm_kfree(dev, sensor_data);
314 }
315 EXPORT_SYMBOL_GPL(thermal_virtual_sensor_unregister);
316
317 static void devm_thermal_virtual_sensor_release(struct device *dev, void *res)
318 {
319 thermal_virtual_sensor_unregister(dev,
320 *(struct virtual_sensor_data **)res);
321 }
322
323 static int devm_thermal_virtual_sensor_match(struct device *dev, void *res,
324 void *data)
325 {
326 struct virtual_sensor_data **r = res;
327
328 if (WARN_ON(!r || !*r))
329 return 0;
330
331 return *r == data;
332 }
333
334
335 /**
336 * devm_thermal_virtual_sensor_register - Resource managed version of
337 * thermal_virtual_sensor_register()
338 * @dev: a valid struct device pointer of a sensor device. Must contain
339 * a valid .of_node, for the sensor node.
340 * @sensor_id: a sensor identifier, in case the sensor IP has more
341 * than one sensors
342 * @data: a private pointer (owned by the caller) that will be passed
343 * back, when a temperature reading is needed.
344 * @ops: struct thermal_zone_of_device_ops *. Must contain at least .get_temp.
345 *
346 * Refer thermal_zone_of_sensor_register() for more details.
347 *
348 * Return: On success returns a valid struct virtual_sensor_data,
349 * otherwise, it returns a corresponding ERR_PTR(). Caller must
350 * check the return value with help of IS_ERR() helper.
351 * Registered virtual_sensor_data device will automatically be
352 * released when device is unbounded.
353 */
> 354 struct virtual_sensor_data *devm_thermal_virtual_sensor_register(
355 struct device *dev, int sensor_id,
356 void *data, const struct thermal_zone_of_device_ops *ops)
357 {
358 struct virtual_sensor_data **ptr, *sensor_data;
359
360 ptr = devres_alloc(devm_thermal_virtual_sensor_release, sizeof(*ptr),
361 GFP_KERNEL);
362 if (!ptr)
363 return ERR_PTR(-ENOMEM);
364
365 sensor_data = thermal_virtual_sensor_register(dev, sensor_id, data, ops);
366 if (IS_ERR(sensor_data)) {
367 devres_free(ptr);
368 return sensor_data;
369 }
370
371 *ptr = sensor_data;
372 devres_add(dev, ptr);
373
374 return sensor_data;
375 }
376 EXPORT_SYMBOL_GPL(devm_thermal_virtual_sensor_register);
377
378 /**
379 * devm_thermal_virtual_sensor_unregister - Resource managed version of
380 * thermal_virtual_sensor_unregister().
381 * @dev: Device for which resource was allocated.
382 * @sensor: a pointer to struct thermal_zone_device where the sensor is registered.
383 *
384 * This function removes the sensor from the list of sensors registered with
385 * devm_thermal_virtual_sensor_register() API.
386 * Normally this function will not need to be called and the resource
387 * management code will ensure that the resource is freed.
388 */
> 389 void devm_thermal_virtual_sensor_unregister(struct device *dev,
390 struct virtual_sensor *sensor)
391 {
392 WARN_ON(devres_release(dev, devm_thermal_virtual_sensor_release,
393 devm_thermal_virtual_sensor_match, sensor));
394 }
395 EXPORT_SYMBOL_GPL(devm_thermal_virtual_sensor_unregister);
396

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip