Third set of fixes for IIO in the 4.7 cycle.

A couple of really old bugs and the results of Mark taking a close look at
 some nasty regulator handling.
 
 * ad7266
   - Fix broken regulator handling that won't play well with dummy regulators.
   - Correctly handle and optional regulator.
   - Fix probe deferral for the vref regulator.
 * kxsd9
   - Fix a wrong error check that leads to an inability to write or read
   the scale.
 * sca3000
   - Fix a wrong error check that leads to an inability to read back the
   sampling frequency.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJXdAd0AAoJEFSFNJnE9BaIUIcP/0hKQM5Pid/MZacJHaUS9dQV
 pQX22hJoPiT9mcl89BmT9k6Fw6n0EY8Yk6aKo3i90QZ5ZTbeXDfagl5qi1HxxN3g
 Rw6kTK8M34uTTwNzavT06hMUfFJh5enOt7FOnQK7PYO1yuQLpYRU+hbAt0OkzAw4
 0zKK00cOJDkhKj05IpBdBMokzt9iOqmaEDxgyaWB5KTBn5GABo1JX3GWq7j9T2nD
 Bj67xAo7ul/iiuckmpW1wnuZkV2SIdURa556t40gWht99CT/YI1VMKRJeVdKEdT2
 tpTNm2pM49z12sB9wEoCfYO46U79XLsdk7tAne5q3QhyoLfVzORRp7hvNtSZTfRr
 0TNdPM7K7B3v6a7wIqszDeKMWnZg+5Z5RrmRrchgfx19SXh5jOmmKtq2fiPe/pP1
 RwtDkfqM7ad+EzC2m+GgGIVR2DuSuSJjkv/KUYUEDv81YvBMy55dJC0Tmldqnf+W
 tSOh25BkaadOytjlwryV3XlCfL4EPNVapo1cyjyn771VGLrC1Z/rgDPysh68I4K4
 38VM0VUrJ/a4XosXOzEhbSxHKXzeaquP3Zh2At7Lafb/KzsmBCoGgPuZYW33OFTF
 dHCIfWOGuhe05o/ZRLFrRAOENmVM0fVaJB4QeEqNk5n2wG4XrlY53tomT+sFRZ2o
 YN4yCLvAb82LZdLBC/MS
 =4KQw
 -----END PGP SIGNATURE-----

Merge tag 'iio-fixes-for-4.7c' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus

Jonathan writes:

Third set of fixes for IIO in the 4.7 cycle.

A couple of really old bugs and the results of Mark taking a close look at
some nasty regulator handling.

* ad7266
  - Fix broken regulator handling that won't play well with dummy regulators.
  - Correctly handle and optional regulator.
  - Fix probe deferral for the vref regulator.
* kxsd9
  - Fix a wrong error check that leads to an inability to write or read
  the scale.
* sca3000
  - Fix a wrong error check that leads to an inability to read back the
  sampling frequency.
This commit is contained in:
Greg Kroah-Hartman 2016-06-29 13:53:31 -07:00
commit d839722131
3 changed files with 8 additions and 5 deletions

View File

@ -81,7 +81,7 @@ static int kxsd9_write_scale(struct iio_dev *indio_dev, int micro)
mutex_lock(&st->buf_lock);
ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C));
if (ret)
if (ret < 0)
goto error_ret;
st->tx[0] = KXSD9_WRITE(KXSD9_REG_CTRL_C);
st->tx[1] = (ret & ~KXSD9_FS_MASK) | i;
@ -163,7 +163,7 @@ static int kxsd9_read_raw(struct iio_dev *indio_dev,
break;
case IIO_CHAN_INFO_SCALE:
ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C));
if (ret)
if (ret < 0)
goto error_ret;
*val2 = kxsd9_micro_scales[ret & KXSD9_FS_MASK];
ret = IIO_VAL_INT_PLUS_MICRO;

View File

@ -396,8 +396,8 @@ static int ad7266_probe(struct spi_device *spi)
st = iio_priv(indio_dev);
st->reg = devm_regulator_get(&spi->dev, "vref");
if (!IS_ERR_OR_NULL(st->reg)) {
st->reg = devm_regulator_get_optional(&spi->dev, "vref");
if (!IS_ERR(st->reg)) {
ret = regulator_enable(st->reg);
if (ret)
return ret;
@ -408,6 +408,9 @@ static int ad7266_probe(struct spi_device *spi)
st->vref_mv = ret / 1000;
} else {
/* Any other error indicates that the regulator does exist */
if (PTR_ERR(st->reg) != -ENODEV)
return PTR_ERR(st->reg);
/* Use internal reference */
st->vref_mv = 2500;
}

View File

@ -594,7 +594,7 @@ static ssize_t sca3000_read_frequency(struct device *dev,
goto error_ret_mut;
ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_OUT_CTRL);
mutex_unlock(&st->lock);
if (ret)
if (ret < 0)
goto error_ret;
val = ret;
if (base_freq > 0)