Re: [PATCH v2 2/2] iio: light: Add support for TI OPT4060 color sensor

From: kernel test robot
Date: Mon Oct 07 2024 - 02:39:58 EST


Hi Per-Daniel,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 0c559323bbaabee7346c12e74b497e283aaafef5]

url: https://github.com/intel-lab-lkp/linux/commits/Per-Daniel-Olsson/dt-bindings-iio-light-Document-TI-OPT4060-RGBW-sensor/20241006-005244
base: 0c559323bbaabee7346c12e74b497e283aaafef5
patch link: https://lore.kernel.org/r/20241005165119.3549472-3-perdaniel.olsson%40axis.com
patch subject: [PATCH v2 2/2] iio: light: Add support for TI OPT4060 color sensor
config: um-allmodconfig (https://download.01.org/0day-ci/archive/20241007/202410071407.8Vp5xp85-lkp@xxxxxxxxx/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project fef3566a25ff0e34fb87339ba5e13eca17cec00f)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241007/202410071407.8Vp5xp85-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/202410071407.8Vp5xp85-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

In file included from drivers/iio/light/opt4060.c:11:
In file included from include/linux/i2c.h:19:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:26:
In file included from include/linux/kernel_stat.h:8:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:11:
In file included from arch/um/include/asm/hardirq.h:5:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:14:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
548 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
561 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
| ^
In file included from drivers/iio/light/opt4060.c:11:
In file included from include/linux/i2c.h:19:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:26:
In file included from include/linux/kernel_stat.h:8:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:11:
In file included from arch/um/include/asm/hardirq.h:5:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:14:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
574 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
| ^
In file included from drivers/iio/light/opt4060.c:11:
In file included from include/linux/i2c.h:19:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:26:
In file included from include/linux/kernel_stat.h:8:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:11:
In file included from arch/um/include/asm/hardirq.h:5:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:14:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
585 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
595 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
605 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:693:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
693 | readsb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:701:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
701 | readsw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:709:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
709 | readsl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:718:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
718 | writesb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:727:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
727 | writesw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:736:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
736 | writesl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
In file included from drivers/iio/light/opt4060.c:11:
In file included from include/linux/i2c.h:19:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:21:
In file included from include/linux/mm.h:2213:
include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
>> drivers/iio/light/opt4060.c:1026:8: warning: variable 'chan' is uninitialized when used here [-Wuninitialized]
1026 | chan,
| ^~~~
include/linux/iio/events.h:54:51: note: expanded from macro 'IIO_UNMOD_EVENT_CODE'
54 | IIO_EVENT_CODE(chan_type, 0, 0, direction, type, number, 0, 0)
| ^~~~~~
include/linux/iio/events.h:29:9: note: expanded from macro 'IIO_EVENT_CODE'
29 | ((u16)chan))
| ^~~~
drivers/iio/light/opt4060.c:994:15: note: initialize the variable 'chan' to silence this warning
994 | int ret, chan, dummy;
| ^
| = 0
14 warnings generated.

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for MODVERSIONS
Depends on [n]: MODULES [=y] && !COMPILE_TEST [=y]
Selected by [y]:
- RANDSTRUCT_FULL [=y] && (CC_HAS_RANDSTRUCT [=y] || GCC_PLUGINS [=n]) && MODULES [=y]
WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]


vim +/chan +1026 drivers/iio/light/opt4060.c

989
990 static irqreturn_t opt4060_irq_thread(int irq, void *private)
991 {
992 struct iio_dev *idev = private;
993 struct opt4060_chip *chip = iio_priv(idev);
994 int ret, chan, dummy;
995 unsigned int int_res;
996
997 ret = regmap_read(chip->regmap, OPT4060_RES_CTRL, &int_res);
998 if (ret < 0) {
999 dev_err(chip->dev, "Failed to read interrupt reasons.\n");
1000 return IRQ_NONE;
1001 }
1002
1003 if (!chip->data_trigger_active) {
1004 /* Only trigger interrupts on thresholds */
1005 ret = opt4060_set_int_state(chip, OPT4060_INT_CTRL_THRESHOLD);
1006 if (ret) {
1007 dev_err(chip->dev, "Failed to set interrupt state\n");
1008 return IRQ_NONE;
1009 }
1010 }
1011
1012 /* Read OPT4060_CTRL to clear interrupt */
1013 ret = regmap_read(chip->regmap, OPT4060_CTRL, &dummy);
1014 if (ret < 0) {
1015 dev_err(chip->dev, "Failed to clear interrupt\n");
1016 return IRQ_NONE;
1017 }
1018
1019 /* Handle events */
1020 if (int_res & (OPT4060_RES_CTRL_FLAG_H | OPT4060_RES_CTRL_FLAG_L)) {
1021 u64 code;
1022
1023 /* Check if the interrupt is from the lower threshold */
1024 if (int_res & OPT4060_RES_CTRL_FLAG_L) {
1025 code = IIO_UNMOD_EVENT_CODE(IIO_LIGHT,
> 1026 chan,
1027 IIO_EV_TYPE_THRESH,
1028 IIO_EV_DIR_FALLING);
1029 iio_push_event(idev, code,
1030 iio_get_time_ns(idev));
1031 }
1032 /* Check if the interrupt is from the upper threshold */
1033 if (int_res & OPT4060_RES_CTRL_FLAG_H) {
1034 code = IIO_UNMOD_EVENT_CODE(IIO_LIGHT,
1035 chan,
1036 IIO_EV_TYPE_THRESH,
1037 IIO_EV_DIR_RISING);
1038 iio_push_event(idev, code,
1039 iio_get_time_ns(idev));
1040 }
1041 /* Handle threshold triggers */
1042 if (chip->threshold_trigger_active && iio_buffer_enabled(idev))
1043 iio_trigger_poll_nested(chip->threshold_trig);
1044 }
1045
1046 /* Handle conversion ready */
1047 if (int_res & OPT4060_RES_CTRL_CONV_READY) {
1048 /* Signal completion for potentially waiting reads */
1049 complete(&chip->completion);
1050
1051 /* Handle data ready triggers */
1052 if (chip->data_trigger_active && iio_buffer_enabled(idev))
1053 iio_trigger_poll_nested(chip->data_trig);
1054 }
1055 return IRQ_HANDLED;
1056 }
1057

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