drivers/thermal/rockchip_thermal.c:1509:25: sparse: sparse: unsigned value that used to be signed checked against zero?

kernel test robot <[email protected]> Fri, 24 Jul 2026 01:20:42 +0800
Newsgroups dev.linux.lists.oe-kbuild
Message-ID <[email protected]>
:::::: 
:::::: Manual check reason: "low confidence static check warning: drivers/thermal/rockchip_thermal.c:1509:25: sparse: sparse: unsigned value that used to be signed checked against zero?"
:::::: 

BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Nicolas Frattaroli <[email protected]>
CC: Daniel Lezcano <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   4539944e515183668109bdf4d0c3d7d228383d88
commit: ae332ec0009d762982540635411caefeafa92a5b thermal/drivers/rockchip: Support reading trim values from OTP
date:   1 year ago
:::::: branch date: 22 hours ago
:::::: commit date: 1 year ago
config: hexagon-randconfig-r132-20260723 (https://download.01.org/0day-ci/archive/20260724/[email protected]/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 890b11e09e45e9d8b29f2f94f22052be3934e757)
sparse: v0.6.5-rc1
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260724/[email protected]/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
| Fixes: ae332ec0009d ("thermal/drivers/rockchip: Support reading trim values from OTP")
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

sparse warnings: (new ones prefixed by >>)
>> drivers/thermal/rockchip_thermal.c:1509:25: sparse: sparse: unsigned value that used to be signed checked against zero?
   drivers/thermal/rockchip_thermal.c:1514:16: sparse: signed value source

vim +1509 drivers/thermal/rockchip_thermal.c

cbac8f63943773 Caesar Wang        2014-11-24  1472  
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1473  /**
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1474   * rockchip_get_efuse_value - read an OTP cell from a device node
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1475   * @np: pointer to the device node with the nvmem-cells property
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1476   * @cell_name: name of cell that should be read
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1477   * @value: pointer to where the read value will be placed
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1478   *
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1479   * Return: Negative errno on failure, during which *value will not be touched,
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1480   * or 0 on success.
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1481   */
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1482  static int rockchip_get_efuse_value(struct device_node *np, const char *cell_name,
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1483  				    int *value)
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1484  {
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1485  	struct nvmem_cell *cell;
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1486  	int ret = 0;
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1487  	size_t len;
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1488  	u8 *buf;
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1489  	int i;
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1490  
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1491  	cell = of_nvmem_cell_get(np, cell_name);
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1492  	if (IS_ERR(cell))
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1493  		return PTR_ERR(cell);
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1494  
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1495  	buf = nvmem_cell_read(cell, &len);
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1496  
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1497  	nvmem_cell_put(cell);
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1498  
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1499  	if (IS_ERR(buf))
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1500  		return PTR_ERR(buf);
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1501  
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1502  	if (len > sizeof(*value)) {
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1503  		ret = -ERANGE;
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1504  		goto exit;
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1505  	}
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1506  
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1507  	/* Copy with implicit endian conversion */
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1508  	*value = 0;
ae332ec0009d76 Nicolas Frattaroli 2025-06-10 @1509  	for (i = 0; i < len; i++)
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1510  		*value |= (int) buf[i] << (8 * i);
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1511  
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1512  exit:
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1513  	kfree(buf);
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1514  	return ret;
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1515  }
ae332ec0009d76 Nicolas Frattaroli 2025-06-10  1516  

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