Re: [PATCH 2/2] iio: dac: driver for MCP4821

From: kernel test robot
Date: Sat Nov 18 2023 - 21:20:03 EST


Hi Anshul,

kernel test robot noticed the following build warnings:

[auto build test WARNING on jic23-iio/togreg]
[also build test WARNING on robh/for-next linus/master v6.7-rc1 next-20231117]
[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/Anshul-Dalal/iio-dac-driver-for-MCP4821/20231117-153451
base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
patch link: https://lore.kernel.org/r/20231117073040.685860-2-anshulusr%40gmail.com
patch subject: [PATCH 2/2] iio: dac: driver for MCP4821
config: i386-randconfig-061-20231119 (https://download.01.org/0day-ci/archive/20231119/202311190944.LgtvolpG-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231119/202311190944.LgtvolpG-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/202311190944.LgtvolpG-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> drivers/iio/dac/mcp4821.c:120:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __be16 [usertype] write_val @@ got unsigned long @@
drivers/iio/dac/mcp4821.c:120:27: sparse: expected restricted __be16 [usertype] write_val
drivers/iio/dac/mcp4821.c:120:27: sparse: got unsigned long
>> drivers/iio/dac/mcp4821.c:122:35: sparse: sparse: invalid assignment: |=
>> drivers/iio/dac/mcp4821.c:122:35: sparse: left side has type restricted __be16
>> drivers/iio/dac/mcp4821.c:122:35: sparse: right side has type unsigned long
>> drivers/iio/dac/mcp4821.c:123:36: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected unsigned short [usertype] val @@ got restricted __be16 [usertype] write_val @@
drivers/iio/dac/mcp4821.c:123:36: sparse: expected unsigned short [usertype] val
drivers/iio/dac/mcp4821.c:123:36: sparse: got restricted __be16 [usertype] write_val
drivers/iio/dac/mcp4821.c: note: in included file (through include/linux/rculist.h, include/linux/pid.h, include/linux/sched.h, ...):
include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true

vim +120 drivers/iio/dac/mcp4821.c

106
107 static int mcp4821_write_raw(struct iio_dev *indio_dev,
108 struct iio_chan_spec const *chan, int val,
109 int val2, long mask)
110 {
111 struct mcp4821_state *state;
112 __be16 write_val;
113 u8 write_buffer[2];
114 int ret;
115 bool is_value_valid = val >= 0 && val < BIT(chan->scan_type.realbits) &&
116 val2 == 0;
117 if (mask == IIO_CHAN_INFO_RAW && is_value_valid) {
118 state = iio_priv(indio_dev);
119
> 120 write_val = MCP4821_ACTIVE_MODE | val << chan->scan_type.shift;
121 if (chan->channel)
> 122 write_val |= MCP4802_SECOND_CHAN;
> 123 put_unaligned_be16(write_val, write_buffer);
124 ret = spi_write(state->spi, write_buffer, sizeof(write_buffer));
125 if (ret) {
126 dev_err(&state->spi->dev,
127 "Failed to write to device: %d", ret);
128 return ret;
129 }
130
131 mutex_lock(&state->lock);
132 state->dac_value[chan->channel] = val;
133 mutex_unlock(&state->lock);
134 return 0;
135 } else {
136 return -EINVAL;
137 }
138 }
139

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