Re: [PATCH 1/4] iio: pressure: bmp280: use bulk regulator ops

From: Jonathan Cameron
Date: Tue Oct 22 2019 - 06:03:56 EST


On Sun, 6 Oct 2019 10:49:18 +0100
Jonathan Cameron <jic23@xxxxxxxxxx> wrote:

> On Wed, 2 Oct 2019 17:57:30 +0200
> Bartosz Golaszewski <brgl@xxxxxxxx> wrote:
>
> > År., 2 paÅ 2019 o 15:06 kbuild test robot <lkp@xxxxxxxxx> napisaÅ(a):
> > >
> > > Hi Bartosz,
> > >
> > > I love your patch! Yet something to improve:
> > >
> > > [auto build test ERROR on iio/togreg]
> > > [cannot apply to v5.4-rc1 next-20191002]
> > > [if your patch is applied to the wrong git tree, please drop us a note to help
> > > improve the system. BTW, we also suggest to use '--base' option to specify the
> > > base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
> > >
> > > url: https://github.com/0day-ci/linux/commits/Bartosz-Golaszewski/iio-pressure-bmp280-code-shrink/20191002-194508
> > > base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
> > > config: sh-allmodconfig (attached as .config)
> > > compiler: sh4-linux-gcc (GCC) 7.4.0
> > > reproduce:
> > > wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> > > chmod +x ~/bin/make.cross
> > > # save the attached .config to linux build tree
> > > GCC_VERSION=7.4.0 make.cross ARCH=sh
> > >
> > > If you fix the issue, kindly add following tag
> > > Reported-by: kbuild test robot <lkp@xxxxxxxxx>
> > >
> > > All errors (new ones prefixed by >>):
> > >
> > > drivers/iio/pressure/bmp280-core.c: In function 'bmp280_common_probe':
> > > >> drivers/iio/pressure/bmp280-core.c:1041:2: error: implicit declaration of function 'regulator_bulk_set_supply_names'; did you mean 'regulator_bulk_register_supply_alias'? [-Werror=implicit-function-declaration]
> > > regulator_bulk_set_supply_names(data->supplies,
> > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > regulator_bulk_register_supply_alias
> > > cc1: some warnings being treated as errors
> > >
> >
> > This function has been introduced in commit d0087e72710c ("regulator:
> > provide regulator_bulk_set_supply_names()") and released in v5.4-rc1
> > but it's not present in this tree. In other words: a false positive.
> Kind of handy to known though ;) My tree doesn't contain it yet
> either. That should be fixed later this week after a pull request
> and rebase. I'll not be applying this series until after that.
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan

>
> Thanks,
>
> Jonathan
>
> >
> > Bart
> >
> > > vim +1041 drivers/iio/pressure/bmp280-core.c
> > >
> > > 986
> > > 987 int bmp280_common_probe(struct device *dev,
> > > 988 struct regmap *regmap,
> > > 989 unsigned int chip,
> > > 990 const char *name,
> > > 991 int irq)
> > > 992 {
> > > 993 int ret;
> > > 994 struct iio_dev *indio_dev;
> > > 995 struct bmp280_data *data;
> > > 996 unsigned int chip_id;
> > > 997 struct gpio_desc *gpiod;
> > > 998
> > > 999 indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
> > > 1000 if (!indio_dev)
> > > 1001 return -ENOMEM;
> > > 1002
> > > 1003 data = iio_priv(indio_dev);
> > > 1004 mutex_init(&data->lock);
> > > 1005 data->dev = dev;
> > > 1006
> > > 1007 indio_dev->dev.parent = dev;
> > > 1008 indio_dev->name = name;
> > > 1009 indio_dev->channels = bmp280_channels;
> > > 1010 indio_dev->info = &bmp280_info;
> > > 1011 indio_dev->modes = INDIO_DIRECT_MODE;
> > > 1012
> > > 1013 switch (chip) {
> > > 1014 case BMP180_CHIP_ID:
> > > 1015 indio_dev->num_channels = 2;
> > > 1016 data->chip_info = &bmp180_chip_info;
> > > 1017 data->oversampling_press = ilog2(8);
> > > 1018 data->oversampling_temp = ilog2(1);
> > > 1019 data->start_up_time = 10000;
> > > 1020 break;
> > > 1021 case BMP280_CHIP_ID:
> > > 1022 indio_dev->num_channels = 2;
> > > 1023 data->chip_info = &bmp280_chip_info;
> > > 1024 data->oversampling_press = ilog2(16);
> > > 1025 data->oversampling_temp = ilog2(2);
> > > 1026 data->start_up_time = 2000;
> > > 1027 break;
> > > 1028 case BME280_CHIP_ID:
> > > 1029 indio_dev->num_channels = 3;
> > > 1030 data->chip_info = &bme280_chip_info;
> > > 1031 data->oversampling_press = ilog2(16);
> > > 1032 data->oversampling_humid = ilog2(16);
> > > 1033 data->oversampling_temp = ilog2(2);
> > > 1034 data->start_up_time = 2000;
> > > 1035 break;
> > > 1036 default:
> > > 1037 return -EINVAL;
> > > 1038 }
> > > 1039
> > > 1040 /* Bring up regulators */
> > > > 1041 regulator_bulk_set_supply_names(data->supplies,
> > > 1042 bmp280_supply_names,
> > > 1043 BMP280_NUM_SUPPLIES);
> > > 1044
> > > 1045 ret = devm_regulator_bulk_get(dev,
> > > 1046 BMP280_NUM_SUPPLIES, data->supplies);
> > > 1047 if (ret) {
> > > 1048 dev_err(dev, "failed to get regulators\n");
> > > 1049 return ret;
> > > 1050 }
> > > 1051
> > > 1052 ret = regulator_bulk_enable(BMP280_NUM_SUPPLIES, data->supplies);
> > > 1053 if (ret) {
> > > 1054 dev_err(dev, "failed to enable regulators\n");
> > > 1055 return ret;
> > > 1056 }
> > > 1057
> > > 1058 /* Wait to make sure we started up properly */
> > > 1059 usleep_range(data->start_up_time, data->start_up_time + 100);
> > > 1060
> > > 1061 /* Bring chip out of reset if there is an assigned GPIO line */
> > > 1062 gpiod = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
> > > 1063 /* Deassert the signal */
> > > 1064 if (!IS_ERR(gpiod)) {
> > > 1065 dev_info(dev, "release reset\n");
> > > 1066 gpiod_set_value(gpiod, 0);
> > > 1067 }
> > > 1068
> > > 1069 data->regmap = regmap;
> > > 1070 ret = regmap_read(regmap, BMP280_REG_ID, &chip_id);
> > > 1071 if (ret < 0)
> > > 1072 goto out_disable_regulators;
> > > 1073 if (chip_id != chip) {
> > > 1074 dev_err(dev, "bad chip id: expected %x got %x\n",
> > > 1075 chip, chip_id);
> > > 1076 ret = -EINVAL;
> > > 1077 goto out_disable_regulators;
> > > 1078 }
> > > 1079
> > > 1080 ret = data->chip_info->chip_config(data);
> > > 1081 if (ret < 0)
> > > 1082 goto out_disable_regulators;
> > > 1083
> > > 1084 dev_set_drvdata(dev, indio_dev);
> > > 1085
> > > 1086 /*
> > > 1087 * Some chips have calibration parameters "programmed into the devices'
> > > 1088 * non-volatile memory during production". Let's read them out at probe
> > > 1089 * time once. They will not change.
> > > 1090 */
> > > 1091 if (chip_id == BMP180_CHIP_ID) {
> > > 1092 ret = bmp180_read_calib(data, &data->calib.bmp180);
> > > 1093 if (ret < 0) {
> > > 1094 dev_err(data->dev,
> > > 1095 "failed to read calibration coefficients\n");
> > > 1096 goto out_disable_regulators;
> > > 1097 }
> > > 1098 } else if (chip_id == BMP280_CHIP_ID || chip_id == BME280_CHIP_ID) {
> > > 1099 ret = bmp280_read_calib(data, &data->calib.bmp280, chip_id);
> > > 1100 if (ret < 0) {
> > > 1101 dev_err(data->dev,
> > > 1102 "failed to read calibration coefficients\n");
> > > 1103 goto out_disable_regulators;
> > > 1104 }
> > > 1105 }
> > > 1106
> > > 1107 /*
> > > 1108 * Attempt to grab an optional EOC IRQ - only the BMP085 has this
> > > 1109 * however as it happens, the BMP085 shares the chip ID of BMP180
> > > 1110 * so we look for an IRQ if we have that.
> > > 1111 */
> > > 1112 if (irq > 0 || (chip_id == BMP180_CHIP_ID)) {
> > > 1113 ret = bmp085_fetch_eoc_irq(dev, name, irq, data);
> > > 1114 if (ret)
> > > 1115 goto out_disable_regulators;
> > > 1116 }
> > > 1117
> > > 1118 /* Enable runtime PM */
> > > 1119 pm_runtime_get_noresume(dev);
> > > 1120 pm_runtime_set_active(dev);
> > > 1121 pm_runtime_enable(dev);
> > > 1122 /*
> > > 1123 * Set autosuspend to two orders of magnitude larger than the
> > > 1124 * start-up time.
> > > 1125 */
> > > 1126 pm_runtime_set_autosuspend_delay(dev, data->start_up_time / 10);
> > > 1127 pm_runtime_use_autosuspend(dev);
> > > 1128 pm_runtime_put(dev);
> > > 1129
> > > 1130 ret = iio_device_register(indio_dev);
> > > 1131 if (ret)
> > > 1132 goto out_runtime_pm_disable;
> > > 1133
> > > 1134
> > > 1135 return 0;
> > > 1136
> > > 1137 out_runtime_pm_disable:
> > > 1138 pm_runtime_get_sync(data->dev);
> > > 1139 pm_runtime_put_noidle(data->dev);
> > > 1140 pm_runtime_disable(data->dev);
> > > 1141 out_disable_regulators:
> > > 1142 regulator_bulk_disable(BMP280_NUM_SUPPLIES, data->supplies);
> > > 1143 return ret;
> > > 1144 }
> > > 1145 EXPORT_SYMBOL(bmp280_common_probe);
> > > 1146
> > >
> > > ---
> > > 0-DAY kernel test infrastructure Open Source Technology Center
> > > https://lists.01.org/pipermail/kbuild-all Intel Corporation
>