]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
Merge tag 'iio-fixes-for-4.4a' of ssh://ra.kernel.org/pub/scm/linux/kernel/git/jic23...
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Nov 2015 21:15:50 +0000 (13:15 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Nov 2015 21:15:50 +0000 (13:15 -0800)
Jonathan writes:

First set of IIO fixes for the 4.4 cycle.

This set does not include those for issues introduced during the merge
window.  Fixes of those will follow in a future series.

* ad5064
  - Make sure the local i2c_write returns 0 on success rather than the
    number of bytes transfered.  Otherwise we report an error on all writes.
  - Fix a shift for ad5629 and ad5669 which gives incorrect DAC output on
    these parts.
* ad7793
  - The product ID on the datasheet is wrong.  Fix it in the driver.
* IIO_DUMMY_EVGEN
  - select IRQ_WORK as a dependency.
* lpc32xx
  - make sure clock is prepared before enabling.
* si7020
  - data byte order was reversed. Fix it.
* vf610
  - Internal temperature calculation was wrong if a different
    reference voltage was used.  Now use a linear interpolation
    function to make it work over the full range.
  - Fix a division by zero in the case of a device tree property
    not being present (same issue two fixes).
* xilinx XADC
  - VREFN scale was wrong - fix it.

1  2 
drivers/iio/adc/ad7793.c
drivers/iio/adc/vf610_adc.c
drivers/iio/adc/xilinx-xadc-core.c
drivers/iio/dac/ad5064.c
drivers/iio/humidity/si7020.c
drivers/staging/iio/adc/lpc32xx_adc.c

diff --combined drivers/iio/adc/ad7793.c
index eea0c79111e7c7e2beb6be21cda21d597833e793,710aee8377bbb018009a4803ffcda89bb9bbb1f7..4d960d3b93c0b45c70183ed5f4a218649d0dfb87
  #define AD7795_CH_AIN1M_AIN1M 8 /* AIN1(-) - AIN1(-) */
  
  /* ID Register Bit Designations (AD7793_REG_ID) */
- #define AD7785_ID             0xB
+ #define AD7785_ID             0x3
  #define AD7792_ID             0xA
  #define AD7793_ID             0xB
  #define AD7794_ID             0xF
@@@ -852,6 -852,7 +852,6 @@@ MODULE_DEVICE_TABLE(spi, ad7793_id)
  static struct spi_driver ad7793_driver = {
        .driver = {
                .name   = "ad7793",
 -              .owner  = THIS_MODULE,
        },
        .probe          = ad7793_probe,
        .remove         = ad7793_remove,
index 599cde3d03a117358f86defec5dcd10ac25b1ed7,d937df4f7f2bbde53543a73ee1defe0a35673e1f..b10f629cc44b5e8aa27b9bde4a5c39fbc3694a5e
  #include <linux/err.h>
  
  #include <linux/iio/iio.h>
 +#include <linux/iio/buffer.h>
  #include <linux/iio/sysfs.h>
 -#include <linux/iio/driver.h>
 +#include <linux/iio/trigger.h>
 +#include <linux/iio/trigger_consumer.h>
 +#include <linux/iio/triggered_buffer.h>
  
  /* This will be the driver name the kernel reports */
  #define DRIVER_NAME "vf610-adc"
  
  #define DEFAULT_SAMPLE_TIME           1000
  
+ /* V at 25°C of 696 mV */
+ #define VF610_VTEMP25_3V0             950
+ /* V at 25°C of 699 mV */
+ #define VF610_VTEMP25_3V3             867
+ /* Typical sensor slope coefficient at all temperatures */
+ #define VF610_TEMP_SLOPE_COEFF                1840
  enum clk_sel {
        VF610_ADCIOC_BUSCLK_SET,
        VF610_ADCIOC_ALTCLK_SET,
@@@ -173,7 -177,6 +180,7 @@@ struct vf610_adc 
        u32 sample_freq_avail[5];
  
        struct completion completion;
 +      u16 buffer[8];
  };
  
  static const u32 vf610_hw_avgs[] = { 1, 4, 8, 16, 32 };
@@@ -197,6 -200,8 +204,8 @@@ static inline void vf610_adc_calculate_
                adc_feature->clk_div = 8;
        }
  
+       adck_rate = ipg_rate / adc_feature->clk_div;
        /*
         * Determine the long sample time adder value to be used based
         * on the default minimum sample time provided.
         * BCT (Base Conversion Time): fixed to 25 ADCK cycles for 12 bit mode
         * LSTAdder(Long Sample Time): 3, 5, 7, 9, 13, 17, 21, 25 ADCK cycles
         */
-       adck_rate = ipg_rate / info->adc_feature.clk_div;
        for (i = 0; i < ARRAY_SIZE(vf610_hw_avgs); i++)
                info->sample_freq_avail[i] =
                        adck_rate / (6 + vf610_hw_avgs[i] *
@@@ -509,24 -513,12 +517,24 @@@ static const struct iio_chan_spec_ext_i
        .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) |  \
                                BIT(IIO_CHAN_INFO_SAMP_FREQ),   \
        .ext_info = vf610_ext_info,                             \
 +      .scan_index = (_idx),                   \
 +      .scan_type = {                                  \
 +              .sign = 'u',                            \
 +              .realbits = 12,                         \
 +              .storagebits = 16,                      \
 +      },                                              \
  }
  
  #define VF610_ADC_TEMPERATURE_CHAN(_idx, _chan_type) {        \
        .type = (_chan_type),   \
        .channel = (_idx),              \
        .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),     \
 +      .scan_index = (_idx),                                   \
 +      .scan_type = {                                          \
 +              .sign = 'u',                                    \
 +              .realbits = 12,                                 \
 +              .storagebits = 16,                              \
 +      },                                                      \
  }
  
  static const struct iio_chan_spec vf610_adc_iio_channels[] = {
        VF610_ADC_CHAN(14, IIO_VOLTAGE),
        VF610_ADC_CHAN(15, IIO_VOLTAGE),
        VF610_ADC_TEMPERATURE_CHAN(26, IIO_TEMP),
 +      IIO_CHAN_SOFT_TIMESTAMP(32),
        /* sentinel */
  };
  
@@@ -576,20 -567,13 +584,20 @@@ static int vf610_adc_read_data(struct v
  
  static irqreturn_t vf610_adc_isr(int irq, void *dev_id)
  {
 -      struct vf610_adc *info = (struct vf610_adc *)dev_id;
 +      struct iio_dev *indio_dev = (struct iio_dev *)dev_id;
 +      struct vf610_adc *info = iio_priv(indio_dev);
        int coco;
  
        coco = readl(info->regs + VF610_REG_ADC_HS);
        if (coco & VF610_ADC_HS_COCO0) {
                info->value = vf610_adc_read_data(info);
 -              complete(&info->completion);
 +              if (iio_buffer_enabled(indio_dev)) {
 +                      info->buffer[0] = info->value;
 +                      iio_push_to_buffers_with_timestamp(indio_dev,
 +                                      info->buffer, iio_get_time_ns());
 +                      iio_trigger_notify_done(indio_dev->trig);
 +              } else
 +                      complete(&info->completion);
        }
  
        return IRQ_HANDLED;
@@@ -637,12 -621,8 +645,12 @@@ static int vf610_read_raw(struct iio_de
        case IIO_CHAN_INFO_RAW:
        case IIO_CHAN_INFO_PROCESSED:
                mutex_lock(&indio_dev->mlock);
 -              reinit_completion(&info->completion);
 +              if (iio_buffer_enabled(indio_dev)) {
 +                      mutex_unlock(&indio_dev->mlock);
 +                      return -EBUSY;
 +              }
  
 +              reinit_completion(&info->completion);
                hc_cfg = VF610_ADC_ADCHC(chan->channel);
                hc_cfg |= VF610_ADC_AIEN;
                writel(hc_cfg, info->regs + VF610_REG_ADC_HC0);
                        break;
                case IIO_TEMP:
                        /*
-                       * Calculate in degree Celsius times 1000
-                       * Using sensor slope of 1.84 mV/°C and
-                       * V at 25°C of 696 mV
-                       */
-                       *val = 25000 - ((int)info->value - 864) * 1000000 / 1840;
+                        * Calculate in degree Celsius times 1000
+                        * Using the typical sensor slope of 1.84 mV/°C
+                        * and VREFH_ADC at 3.3V, V at 25°C of 699 mV
+                        */
+                       *val = 25000 - ((int)info->value - VF610_VTEMP25_3V3) *
+                                       1000000 / VF610_TEMP_SLOPE_COEFF;
                        break;
                default:
                        mutex_unlock(&indio_dev->mlock);
@@@ -722,56 -704,6 +732,56 @@@ static int vf610_write_raw(struct iio_d
        return -EINVAL;
  }
  
 +static int vf610_adc_buffer_postenable(struct iio_dev *indio_dev)
 +{
 +      struct vf610_adc *info = iio_priv(indio_dev);
 +      unsigned int channel;
 +      int ret;
 +      int val;
 +
 +      ret = iio_triggered_buffer_postenable(indio_dev);
 +      if (ret)
 +              return ret;
 +
 +      val = readl(info->regs + VF610_REG_ADC_GC);
 +      val |= VF610_ADC_ADCON;
 +      writel(val, info->regs + VF610_REG_ADC_GC);
 +
 +      channel = find_first_bit(indio_dev->active_scan_mask,
 +                                              indio_dev->masklength);
 +
 +      val = VF610_ADC_ADCHC(channel);
 +      val |= VF610_ADC_AIEN;
 +
 +      writel(val, info->regs + VF610_REG_ADC_HC0);
 +
 +      return 0;
 +}
 +
 +static int vf610_adc_buffer_predisable(struct iio_dev *indio_dev)
 +{
 +      struct vf610_adc *info = iio_priv(indio_dev);
 +      unsigned int hc_cfg = 0;
 +      int val;
 +
 +      val = readl(info->regs + VF610_REG_ADC_GC);
 +      val &= ~VF610_ADC_ADCON;
 +      writel(val, info->regs + VF610_REG_ADC_GC);
 +
 +      hc_cfg |= VF610_ADC_CONV_DISABLE;
 +      hc_cfg &= ~VF610_ADC_AIEN;
 +
 +      writel(hc_cfg, info->regs + VF610_REG_ADC_HC0);
 +
 +      return iio_triggered_buffer_predisable(indio_dev);
 +}
 +
 +static const struct iio_buffer_setup_ops iio_triggered_buffer_setup_ops = {
 +      .postenable = &vf610_adc_buffer_postenable,
 +      .predisable = &vf610_adc_buffer_predisable,
 +      .validate_scan_mask = &iio_validate_scan_mask_onehot,
 +};
 +
  static int vf610_adc_reg_access(struct iio_dev *indio_dev,
                        unsigned reg, unsigned writeval,
                        unsigned *readval)
@@@ -831,7 -763,7 +841,7 @@@ static int vf610_adc_probe(struct platf
  
        ret = devm_request_irq(info->dev, irq,
                                vf610_adc_isr, 0,
 -                              dev_name(&pdev->dev), info);
 +                              dev_name(&pdev->dev), indio_dev);
        if (ret < 0) {
                dev_err(&pdev->dev, "failed requesting irq, irq = %d\n", irq);
                return ret;
        vf610_adc_cfg_init(info);
        vf610_adc_hw_init(info);
  
 +      ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
 +                                      NULL, &iio_triggered_buffer_setup_ops);
 +      if (ret < 0) {
 +              dev_err(&pdev->dev, "Couldn't initialise the buffer\n");
 +              goto error_iio_device_register;
 +      }
 +
        ret = iio_device_register(indio_dev);
        if (ret) {
                dev_err(&pdev->dev, "Couldn't register the device.\n");
 -              goto error_iio_device_register;
 +              goto error_adc_buffer_init;
        }
  
        return 0;
  
 -
 +error_adc_buffer_init:
 +      iio_triggered_buffer_cleanup(indio_dev);
  error_iio_device_register:
        clk_disable_unprepare(info->clk);
  error_adc_clk_enable:
@@@ -915,7 -839,6 +925,7 @@@ static int vf610_adc_remove(struct plat
        struct vf610_adc *info = iio_priv(indio_dev);
  
        iio_device_unregister(indio_dev);
 +      iio_triggered_buffer_cleanup(indio_dev);
        regulator_disable(info->vref);
        clk_disable_unprepare(info->clk);
  
index 0370624a35db723a6b6089c99398cca36fc10590,95c0b3d9890cd8e0437ce1b24fdc075146000e35..02e636a1c49a7a17bbb2cd19356301c41781710f
@@@ -273,13 -273,33 +273,13 @@@ static void xadc_zynq_unmask_worker(str
                schedule_delayed_work(&xadc->zynq_unmask_work,
                                msecs_to_jiffies(XADC_ZYNQ_UNMASK_TIMEOUT));
        }
 -}
 -
 -static irqreturn_t xadc_zynq_threaded_interrupt_handler(int irq, void *devid)
 -{
 -      struct iio_dev *indio_dev = devid;
 -      struct xadc *xadc = iio_priv(indio_dev);
 -      unsigned int alarm;
 -
 -      spin_lock_irq(&xadc->lock);
 -      alarm = xadc->zynq_alarm;
 -      xadc->zynq_alarm = 0;
 -      spin_unlock_irq(&xadc->lock);
 -
 -      xadc_handle_events(indio_dev, xadc_zynq_transform_alarm(alarm));
  
 -      /* unmask the required interrupts in timer. */
 -      schedule_delayed_work(&xadc->zynq_unmask_work,
 -                      msecs_to_jiffies(XADC_ZYNQ_UNMASK_TIMEOUT));
 -
 -      return IRQ_HANDLED;
  }
  
  static irqreturn_t xadc_zynq_interrupt_handler(int irq, void *devid)
  {
        struct iio_dev *indio_dev = devid;
        struct xadc *xadc = iio_priv(indio_dev);
 -      irqreturn_t ret = IRQ_HANDLED;
        uint32_t status;
  
        xadc_read_reg(xadc, XADC_ZYNQ_REG_INTSTS, &status);
  
        status &= XADC_ZYNQ_INT_ALARM_MASK;
        if (status) {
 -              xadc->zynq_alarm |= status;
                xadc->zynq_masked_alarm |= status;
                /*
                 * mask the current event interrupt,
                 * unmask it when the interrupt is no more active.
                 */
                xadc_zynq_update_intmsk(xadc, 0, 0);
 -              ret = IRQ_WAKE_THREAD;
 +
 +              xadc_handle_events(indio_dev,
 +                              xadc_zynq_transform_alarm(status));
 +
 +              /* unmask the required interrupts in timer. */
 +              schedule_delayed_work(&xadc->zynq_unmask_work,
 +                              msecs_to_jiffies(XADC_ZYNQ_UNMASK_TIMEOUT));
        }
        spin_unlock(&xadc->lock);
  
 -      return ret;
 +      return IRQ_HANDLED;
  }
  
  #define XADC_ZYNQ_TCK_RATE_MAX 50000000
@@@ -422,6 -437,7 +422,6 @@@ static const struct xadc_ops xadc_zynq_
        .setup = xadc_zynq_setup,
        .get_dclk_rate = xadc_zynq_get_dclk_rate,
        .interrupt_handler = xadc_zynq_interrupt_handler,
 -      .threaded_interrupt_handler = xadc_zynq_threaded_interrupt_handler,
        .update_alarm = xadc_zynq_update_alarm,
  };
  
@@@ -841,6 -857,7 +841,7 @@@ static int xadc_read_raw(struct iio_de
                        case XADC_REG_VCCINT:
                        case XADC_REG_VCCAUX:
                        case XADC_REG_VREFP:
+                       case XADC_REG_VREFN:
                        case XADC_REG_VCCBRAM:
                        case XADC_REG_VCCPINT:
                        case XADC_REG_VCCPAUX:
@@@ -1209,8 -1226,9 +1210,8 @@@ static int xadc_probe(struct platform_d
        if (ret)
                goto err_free_samplerate_trigger;
  
 -      ret = request_threaded_irq(irq, xadc->ops->interrupt_handler,
 -                              xadc->ops->threaded_interrupt_handler,
 -                              0, dev_name(&pdev->dev), indio_dev);
 +      ret = request_irq(irq, xadc->ops->interrupt_handler, 0,
 +                      dev_name(&pdev->dev), indio_dev);
        if (ret)
                goto err_clk_disable_unprepare;
  
diff --combined drivers/iio/dac/ad5064.c
index 9e4d2c18b5541b2043e244229aeb393e79e737d4,978f130ca6781f7987ebe4b8eed59b2efac6302d..81ca0081a019b355ce58ce26bf9370c84d48fb7b
@@@ -113,12 -113,16 +113,16 @@@ enum ad5064_type 
        ID_AD5065,
        ID_AD5628_1,
        ID_AD5628_2,
+       ID_AD5629_1,
+       ID_AD5629_2,
        ID_AD5648_1,
        ID_AD5648_2,
        ID_AD5666_1,
        ID_AD5666_2,
        ID_AD5668_1,
        ID_AD5668_2,
+       ID_AD5669_1,
+       ID_AD5669_2,
  };
  
  static int ad5064_write(struct ad5064_state *st, unsigned int cmd,
@@@ -291,7 -295,7 +295,7 @@@ static const struct iio_chan_spec_ext_i
        { },
  };
  
- #define AD5064_CHANNEL(chan, addr, bits) {                    \
+ #define AD5064_CHANNEL(chan, addr, bits, _shift) {            \
        .type = IIO_VOLTAGE,                                    \
        .indexed = 1,                                           \
        .output = 1,                                            \
                .sign = 'u',                                    \
                .realbits = (bits),                             \
                .storagebits = 16,                              \
-               .shift = 20 - bits,                             \
+               .shift = (_shift),                              \
        },                                                      \
        .ext_info = ad5064_ext_info,                            \
  }
  
- #define DECLARE_AD5064_CHANNELS(name, bits) \
+ #define DECLARE_AD5064_CHANNELS(name, bits, shift) \
  const struct iio_chan_spec name[] = { \
-       AD5064_CHANNEL(0, 0, bits), \
-       AD5064_CHANNEL(1, 1, bits), \
-       AD5064_CHANNEL(2, 2, bits), \
-       AD5064_CHANNEL(3, 3, bits), \
-       AD5064_CHANNEL(4, 4, bits), \
-       AD5064_CHANNEL(5, 5, bits), \
-       AD5064_CHANNEL(6, 6, bits), \
-       AD5064_CHANNEL(7, 7, bits), \
+       AD5064_CHANNEL(0, 0, bits, shift), \
+       AD5064_CHANNEL(1, 1, bits, shift), \
+       AD5064_CHANNEL(2, 2, bits, shift), \
+       AD5064_CHANNEL(3, 3, bits, shift), \
+       AD5064_CHANNEL(4, 4, bits, shift), \
+       AD5064_CHANNEL(5, 5, bits, shift), \
+       AD5064_CHANNEL(6, 6, bits, shift), \
+       AD5064_CHANNEL(7, 7, bits, shift), \
  }
  
- #define DECLARE_AD5065_CHANNELS(name, bits) \
+ #define DECLARE_AD5065_CHANNELS(name, bits, shift) \
  const struct iio_chan_spec name[] = { \
-       AD5064_CHANNEL(0, 0, bits), \
-       AD5064_CHANNEL(1, 3, bits), \
+       AD5064_CHANNEL(0, 0, bits, shift), \
+       AD5064_CHANNEL(1, 3, bits, shift), \
  }
  
- static DECLARE_AD5064_CHANNELS(ad5024_channels, 12);
- static DECLARE_AD5064_CHANNELS(ad5044_channels, 14);
- static DECLARE_AD5064_CHANNELS(ad5064_channels, 16);
+ static DECLARE_AD5064_CHANNELS(ad5024_channels, 12, 8);
+ static DECLARE_AD5064_CHANNELS(ad5044_channels, 14, 6);
+ static DECLARE_AD5064_CHANNELS(ad5064_channels, 16, 4);
  
- static DECLARE_AD5065_CHANNELS(ad5025_channels, 12);
- static DECLARE_AD5065_CHANNELS(ad5045_channels, 14);
- static DECLARE_AD5065_CHANNELS(ad5065_channels, 16);
+ static DECLARE_AD5065_CHANNELS(ad5025_channels, 12, 8);
+ static DECLARE_AD5065_CHANNELS(ad5045_channels, 14, 6);
+ static DECLARE_AD5065_CHANNELS(ad5065_channels, 16, 4);
+ static DECLARE_AD5064_CHANNELS(ad5629_channels, 12, 4);
+ static DECLARE_AD5064_CHANNELS(ad5669_channels, 16, 0);
  
  static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
        [ID_AD5024] = {
                .channels = ad5024_channels,
                .num_channels = 8,
        },
+       [ID_AD5629_1] = {
+               .shared_vref = true,
+               .internal_vref = 2500000,
+               .channels = ad5629_channels,
+               .num_channels = 8,
+       },
+       [ID_AD5629_2] = {
+               .shared_vref = true,
+               .internal_vref = 5000000,
+               .channels = ad5629_channels,
+               .num_channels = 8,
+       },
        [ID_AD5648_1] = {
                .shared_vref = true,
                .internal_vref = 2500000,
                .channels = ad5064_channels,
                .num_channels = 8,
        },
+       [ID_AD5669_1] = {
+               .shared_vref = true,
+               .internal_vref = 2500000,
+               .channels = ad5669_channels,
+               .num_channels = 8,
+       },
+       [ID_AD5669_2] = {
+               .shared_vref = true,
+               .internal_vref = 5000000,
+               .channels = ad5669_channels,
+               .num_channels = 8,
+       },
  };
  
  static inline unsigned int ad5064_num_vref(struct ad5064_state *st)
@@@ -568,6 -599,7 +599,6 @@@ MODULE_DEVICE_TABLE(spi, ad5064_spi_ids
  static struct spi_driver ad5064_spi_driver = {
        .driver = {
                   .name = "ad5064",
 -                 .owner = THIS_MODULE,
        },
        .probe = ad5064_spi_probe,
        .remove = ad5064_spi_remove,
@@@ -597,10 -629,16 +628,16 @@@ static int ad5064_i2c_write(struct ad50
        unsigned int addr, unsigned int val)
  {
        struct i2c_client *i2c = to_i2c_client(st->dev);
+       int ret;
  
        st->data.i2c[0] = (cmd << 4) | addr;
        put_unaligned_be16(val, &st->data.i2c[1]);
-       return i2c_master_send(i2c, st->data.i2c, 3);
+       ret = i2c_master_send(i2c, st->data.i2c, 3);
+       if (ret < 0)
+               return ret;
+       return 0;
  }
  
  static int ad5064_i2c_probe(struct i2c_client *i2c,
@@@ -616,12 -654,12 +653,12 @@@ static int ad5064_i2c_remove(struct i2c
  }
  
  static const struct i2c_device_id ad5064_i2c_ids[] = {
-       {"ad5629-1", ID_AD5628_1},
-       {"ad5629-2", ID_AD5628_2},
-       {"ad5629-3", ID_AD5628_2}, /* similar enough to ad5629-2 */
-       {"ad5669-1", ID_AD5668_1},
-       {"ad5669-2", ID_AD5668_2},
-       {"ad5669-3", ID_AD5668_2}, /* similar enough to ad5669-2 */
+       {"ad5629-1", ID_AD5629_1},
+       {"ad5629-2", ID_AD5629_2},
+       {"ad5629-3", ID_AD5629_2}, /* similar enough to ad5629-2 */
+       {"ad5669-1", ID_AD5669_1},
+       {"ad5669-2", ID_AD5669_2},
+       {"ad5669-3", ID_AD5669_2}, /* similar enough to ad5669-2 */
        {}
  };
  MODULE_DEVICE_TABLE(i2c, ad5064_i2c_ids);
index 12128d1ca570fc4dd93461219628b6ab6461d95d,1b6935d991006724dd78acc80e7f3f4ec23de799..71991b5c0658d05fe728f797573b08843e51d9ad
@@@ -50,19 -50,15 +50,19 @@@ static int si7020_read_raw(struct iio_d
  
        switch (mask) {
        case IIO_CHAN_INFO_RAW:
-               ret = i2c_smbus_read_word_data(*client,
-                                              chan->type == IIO_TEMP ?
-                                              SI7020CMD_TEMP_HOLD :
-                                              SI7020CMD_RH_HOLD);
+               ret = i2c_smbus_read_word_swapped(*client,
+                                                 chan->type == IIO_TEMP ?
+                                                 SI7020CMD_TEMP_HOLD :
+                                                 SI7020CMD_RH_HOLD);
                if (ret < 0)
                        return ret;
                *val = ret >> 2;
 +              /*
 +               * Humidity values can slightly exceed the 0-100%RH
 +               * range and should be corrected by software
 +               */
                if (chan->type == IIO_HUMIDITYRELATIVE)
 -                      *val &= GENMASK(11, 0);
 +                      *val = clamp_val(*val, 786, 13893);
                return IIO_VAL_INT;
        case IIO_CHAN_INFO_SCALE:
                if (chan->type == IIO_TEMP)
index d11c54b721860cccb0c6db82a6d9353787560896,ef6d0b0ccf555fb1faebeb6b22744e1f3e3baf36..b51f237cd817c9dc8fe668bb61ae708577bf8287
@@@ -67,24 -67,24 +67,24 @@@ struct lpc32xx_adc_info 
  };
  
  static int lpc32xx_read_raw(struct iio_dev *indio_dev,
 -                              struct iio_chan_spec const *chan,
 -                              int *val,
 -                              int *val2,
 -                              long mask)
 +                          struct iio_chan_spec const *chan,
 +                          int *val,
 +                          int *val2,
 +                          long mask)
  {
        struct lpc32xx_adc_info *info = iio_priv(indio_dev);
  
        if (mask == IIO_CHAN_INFO_RAW) {
                mutex_lock(&indio_dev->mlock);
-               clk_enable(info->clk);
+               clk_prepare_enable(info->clk);
                /* Measurement setup */
                __raw_writel(AD_INTERNAL | (chan->address) | AD_REFp | AD_REFm,
 -                      LPC32XX_ADC_SELECT(info->adc_base));
 +                           LPC32XX_ADC_SELECT(info->adc_base));
                /* Trigger conversion */
                __raw_writel(AD_PDN_CTRL | AD_STROBE,
 -                      LPC32XX_ADC_CTRL(info->adc_base));
 +                           LPC32XX_ADC_CTRL(info->adc_base));
                wait_for_completion(&info->completion); /* set by ISR */
-               clk_disable(info->clk);
+               clk_disable_unprepare(info->clk);
                *val = info->value;
                mutex_unlock(&indio_dev->mlock);
  
@@@ -137,7 -137,7 +137,7 @@@ static int lpc32xx_adc_probe(struct pla
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (!res) {
                dev_err(&pdev->dev, "failed to get platform I/O memory\n");
 -              return -EBUSY;
 +              return -ENXIO;
        }
  
        iodev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
        irq = platform_get_irq(pdev, 0);
        if (irq <= 0) {
                dev_err(&pdev->dev, "failed getting interrupt resource\n");
 -              return -EINVAL;
 +              return -ENXIO;
        }
  
        retval = devm_request_irq(&pdev->dev, irq, lpc32xx_adc_isr, 0,
 -                                                              MOD_NAME, info);
 +                                MOD_NAME, info);
        if (retval < 0) {
                dev_err(&pdev->dev, "failed requesting interrupt\n");
                return retval;