Message ID | 20241028071118.699951-6-ahaslam@baylibre.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | Improvements and Enhancements for AD5791 DAC Driver | expand |
Hi, kernel test robot noticed the following build warnings: [auto build test WARNING on jic23-iio/togreg] [also build test WARNING on linus/master v6.12-rc5 next-20241028] [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/ahaslam-baylibre-com/dt-bindings-iio-dac-ad5791-Add-optional-reset-clr-and-ldac-gpios/20241028-151319 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg patch link: https://lore.kernel.org/r/20241028071118.699951-6-ahaslam%40baylibre.com patch subject: [PATCH 5/6] iio: dac: ad5791: Use devm_regulator_get_enable_read_voltage config: x86_64-buildonly-randconfig-004-20241028 (https://download.01.org/0day-ci/archive/20241029/202410290245.0RC0cDV4-lkp@intel.com/config) compiler: clang version 19.1.2 (https://github.com/llvm/llvm-project 7ba7d8e2f7b6445b60679da826210cdde29eaf8b) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241029/202410290245.0RC0cDV4-lkp@intel.com/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@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202410290245.0RC0cDV4-lkp@intel.com/ All warnings (new ones prefixed by >>): In file included from drivers/iio/dac/ad5791.c:14: In file included from include/linux/spi/spi.h:17: In file included from include/linux/scatterlist.h:8: 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/dac/ad5791.c:370:35: warning: variable 'ret' is uninitialized when used here [-Wuninitialized] 370 | return dev_err_probe(&spi->dev, ret, "failed to get vdd voltage\n"); | ^~~ drivers/iio/dac/ad5791.c:336:9: note: initialize the variable 'ret' to silence this warning 336 | int ret, pos_voltage_uv = 0, neg_voltage_uv = 0; | ^ | = 0 2 warnings generated. vim +/ret +370 drivers/iio/dac/ad5791.c 330 331 static int ad5791_probe(struct spi_device *spi) 332 { 333 const struct ad5791_platform_data *pdata = dev_get_platdata(&spi->dev); 334 struct iio_dev *indio_dev; 335 struct ad5791_state *st; 336 int ret, pos_voltage_uv = 0, neg_voltage_uv = 0; 337 bool use_rbuf_gain2; 338 339 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); 340 if (!indio_dev) 341 return -ENOMEM; 342 st = iio_priv(indio_dev); 343 344 st->gpio_reset = devm_gpiod_get_optional(&spi->dev, "reset", 345 GPIOD_OUT_HIGH); 346 if (IS_ERR(st->gpio_reset)) 347 return PTR_ERR(st->gpio_reset); 348 349 st->gpio_clear = devm_gpiod_get_optional(&spi->dev, "clear", 350 GPIOD_OUT_LOW); 351 if (IS_ERR(st->gpio_clear)) 352 return PTR_ERR(st->gpio_clear); 353 354 st->gpio_ldac = devm_gpiod_get_optional(&spi->dev, "ldac", 355 GPIOD_OUT_HIGH); 356 if (IS_ERR(st->gpio_ldac)) 357 return PTR_ERR(st->gpio_ldac); 358 359 st->pwr_down = true; 360 st->spi = spi; 361 362 if (pdata) 363 use_rbuf_gain2 = pdata->use_rbuf_gain2; 364 else 365 use_rbuf_gain2 = device_property_read_bool(&spi->dev, 366 "adi,rbuf-gain2-en"); 367 368 pos_voltage_uv = devm_regulator_get_enable_read_voltage(&spi->dev, "vdd"); 369 if (pos_voltage_uv < 0 && pos_voltage_uv != -ENODEV) > 370 return dev_err_probe(&spi->dev, ret, "failed to get vdd voltage\n"); 371 372 neg_voltage_uv = devm_regulator_get_enable_read_voltage(&spi->dev, "vss"); 373 if (neg_voltage_uv < 0 && neg_voltage_uv != -ENODEV) 374 return dev_err_probe(&spi->dev, ret, "failed to get vss voltage\n"); 375 376 if (neg_voltage_uv >= 0 && pos_voltage_uv >= 0) { 377 st->vref_mv = (pos_voltage_uv + neg_voltage_uv) / 1000; 378 st->vref_neg_mv = neg_voltage_uv / 1000; 379 } else if (pdata) { 380 st->vref_mv = pdata->vref_pos_mv + pdata->vref_neg_mv; 381 st->vref_neg_mv = pdata->vref_neg_mv; 382 } else { 383 dev_warn(&spi->dev, "reference voltage unspecified\n"); 384 } 385 386 if (st->gpio_reset) { 387 fsleep(20); 388 gpiod_set_value_cansleep(st->gpio_reset, 0); 389 } else { 390 ret = ad5791_spi_write(st, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET); 391 if (ret) 392 return dev_err_probe(&spi->dev, ret, "fail to reset\n"); 393 } 394 395 st->chip_info = spi_get_device_match_data(spi); 396 if (!st->chip_info) 397 return dev_err_probe(&spi->dev, -EINVAL, "no chip info\n"); 398 399 st->ctrl = AD5761_CTRL_LINCOMP(st->chip_info->get_lin_comp(st->vref_mv)) 400 | (use_rbuf_gain2 ? 0 : AD5791_CTRL_RBUF) | 401 AD5791_CTRL_BIN2SC; 402 403 ret = ad5791_spi_write(st, AD5791_ADDR_CTRL, st->ctrl | 404 AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI); 405 if (ret) 406 return dev_err_probe(&spi->dev, ret, "fail to write ctrl register\n"); 407 408 spi_set_drvdata(spi, indio_dev); 409 indio_dev->info = &ad5791_info; 410 indio_dev->modes = INDIO_DIRECT_MODE; 411 indio_dev->channels = &st->chip_info->channel; 412 indio_dev->num_channels = 1; 413 indio_dev->name = st->chip_info->name; 414 ret = iio_device_register(indio_dev); 415 if (ret) 416 return dev_err_probe(&spi->dev, ret, "unable to register iio device\n"); 417 418 return 0; 419 } 420
diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index a7cf19346cf0..cf3d41a10c20 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c @@ -356,32 +356,6 @@ static int ad5791_probe(struct spi_device *spi) if (IS_ERR(st->gpio_ldac)) return PTR_ERR(st->gpio_ldac); - st->reg_vdd = devm_regulator_get(&spi->dev, "vdd"); - if (!IS_ERR(st->reg_vdd)) { - ret = regulator_enable(st->reg_vdd); - if (ret) - return ret; - - ret = regulator_get_voltage(st->reg_vdd); - if (ret < 0) - goto error_disable_reg_pos; - - pos_voltage_uv = ret; - } - - st->reg_vss = devm_regulator_get(&spi->dev, "vss"); - if (!IS_ERR(st->reg_vss)) { - ret = regulator_enable(st->reg_vss); - if (ret) - goto error_disable_reg_pos; - - ret = regulator_get_voltage(st->reg_vss); - if (ret < 0) - goto error_disable_reg_neg; - - neg_voltage_uv = ret; - } - st->pwr_down = true; st->spi = spi; @@ -391,7 +365,15 @@ static int ad5791_probe(struct spi_device *spi) use_rbuf_gain2 = device_property_read_bool(&spi->dev, "adi,rbuf-gain2-en"); - if (!IS_ERR(st->reg_vss) && !IS_ERR(st->reg_vdd)) { + pos_voltage_uv = devm_regulator_get_enable_read_voltage(&spi->dev, "vdd"); + if (pos_voltage_uv < 0 && pos_voltage_uv != -ENODEV) + return dev_err_probe(&spi->dev, ret, "failed to get vdd voltage\n"); + + neg_voltage_uv = devm_regulator_get_enable_read_voltage(&spi->dev, "vss"); + if (neg_voltage_uv < 0 && neg_voltage_uv != -ENODEV) + return dev_err_probe(&spi->dev, ret, "failed to get vss voltage\n"); + + if (neg_voltage_uv >= 0 && pos_voltage_uv >= 0) { st->vref_mv = (pos_voltage_uv + neg_voltage_uv) / 1000; st->vref_neg_mv = neg_voltage_uv / 1000; } else if (pdata) { @@ -407,7 +389,7 @@ static int ad5791_probe(struct spi_device *spi) } else { ret = ad5791_spi_write(st, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET); if (ret) - goto error_disable_reg_neg; + return dev_err_probe(&spi->dev, ret, "fail to reset\n"); } st->chip_info = spi_get_device_match_data(spi); @@ -421,7 +403,7 @@ static int ad5791_probe(struct spi_device *spi) ret = ad5791_spi_write(st, AD5791_ADDR_CTRL, st->ctrl | AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI); if (ret) - goto error_disable_reg_neg; + return dev_err_probe(&spi->dev, ret, "fail to write ctrl register\n"); spi_set_drvdata(spi, indio_dev); indio_dev->info = &ad5791_info; @@ -431,30 +413,16 @@ static int ad5791_probe(struct spi_device *spi) indio_dev->name = st->chip_info->name; ret = iio_device_register(indio_dev); if (ret) - goto error_disable_reg_neg; + return dev_err_probe(&spi->dev, ret, "unable to register iio device\n"); return 0; - -error_disable_reg_neg: - if (!IS_ERR(st->reg_vss)) - regulator_disable(st->reg_vss); -error_disable_reg_pos: - if (!IS_ERR(st->reg_vdd)) - regulator_disable(st->reg_vdd); - return ret; } static void ad5791_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); - struct ad5791_state *st = iio_priv(indio_dev); iio_device_unregister(indio_dev); - if (!IS_ERR(st->reg_vdd)) - regulator_disable(st->reg_vdd); - - if (!IS_ERR(st->reg_vss)) - regulator_disable(st->reg_vss); } static const struct of_device_id ad5791_of_match[] = {