Hi Bartosz,

I love your patch! Yet something to improve:

[auto build test ERROR on iio/togreg]
[also build test ERROR on staging/staging-testing v5.8-rc3 next-20200702]
[cannot apply to xlnx/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    
https://github.com/0day-ci/linux/commits/Bartosz-Golaszewski/iio-adc-xilinx-xadc-use-devm_krealloc/20200703-002747
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
config: i386-randconfig-s002-20200702 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.2-3-gfa153962-dirty
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <l...@intel.com>

All error/warnings (new ones prefixed by >>):

   drivers/iio/adc/xilinx-xadc-core.c: In function 'xadc_parse_dt':
>> drivers/iio/adc/xilinx-xadc-core.c:1179:24: error: implicit declaration of 
>> function 'devm_krealloc'; did you mean 'devm_kcalloc'? 
>> [-Werror=implicit-function-declaration]
    1179 |  indio_dev->channels = devm_krealloc(dev, channels,
         |                        ^~~~~~~~~~~~~
         |                        devm_kcalloc
>> drivers/iio/adc/xilinx-xadc-core.c:1179:22: warning: assignment to 'const 
>> struct iio_chan_spec *' from 'int' makes pointer from integer without a cast 
>> [-Wint-conversion]
    1179 |  indio_dev->channels = devm_krealloc(dev, channels,
         |                      ^
   cc1: some warnings being treated as errors

vim +1179 drivers/iio/adc/xilinx-xadc-core.c

  1093  
  1094  static int xadc_parse_dt(struct iio_dev *indio_dev, struct device_node 
*np,
  1095          unsigned int *conf)
  1096  {
  1097          struct device *dev = indio_dev->dev.parent;
  1098          struct xadc *xadc = iio_priv(indio_dev);
  1099          struct iio_chan_spec *channels, *chan;
  1100          struct device_node *chan_node, *child;
  1101          unsigned int num_channels;
  1102          const char *external_mux;
  1103          u32 ext_mux_chan;
  1104          u32 reg;
  1105          int ret;
  1106  
  1107          *conf = 0;
  1108  
  1109          ret = of_property_read_string(np, "xlnx,external-mux", 
&external_mux);
  1110          if (ret < 0 || strcasecmp(external_mux, "none") == 0)
  1111                  xadc->external_mux_mode = XADC_EXTERNAL_MUX_NONE;
  1112          else if (strcasecmp(external_mux, "single") == 0)
  1113                  xadc->external_mux_mode = XADC_EXTERNAL_MUX_SINGLE;
  1114          else if (strcasecmp(external_mux, "dual") == 0)
  1115                  xadc->external_mux_mode = XADC_EXTERNAL_MUX_DUAL;
  1116          else
  1117                  return -EINVAL;
  1118  
  1119          if (xadc->external_mux_mode != XADC_EXTERNAL_MUX_NONE) {
  1120                  ret = of_property_read_u32(np, 
"xlnx,external-mux-channel",
  1121                                          &ext_mux_chan);
  1122                  if (ret < 0)
  1123                          return ret;
  1124  
  1125                  if (xadc->external_mux_mode == 
XADC_EXTERNAL_MUX_SINGLE) {
  1126                          if (ext_mux_chan == 0)
  1127                                  ext_mux_chan = XADC_REG_VPVN;
  1128                          else if (ext_mux_chan <= 16)
  1129                                  ext_mux_chan = 
XADC_REG_VAUX(ext_mux_chan - 1);
  1130                          else
  1131                                  return -EINVAL;
  1132                  } else {
  1133                          if (ext_mux_chan > 0 && ext_mux_chan <= 8)
  1134                                  ext_mux_chan = 
XADC_REG_VAUX(ext_mux_chan - 1);
  1135                          else
  1136                                  return -EINVAL;
  1137                  }
  1138  
  1139                  *conf |= XADC_CONF0_MUX | XADC_CONF0_CHAN(ext_mux_chan);
  1140          }
  1141  
  1142          channels = devm_kmemdup(dev, xadc_channels,
  1143                                  sizeof(xadc_channels), GFP_KERNEL);
  1144          if (!channels)
  1145                  return -ENOMEM;
  1146  
  1147          num_channels = 9;
  1148          chan = &channels[9];
  1149  
  1150          chan_node = of_get_child_by_name(np, "xlnx,channels");
  1151          if (chan_node) {
  1152                  for_each_child_of_node(chan_node, child) {
  1153                          if (num_channels >= ARRAY_SIZE(xadc_channels)) {
  1154                                  of_node_put(child);
  1155                                  break;
  1156                          }
  1157  
  1158                          ret = of_property_read_u32(child, "reg", &reg);
  1159                          if (ret || reg > 16)
  1160                                  continue;
  1161  
  1162                          if (of_property_read_bool(child, 
"xlnx,bipolar"))
  1163                                  chan->scan_type.sign = 's';
  1164  
  1165                          if (reg == 0) {
  1166                                  chan->scan_index = 11;
  1167                                  chan->address = XADC_REG_VPVN;
  1168                          } else {
  1169                                  chan->scan_index = 15 + reg;
  1170                                  chan->address = XADC_REG_VAUX(reg - 1);
  1171                          }
  1172                          num_channels++;
  1173                          chan++;
  1174                  }
  1175          }
  1176          of_node_put(chan_node);
  1177  
  1178          indio_dev->num_channels = num_channels;
> 1179          indio_dev->channels = devm_krealloc(dev, channels,
  1180                                              sizeof(*channels) * 
num_channels,
  1181                                              GFP_KERNEL);
  1182          /* If we can't resize the channels array, just use the original 
*/
  1183          if (!indio_dev->channels)
  1184                  indio_dev->channels = channels;
  1185  
  1186          return 0;
  1187  }
  1188  

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

Attachment: .config.gz
Description: application/gzip

Reply via email to