Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'staging-5.0-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging/IIO driver fixes from Greg KH:
"Here are some small iio and staging driver fixes for 5.0-rc6.

Nothing big, just resolve some reported IIO driver issues, and one
staging driver bug. One staging driver patch was added and then
reverted as well.

All of these have been in linux-next for a while with no reported
issues"

* tag 'staging-5.0-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
Revert "staging: erofs: keep corrupted fs from crashing kernel in erofs_namei()"
staging: erofs: keep corrupted fs from crashing kernel in erofs_namei()
staging: octeon: fix broken phylib usage
iio: ti-ads8688: Update buffer allocation for timestamps
tools: iio: iio_generic_buffer: make num_loops signed
iio: adc: axp288: Fix TS-pin handling
iio: chemical: atlas-ph-sensor: correct IIO_TEMP values to millicelsius

+67 -23
+60 -16
drivers/iio/adc/axp288_adc.c
··· 27 27 #include <linux/iio/machine.h> 28 28 #include <linux/iio/driver.h> 29 29 30 - #define AXP288_ADC_EN_MASK 0xF1 31 - #define AXP288_ADC_TS_PIN_GPADC 0xF2 32 - #define AXP288_ADC_TS_PIN_ON 0xF3 30 + /* 31 + * This mask enables all ADCs except for the battery temp-sensor (TS), that is 32 + * left as-is to avoid breaking charging on devices without a temp-sensor. 33 + */ 34 + #define AXP288_ADC_EN_MASK 0xF0 35 + #define AXP288_ADC_TS_ENABLE 0x01 36 + 37 + #define AXP288_ADC_TS_CURRENT_ON_OFF_MASK GENMASK(1, 0) 38 + #define AXP288_ADC_TS_CURRENT_OFF (0 << 0) 39 + #define AXP288_ADC_TS_CURRENT_ON_WHEN_CHARGING (1 << 0) 40 + #define AXP288_ADC_TS_CURRENT_ON_ONDEMAND (2 << 0) 41 + #define AXP288_ADC_TS_CURRENT_ON (3 << 0) 33 42 34 43 enum axp288_adc_id { 35 44 AXP288_ADC_TS, ··· 53 44 struct axp288_adc_info { 54 45 int irq; 55 46 struct regmap *regmap; 47 + bool ts_enabled; 56 48 }; 57 49 58 50 static const struct iio_chan_spec axp288_adc_channels[] = { ··· 125 115 return IIO_VAL_INT; 126 116 } 127 117 128 - static int axp288_adc_set_ts(struct regmap *regmap, unsigned int mode, 129 - unsigned long address) 118 + /* 119 + * The current-source used for the battery temp-sensor (TS) is shared 120 + * with the GPADC. For proper fuel-gauge and charger operation the TS 121 + * current-source needs to be permanently on. But to read the GPADC we 122 + * need to temporary switch the TS current-source to ondemand, so that 123 + * the GPADC can use it, otherwise we will always read an all 0 value. 124 + */ 125 + static int axp288_adc_set_ts(struct axp288_adc_info *info, 126 + unsigned int mode, unsigned long address) 130 127 { 131 128 int ret; 132 129 133 - /* channels other than GPADC do not need to switch TS pin */ 130 + /* No need to switch the current-source if the TS pin is disabled */ 131 + if (!info->ts_enabled) 132 + return 0; 133 + 134 + /* Channels other than GPADC do not need the current source */ 134 135 if (address != AXP288_GP_ADC_H) 135 136 return 0; 136 137 137 - ret = regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, mode); 138 + ret = regmap_update_bits(info->regmap, AXP288_ADC_TS_PIN_CTRL, 139 + AXP288_ADC_TS_CURRENT_ON_OFF_MASK, mode); 138 140 if (ret) 139 141 return ret; 140 142 141 143 /* When switching to the GPADC pin give things some time to settle */ 142 - if (mode == AXP288_ADC_TS_PIN_GPADC) 144 + if (mode == AXP288_ADC_TS_CURRENT_ON_ONDEMAND) 143 145 usleep_range(6000, 10000); 144 146 145 147 return 0; ··· 167 145 mutex_lock(&indio_dev->mlock); 168 146 switch (mask) { 169 147 case IIO_CHAN_INFO_RAW: 170 - if (axp288_adc_set_ts(info->regmap, AXP288_ADC_TS_PIN_GPADC, 148 + if (axp288_adc_set_ts(info, AXP288_ADC_TS_CURRENT_ON_ONDEMAND, 171 149 chan->address)) { 172 150 dev_err(&indio_dev->dev, "GPADC mode\n"); 173 151 ret = -EINVAL; 174 152 break; 175 153 } 176 154 ret = axp288_adc_read_channel(val, chan->address, info->regmap); 177 - if (axp288_adc_set_ts(info->regmap, AXP288_ADC_TS_PIN_ON, 155 + if (axp288_adc_set_ts(info, AXP288_ADC_TS_CURRENT_ON, 178 156 chan->address)) 179 157 dev_err(&indio_dev->dev, "TS pin restore\n"); 180 158 break; ··· 186 164 return ret; 187 165 } 188 166 189 - static int axp288_adc_set_state(struct regmap *regmap) 167 + static int axp288_adc_initialize(struct axp288_adc_info *info) 190 168 { 191 - /* ADC should be always enabled for internal FG to function */ 192 - if (regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, AXP288_ADC_TS_PIN_ON)) 193 - return -EIO; 169 + int ret, adc_enable_val; 194 170 195 - return regmap_write(regmap, AXP20X_ADC_EN1, AXP288_ADC_EN_MASK); 171 + /* 172 + * Determine if the TS pin is enabled and set the TS current-source 173 + * accordingly. 174 + */ 175 + ret = regmap_read(info->regmap, AXP20X_ADC_EN1, &adc_enable_val); 176 + if (ret) 177 + return ret; 178 + 179 + if (adc_enable_val & AXP288_ADC_TS_ENABLE) { 180 + info->ts_enabled = true; 181 + ret = regmap_update_bits(info->regmap, AXP288_ADC_TS_PIN_CTRL, 182 + AXP288_ADC_TS_CURRENT_ON_OFF_MASK, 183 + AXP288_ADC_TS_CURRENT_ON); 184 + } else { 185 + info->ts_enabled = false; 186 + ret = regmap_update_bits(info->regmap, AXP288_ADC_TS_PIN_CTRL, 187 + AXP288_ADC_TS_CURRENT_ON_OFF_MASK, 188 + AXP288_ADC_TS_CURRENT_OFF); 189 + } 190 + if (ret) 191 + return ret; 192 + 193 + /* Turn on the ADC for all channels except TS, leave TS as is */ 194 + return regmap_update_bits(info->regmap, AXP20X_ADC_EN1, 195 + AXP288_ADC_EN_MASK, AXP288_ADC_EN_MASK); 196 196 } 197 197 198 198 static const struct iio_info axp288_adc_iio_info = { ··· 244 200 * Set ADC to enabled state at all time, including system suspend. 245 201 * otherwise internal fuel gauge functionality may be affected. 246 202 */ 247 - ret = axp288_adc_set_state(axp20x->regmap); 203 + ret = axp288_adc_initialize(info); 248 204 if (ret) { 249 205 dev_err(&pdev->dev, "unable to enable ADC device\n"); 250 206 return ret;
+2 -1
drivers/iio/adc/ti-ads8688.c
··· 41 41 42 42 #define ADS8688_VREF_MV 4096 43 43 #define ADS8688_REALBITS 16 44 + #define ADS8688_MAX_CHANNELS 8 44 45 45 46 /* 46 47 * enum ads8688_range - ADS8688 reference voltage range ··· 386 385 { 387 386 struct iio_poll_func *pf = p; 388 387 struct iio_dev *indio_dev = pf->indio_dev; 389 - u16 buffer[8]; 388 + u16 buffer[ADS8688_MAX_CHANNELS + sizeof(s64)/sizeof(u16)]; 390 389 int i, j = 0; 391 390 392 391 for (i = 0; i < indio_dev->masklength; i++) {
+3 -4
drivers/iio/chemical/atlas-ph-sensor.c
··· 444 444 case IIO_CHAN_INFO_SCALE: 445 445 switch (chan->type) { 446 446 case IIO_TEMP: 447 - *val = 1; /* 0.01 */ 448 - *val2 = 100; 449 - break; 447 + *val = 10; 448 + return IIO_VAL_INT; 450 449 case IIO_PH: 451 450 *val = 1; /* 0.001 */ 452 451 *val2 = 1000; ··· 476 477 int val, int val2, long mask) 477 478 { 478 479 struct atlas_data *data = iio_priv(indio_dev); 479 - __be32 reg = cpu_to_be32(val); 480 + __be32 reg = cpu_to_be32(val / 10); 480 481 481 482 if (val2 != 0 || val < 0 || val > 20000) 482 483 return -EINVAL;
+1 -1
drivers/staging/octeon/ethernet-mdio.c
··· 170 170 return -ENODEV; 171 171 172 172 priv->last_link = 0; 173 - phy_start_aneg(phydev); 173 + phy_start(phydev); 174 174 175 175 return 0; 176 176 no_phy:
+1 -1
tools/iio/iio_generic_buffer.c
··· 330 330 331 331 int main(int argc, char **argv) 332 332 { 333 - unsigned long long num_loops = 2; 333 + long long num_loops = 2; 334 334 unsigned long timedelay = 1000000; 335 335 unsigned long buf_len = 128; 336 336