Re: [jic23-iio:testing 15/61] drivers/iio/adc/ad7173.c:1254 ad7173_fw_parse_channel_config() error: uninitialized symbol 'is_current_chan'.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 1 Jul 2024 17:30:57 +0200
Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:

> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git testing
> head:   e2afe21f9b0bfa3f188cd5a60940b07a85d65e9a
> commit: cfc4c76b75ab68a95976e0db725baff385c4136d [15/61] iio: adc: ad7173: Add support for AD411x devices
> config: x86_64-randconfig-161-20240623 (https://download.01.org/0day-ci/archive/20240623/202406232046.DKfBJq6o-lkp@xxxxxxxxx/config)
> compiler: gcc-11 (Ubuntu 11.4.0-4ubuntu1) 11.4.0
> 
> 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>
> | Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> | Closes: https://lore.kernel.org/r/202406232046.DKfBJq6o-lkp@xxxxxxxxx/
> 
> smatch warnings:
> drivers/iio/adc/ad7173.c:1254 ad7173_fw_parse_channel_config() error: uninitialized symbol 'is_current_chan'.

Thanks. Initializing to false or setting it in the else should do the job.

The IIO Tree is a complex mess of merges as the moment, so I'll apply a patch
on top.  If anyone wants to spin one that would save me a few mins.

Jonathan

> 
> vim +/is_current_chan +1254 drivers/iio/adc/ad7173.c
> 
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1184  static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev)
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1185  {
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1186  	struct ad7173_channel *chans_st_arr, *chan_st_priv;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1187  	struct ad7173_state *st = iio_priv(indio_dev);
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1188  	struct device *dev = indio_dev->dev.parent;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1189  	struct iio_chan_spec *chan_arr, *chan;
> 87477bf7433028 Dumitru Ceclan   2024-06-07  1190  	unsigned int ain[AD7173_NO_AINS_PER_CHANNEL], chan_index = 0;
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1191  	int ref_sel, ret, is_current_chan, num_channels;
> 51d5a38b21113a Dumitru Ceclan   2024-06-07  1192  
> 51d5a38b21113a Dumitru Ceclan   2024-06-07  1193  	num_channels = device_get_child_node_count(dev);
> 51d5a38b21113a Dumitru Ceclan   2024-06-07  1194  
> 51d5a38b21113a Dumitru Ceclan   2024-06-07  1195  	if (st->info->has_temp)
> 51d5a38b21113a Dumitru Ceclan   2024-06-07  1196  		num_channels++;
> 51d5a38b21113a Dumitru Ceclan   2024-06-07  1197  
> 51d5a38b21113a Dumitru Ceclan   2024-06-07  1198  	if (num_channels == 0)
> 51d5a38b21113a Dumitru Ceclan   2024-06-07  1199  		return dev_err_probe(dev, -ENODATA, "No channels specified\n");
> 51d5a38b21113a Dumitru Ceclan   2024-06-07  1200  
> 51d5a38b21113a Dumitru Ceclan   2024-06-07  1201  	if (num_channels > st->info->num_channels)
> 51d5a38b21113a Dumitru Ceclan   2024-06-07  1202  		return dev_err_probe(dev, -EINVAL,
> 51d5a38b21113a Dumitru Ceclan   2024-06-07  1203  			"Too many channels specified. Maximum is %d, not including temperature channel if supported.\n",
> 51d5a38b21113a Dumitru Ceclan   2024-06-07  1204  			st->info->num_channels);
> 51d5a38b21113a Dumitru Ceclan   2024-06-07  1205  
> 51d5a38b21113a Dumitru Ceclan   2024-06-07  1206  	indio_dev->num_channels = num_channels;
> 51d5a38b21113a Dumitru Ceclan   2024-06-07  1207  	st->num_channels = num_channels;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1208  
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1209  	chan_arr = devm_kcalloc(dev, sizeof(*indio_dev->channels),
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1210  				st->num_channels, GFP_KERNEL);
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1211  	if (!chan_arr)
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1212  		return -ENOMEM;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1213  
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1214  	chans_st_arr = devm_kcalloc(dev, st->num_channels, sizeof(*st->channels),
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1215  				    GFP_KERNEL);
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1216  	if (!chans_st_arr)
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1217  		return -ENOMEM;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1218  
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1219  	indio_dev->channels = chan_arr;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1220  	st->channels = chans_st_arr;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1221  
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1222  	if (st->info->has_temp) {
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1223  		chan_arr[chan_index] = ad7173_temp_iio_channel_template;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1224  		chan_st_priv = &chans_st_arr[chan_index];
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1225  		chan_st_priv->ain =
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1226  			AD7173_CH_ADDRESS(chan_arr[chan_index].channel,
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1227  					  chan_arr[chan_index].channel2);
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1228  		chan_st_priv->cfg.bipolar = false;
> ab6f0ab1781371 Dumitru Ceclan   2024-05-21  1229  		chan_st_priv->cfg.input_buf = st->info->has_input_buf;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1230  		chan_st_priv->cfg.ref_sel = AD7173_SETUP_REF_SEL_INT_REF;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1231  		st->adc_mode |= AD7173_ADC_MODE_REF_EN;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1232  
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1233  		chan_index++;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1234  	}
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1235  
> cf84f1e0a8fd23 Jonathan Cameron 2024-03-30  1236  	device_for_each_child_node_scoped(dev, child) {
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1237  		chan = &chan_arr[chan_index];
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1238  		*chan = ad7173_channel_template;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1239  		chan_st_priv = &chans_st_arr[chan_index];
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1240  		ret = fwnode_property_read_u32_array(child, "diff-channels",
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1241  						     ain, ARRAY_SIZE(ain));
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1242  		if (ret) {
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1243  			ret = fwnode_property_read_u32(child, "single-channel",
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1244  						       ain);
> cf84f1e0a8fd23 Jonathan Cameron 2024-03-30  1245  			if (ret)
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1246  				return dev_err_probe(dev, ret,
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1247  					"Channel must define one of diff-channels or single-channel.\n");
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1248  
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1249  			is_current_chan = fwnode_property_read_bool(child, "adi,current-channel");
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1250  		} else {
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1251  			chan->differential = true;
> 
> is_current_chan not initialized on this path.
> 
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1252  		}
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1253  
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07 @1254  		if (is_current_chan) {
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1255  			ret = ad4111_validate_current_ain(st, ain);
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1256  			if (ret)
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1257  				return ret;
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1258  		} else {
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1259  			if (!chan->differential) {
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1260  				ret = fwnode_property_read_u32(child,
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1261  					"common-mode-channel", ain + 1);
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1262  				if (ret)
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1263  					return dev_err_probe(dev, ret,
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1264  						"common-mode-channel must be defined for single-ended channels.\n");
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1265  			}
> 87477bf7433028 Dumitru Ceclan   2024-06-07  1266  			ret = ad7173_validate_voltage_ain_inputs(st, ain[0], ain[1]);
> 87477bf7433028 Dumitru Ceclan   2024-06-07  1267  			if (ret)
> 87477bf7433028 Dumitru Ceclan   2024-06-07  1268  				return ret;
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1269  		}
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1270  
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1271  		ret = fwnode_property_match_property_string(child,
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1272  							    "adi,reference-select",
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1273  							    ad7173_ref_sel_str,
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1274  							    ARRAY_SIZE(ad7173_ref_sel_str));
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1275  		if (ret < 0)
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1276  			ref_sel = AD7173_SETUP_REF_SEL_INT_REF;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1277  		else
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1278  			ref_sel = ret;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1279  
> 87477bf7433028 Dumitru Ceclan   2024-06-07  1280  		ret = ad7173_validate_reference(st, ref_sel);
> 87477bf7433028 Dumitru Ceclan   2024-06-07  1281  		if (ret)
> 87477bf7433028 Dumitru Ceclan   2024-06-07  1282  			return ret;
> cf84f1e0a8fd23 Jonathan Cameron 2024-03-30  1283  
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1284  		if (ref_sel == AD7173_SETUP_REF_SEL_INT_REF)
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1285  			st->adc_mode |= AD7173_ADC_MODE_REF_EN;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1286  		chan_st_priv->cfg.ref_sel = ref_sel;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1287  
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1288  		chan->address = chan_index;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1289  		chan->scan_index = chan_index;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1290  		chan->channel = ain[0];
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1291  		chan_st_priv->chan_reg = chan_index;
> ab6f0ab1781371 Dumitru Ceclan   2024-05-21  1292  		chan_st_priv->cfg.input_buf = st->info->has_input_buf;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1293  		chan_st_priv->cfg.odr = 0;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1294  
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1295  		chan_st_priv->cfg.bipolar = fwnode_property_read_bool(child, "bipolar");
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1296  		if (chan_st_priv->cfg.bipolar)
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1297  			chan->info_mask_separate |= BIT(IIO_CHAN_INFO_OFFSET);
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1298  
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1299  		if (is_current_chan) {
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1300  			chan->type = IIO_CURRENT;
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1301  			chan->differential = false;
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1302  			chan->channel2 = 0;
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1303  			chan_st_priv->ain = ad4111_current_channel_config[ain[0]];
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1304  		} else {
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1305  			chan_st_priv->cfg.input_buf = st->info->has_input_buf;
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1306  			chan->channel2 = ain[1];
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1307  			chan_st_priv->ain = AD7173_CH_ADDRESS(ain[0], ain[1]);
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1308  		}
> cfc4c76b75ab68 Dumitru Ceclan   2024-06-07  1309  
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1310  		chan_index++;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1311  	}
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1312  	return 0;
> 76a1e6a4280211 Dumitru Ceclan   2024-02-28  1313  }
> 





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux