Merge tag 'iio-fixes-for-3.18a' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Oct 2014 02:09:39 +0000 (10:09 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Oct 2014 02:09:39 +0000 (10:09 +0800)
Jonathan writes:

First round of IIO fixes for the 3.18 cycle.

* ad5933 - fix a null pointer dereference due to an old change that prevents
  different channels being registered for the buffer and used for sysfs
  interfaces.
* ad5933 - Drop a bonus _raw from attribute names.
* st-sensors - Makes sure the correct number of elements are copied when
  filling a local buffer copy.
* mxs-lradc - Disable clocks in a failure path during probe so they aren't
  left running.

1  2 
drivers/staging/iio/adc/mxs-lradc.c
drivers/staging/iio/impedance-analyzer/ad5933.c

@@@ -365,49 -365,56 +365,49 @@@ static u32 mxs_lradc_plate_mask(struct 
  {
        if (lradc->soc == IMX23_LRADC)
                return LRADC_CTRL0_MX23_PLATE_MASK;
 -      else
 -              return LRADC_CTRL0_MX28_PLATE_MASK;
 +      return LRADC_CTRL0_MX28_PLATE_MASK;
  }
  
  static u32 mxs_lradc_irq_en_mask(struct mxs_lradc *lradc)
  {
        if (lradc->soc == IMX23_LRADC)
                return LRADC_CTRL1_MX23_LRADC_IRQ_EN_MASK;
 -      else
 -              return LRADC_CTRL1_MX28_LRADC_IRQ_EN_MASK;
 +      return LRADC_CTRL1_MX28_LRADC_IRQ_EN_MASK;
  }
  
  static u32 mxs_lradc_irq_mask(struct mxs_lradc *lradc)
  {
        if (lradc->soc == IMX23_LRADC)
                return LRADC_CTRL1_MX23_LRADC_IRQ_MASK;
 -      else
 -              return LRADC_CTRL1_MX28_LRADC_IRQ_MASK;
 +      return LRADC_CTRL1_MX28_LRADC_IRQ_MASK;
  }
  
  static u32 mxs_lradc_touch_detect_bit(struct mxs_lradc *lradc)
  {
        if (lradc->soc == IMX23_LRADC)
                return LRADC_CTRL0_MX23_TOUCH_DETECT_ENABLE;
 -      else
 -              return LRADC_CTRL0_MX28_TOUCH_DETECT_ENABLE;
 +      return LRADC_CTRL0_MX28_TOUCH_DETECT_ENABLE;
  }
  
  static u32 mxs_lradc_drive_x_plate(struct mxs_lradc *lradc)
  {
        if (lradc->soc == IMX23_LRADC)
                return LRADC_CTRL0_MX23_XP | LRADC_CTRL0_MX23_XM;
 -      else
 -              return LRADC_CTRL0_MX28_XPPSW | LRADC_CTRL0_MX28_XNNSW;
 +      return LRADC_CTRL0_MX28_XPPSW | LRADC_CTRL0_MX28_XNNSW;
  }
  
  static u32 mxs_lradc_drive_y_plate(struct mxs_lradc *lradc)
  {
        if (lradc->soc == IMX23_LRADC)
                return LRADC_CTRL0_MX23_YP | LRADC_CTRL0_MX23_YM;
 -      else
 -              return LRADC_CTRL0_MX28_YPPSW | LRADC_CTRL0_MX28_YNNSW;
 +      return LRADC_CTRL0_MX28_YPPSW | LRADC_CTRL0_MX28_YNNSW;
  }
  
  static u32 mxs_lradc_drive_pressure(struct mxs_lradc *lradc)
  {
        if (lradc->soc == IMX23_LRADC)
                return LRADC_CTRL0_MX23_YP | LRADC_CTRL0_MX23_XM;
 -      else
 -              return LRADC_CTRL0_MX28_YPPSW | LRADC_CTRL0_MX28_XNNSW;
 +      return LRADC_CTRL0_MX28_YPPSW | LRADC_CTRL0_MX28_XNNSW;
  }
  
  static bool mxs_lradc_check_touch_event(struct mxs_lradc *lradc)
@@@ -1273,7 -1280,7 +1273,7 @@@ static int mxs_lradc_buffer_preenable(s
        if (!ret)
                return -EBUSY;
  
 -      lradc->buffer = kmalloc(len * sizeof(*lradc->buffer), GFP_KERNEL);
 +      lradc->buffer = kmalloc_array(len, sizeof(*lradc->buffer), GFP_KERNEL);
        if (!lradc->buffer) {
                ret = -ENOMEM;
                goto err_mem;
@@@ -1420,7 -1427,6 +1420,7 @@@ static int mxs_lradc_hw_init(struct mxs
                (LRADC_DELAY_TIMER_PER << LRADC_DELAY_DELAY_OFFSET);
  
        int ret = stmp_reset_block(lradc->base);
 +
        if (ret)
                return ret;
  
@@@ -1559,14 -1565,16 +1559,16 @@@ static int mxs_lradc_probe(struct platf
        /* Grab all IRQ sources */
        for (i = 0; i < of_cfg->irq_count; i++) {
                lradc->irq[i] = platform_get_irq(pdev, i);
-               if (lradc->irq[i] < 0)
-                       return lradc->irq[i];
+               if (lradc->irq[i] < 0) {
+                       ret = lradc->irq[i];
+                       goto err_clk;
+               }
  
                ret = devm_request_irq(dev, lradc->irq[i],
                                        mxs_lradc_handle_irq, 0,
                                        of_cfg->irq_name[i], iio);
                if (ret)
-                       return ret;
+                       goto err_clk;
        }
  
        lradc->vref_mv = of_cfg->vref_mv;
                                &mxs_lradc_trigger_handler,
                                &mxs_lradc_buffer_ops);
        if (ret)
-               return ret;
+               goto err_clk;
  
        ret = mxs_lradc_trigger_init(iio);
        if (ret)
@@@ -1643,6 -1651,8 +1645,8 @@@ err_dev
        mxs_lradc_trigger_remove(iio);
  err_trig:
        iio_triggered_buffer_cleanup(iio);
+ err_clk:
+       clk_disable_unprepare(lradc->clk);
        return ret;
  }
  
@@@ -115,6 -115,7 +115,7 @@@ static const struct iio_chan_spec ad593
                .channel = 0,
                .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
                .address = AD5933_REG_TEMP_DATA,
+               .scan_index = -1,
                .scan_type = {
                        .sign = 's',
                        .realbits = 14,
                .type = IIO_VOLTAGE,
                .indexed = 1,
                .channel = 0,
-               .extend_name = "real_raw",
-               .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
-               BIT(IIO_CHAN_INFO_SCALE),
+               .extend_name = "real",
                .address = AD5933_REG_REAL_DATA,
                .scan_index = 0,
                .scan_type = {
                .type = IIO_VOLTAGE,
                .indexed = 1,
                .channel = 0,
-               .extend_name = "imag_raw",
-               .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
-               BIT(IIO_CHAN_INFO_SCALE),
+               .extend_name = "imag",
                .address = AD5933_REG_IMAG_DATA,
                .scan_index = 1,
                .scan_type = {
@@@ -193,7 -190,6 +190,7 @@@ static int ad5933_cmd(struct ad5933_sta
  static int ad5933_reset(struct ad5933_state *st)
  {
        unsigned char dat = st->ctrl_lb | AD5933_CTRL_RESET;
 +
        return ad5933_i2c_write(st->client,
                        AD5933_REG_CONTROL_LB, 1, &dat);
  }
@@@ -221,7 -217,7 +218,7 @@@ static int ad5933_set_freq(struct ad593
  {
        unsigned long long freqreg;
        union {
 -              u32 d32;
 +              __be32 d32;
                u8 d8[4];
        } dat;
  
  
  static int ad5933_setup(struct ad5933_state *st)
  {
 -      unsigned short dat;
 +      __be16 dat;
        int ret;
  
        ret = ad5933_reset(st);
@@@ -298,7 -294,7 +295,7 @@@ static ssize_t ad5933_show_frequency(st
        int ret;
        unsigned long long freqreg;
        union {
 -              u32 d32;
 +              __be32 d32;
                u8 d8[4];
        } dat;
  
@@@ -403,7 -399,7 +400,7 @@@ static ssize_t ad5933_store(struct devi
        struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
        u16 val;
        int i, ret = 0;
 -      unsigned short dat;
 +      __be16 dat;
  
        if (this_attr->address != AD5933_IN_PGA_GAIN) {
                ret = kstrtou16(buf, 10, &val);
@@@ -522,7 -518,7 +519,7 @@@ static int ad5933_read_raw(struct iio_d
                           long m)
  {
        struct ad5933_state *st = iio_priv(indio_dev);
 -      unsigned short dat;
 +      __be16 dat;
        int ret = -EINVAL;
  
        mutex_lock(&indio_dev->mlock);
@@@ -749,14 -745,14 +746,14 @@@ static int ad5933_probe(struct i2c_clie
        indio_dev->name = id->name;
        indio_dev->modes = INDIO_DIRECT_MODE;
        indio_dev->channels = ad5933_channels;
-       indio_dev->num_channels = 1; /* only register temp0_input */
+       indio_dev->num_channels = ARRAY_SIZE(ad5933_channels);
  
        ret = ad5933_register_ring_funcs_and_init(indio_dev);
        if (ret)
                goto error_disable_reg;
  
-       /* skip temp0_input, register in0_(real|imag)_raw */
-       ret = iio_buffer_register(indio_dev, &ad5933_channels[1], 2);
+       ret = iio_buffer_register(indio_dev, ad5933_channels,
+               ARRAY_SIZE(ad5933_channels));
        if (ret)
                goto error_unreg_ring;