Merge tag 'iio-for-3.20a_take2' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Jan 2015 02:13:37 +0000 (10:13 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Jan 2015 02:13:37 +0000 (10:13 +0800)
Jonathan writes:

First round of IIO new drivers, cleanups and functionality for the 3.20 cycle take 2

Updated pull request with Daniel's fix on top for the power management
Kconfig changes that had snuck in since last update of the IIO tree
worked it's way through from mainline.

Original pull message

New device support
* jsa1212 proxmity / ambient light sensor
* SM08500 supported added to the kxcjk-1013 accelerometer driver
* KMX61 Accelerometer/Magnetometer.  This took a somewhat rocky path
  being first merged, then reverted for a rewrite after a discussion of
  how to support additional functionality and finally being merged prior
  to some last reviews coming in, with resultant follow up patches.
* Freescale mma9551l driver (minor follow up warning supression patch).
* Semtech SX9500 proximity device driver.
* ak8975 gains support for ak09911 and ak09912 and drop the standalone driver
  for the ak09911.

New functionality
 * Dummy driver gains some virtual registers making it more flexible.
 * IIO_ACTIVITY channel types, with modifiers running, walking etc.  This is
   to support on chip motion clasifiers.  As such it is in the form of a
   confidence percentage.  The only devices so far only do binary decisions
   but this gives us room when other devices give more nuanced clasification.
 * IIO_EV_DIR_NONE type for events where there is no obvious direction.
   First case is step detection.
 * IIO_STEPS channel type for pedometers.
 * ENABLE mask element used to control turning on counting types such as
   the pedometer that need a 'start point'.
 * INSTANCE event type to support things that happen once.
 * info element for height calibration (used in various motion estimation
   algorithms). Note heigh tof use
 * dummy driver demonstration of the use of all the new bits above.
 * event monitor support for the new events.
 * inv_mpu6050 gains an i2c mux to allow bypassing the device to access
   additional devices connected on the other side of it.  Note that in
   Windows these are handled by firmware on the device and not exposed
   directly.
 * inv_mpu6050 gains ACPI enumeration.
 * inkern interface gains iio_write_channel_raw to allow in kernel users
   of DAC functionality via a simple wrapper.
 * Document input current readings in the ABI docs.
 * Add an error message when we get an out of range error in device tree
   processing for the in kernel interfaces.  Basically a device tree debugging
   aid.
 * Add a sanity check that a scan index for a channel is unique during
   registration.  There to help catch bugs as this should never happen
   in a bug free driver.

Cleanups and fixlets

 A rework of buffer registration from Lars - a precursor to some other
 upcoming new stuff (a few patches from others rolled in here as well).
 * Ensure all drivers register the same channels for the device and buffer.
 * Move buffer registration into the core rather than using the old
   two step approach.  Now we have simple ways of using a unified set channels
   for both without requiring channels be exposed by both interface, this
   removes a fair bit of boilerplate.
 * Stop sca3000 and ad5933 (both in staging) enabling buffer channels by
   default. It has long be convention in IIO to startup with no channels
   enabled and leave it up to userspace to say what goes in the buffer.
   Getting rid of these allows us to drop export of iio_scan_mask_set.
 * Drop get_bytes_per_datum from iio_buffer_access_funcs as not been used
   for a while.
 * Allocate standard buffer attributes in the core rather than in every
   driver with a buffer.
 * Make the length attribute read only when a driver is not able to set
   the length.
 * Drop the get_length callback for buffers as it is already available in
   struct iio_buffer.
 * Drop an unused arguement form iio_kfifo_allocate and add devm allocator
   for it.
 * some kconfig entries gain anotation with the resulting module name.
 * Fix a resulting compile issue in dummy driver due to a stub taking
   wrong parameters as a result of the above rework.
 * Fix an off by 2 error in copying the core assigned buffer attributes.

Other cleanups,
 * Trivial space before comma fixups.
 * ak8975 fixlets - none critical.  Rework to allow more device support.
 * Drop unnecessary sizeof(u8) calls.
 * bmp280 - refactor the compensation code to reduce copy operations and
   code length.  A second patch futher optimized this and performed some
   other minor cleanups.
 * kxcjk-1013 - various power control cleanups to avoid unnecessary enable
   / disable of device.  Make sure it is only controlled at all if CONFIG_PM
   is enabled.  Also som cleanups of error paths.
 * Small cleanups in adf4530 driver - pointless message and unnecessary braces.
 * Clarifiy the proximity ABI docs to make it clear it should get bigger
   as we move futher away.
 * Drop a misleading comment form industrialio-core.c
 * Trivial white space cleanups.
 * sca3000 looses an unused debug function.
 * Fix char unsigned ordering in ad8366
 * Increase the sleep time in ad9523 to make it predictable (value didn't
   really matter so make it more than 20 msecs)
 * mxs-lradc touchscreen property cleanups in device tree are fixed to ensure
   the meet all the 'interesting' documentation.
 * A couple of cleanups for the staging ad5933 driver to avoid unnecessary
   conversion to a processed temperature vlaue in kernel and remove
   platform data form the state structure as not needed after probe.
 * Fix a wrong scale factor in the docs.

Misc
 * Add IIO include files to the maintainers entry.

1  2 
drivers/iio/accel/kxcjk-1013.c
drivers/iio/inkern.c
drivers/staging/iio/adc/mxs-lradc.c
drivers/staging/iio/meter/ade7758.h
drivers/staging/iio/meter/ade7758_core.c
drivers/staging/iio/meter/ade7758_ring.c

index da2fe93739a2e442d136725dd3972f4eeed3a7c3,09902f4efc5ea211af95dd1bb8a05d5c5edb34ec..567de269cc00650191541a98ac8d5818d0ea8661
@@@ -108,6 -108,7 +108,7 @@@ struct kxcjk1013_data 
        bool motion_trigger_on;
        int64_t timestamp;
        enum kx_chipset chipset;
+       bool is_smo8500_device;
  };
  
  enum kxcjk1013_axis {
@@@ -269,8 -270,6 +270,8 @@@ static int kxcjk1013_set_range(struct k
                return ret;
        }
  
 +      ret &= ~(KXCJK1013_REG_CTRL1_BIT_GSEL0 |
 +               KXCJK1013_REG_CTRL1_BIT_GSEL1);
        ret |= (KXCJK1013_scale_table[range_index].gsel_0 << 3);
        ret |= (KXCJK1013_scale_table[range_index].gsel_1 << 4);
  
@@@ -360,7 -359,7 +361,7 @@@ static int kxcjk1013_chip_init(struct k
        return 0;
  }
  
 -#ifdef CONFIG_PM_RUNTIME
 +#ifdef CONFIG_PM
  static int kxcjk1013_get_startup_times(struct kxcjk1013_data *data)
  {
        int i;
  
  static int kxcjk1013_set_power_state(struct kxcjk1013_data *data, bool on)
  {
+ #ifdef CONFIG_PM
        int ret;
  
        if (on)
        if (ret < 0) {
                dev_err(&data->client->dev,
                        "Failed: kxcjk1013_set_power_state for %d\n", on);
+               if (on)
+                       pm_runtime_put_noidle(&data->client->dev);
                return ret;
        }
+ #endif
  
        return 0;
  }
@@@ -858,6 -861,8 +863,8 @@@ static int kxcjk1013_write_event_config
  
        ret =  kxcjk1013_setup_any_motion_interrupt(data, state);
        if (ret < 0) {
+               kxcjk1013_set_power_state(data, false);
+               data->ev_enable_state = 0;
                mutex_unlock(&data->mutex);
                return ret;
        }
@@@ -896,7 -901,7 +903,7 @@@ static const struct attribute_group kxc
  
  static const struct iio_event_spec kxcjk1013_event = {
                .type = IIO_EV_TYPE_THRESH,
 -              .dir = IIO_EV_DIR_RISING | IIO_EV_DIR_FALLING,
 +              .dir = IIO_EV_DIR_EITHER,
                .mask_separate = BIT(IIO_EV_INFO_VALUE) |
                                 BIT(IIO_EV_INFO_ENABLE) |
                                 BIT(IIO_EV_INFO_PERIOD)
@@@ -1008,6 -1013,7 +1015,7 @@@ static int kxcjk1013_data_rdy_trigger_s
        else
                ret = kxcjk1013_setup_new_data_interrupt(data, state);
        if (ret < 0) {
+               kxcjk1013_set_power_state(data, false);
                mutex_unlock(&data->mutex);
                return ret;
        }
@@@ -1131,12 -1137,16 +1139,16 @@@ static irqreturn_t kxcjk1013_data_rdy_t
  }
  
  static const char *kxcjk1013_match_acpi_device(struct device *dev,
-                                              enum kx_chipset *chipset)
+                                              enum kx_chipset *chipset,
+                                              bool *is_smo8500_device)
  {
        const struct acpi_device_id *id;
        id = acpi_match_device(dev->driver->acpi_match_table, dev);
        if (!id)
                return NULL;
+       if (strcmp(id->id, "SMO8500") == 0)
+               *is_smo8500_device = true;
        *chipset = (enum kx_chipset)id->driver_data;
  
        return dev_name(dev);
@@@ -1151,6 -1161,8 +1163,8 @@@ static int kxcjk1013_gpio_probe(struct 
  
        if (!client)
                return -EINVAL;
+       if (data->is_smo8500_device)
+               return -ENOTSUPP;
  
        dev = &client->dev;
  
@@@ -1200,7 -1212,8 +1214,8 @@@ static int kxcjk1013_probe(struct i2c_c
                name = id->name;
        } else if (ACPI_HANDLE(&client->dev)) {
                name = kxcjk1013_match_acpi_device(&client->dev,
-                                                  &data->chipset);
+                                                  &data->chipset,
+                                                  &data->is_smo8500_device);
        } else
                return -ENODEV;
  
                                                KXCJK1013_IRQ_NAME,
                                                indio_dev);
                if (ret)
-                       return ret;
+                       goto err_poweroff;
  
                data->dready_trig = devm_iio_trigger_alloc(&client->dev,
                                                           "%s-dev%d",
                                                           indio_dev->name,
                                                           indio_dev->id);
-               if (!data->dready_trig)
-                       return -ENOMEM;
+               if (!data->dready_trig) {
+                       ret = -ENOMEM;
+                       goto err_poweroff;
+               }
  
                data->motion_trig = devm_iio_trigger_alloc(&client->dev,
                                                          "%s-any-motion-dev%d",
                                                          indio_dev->name,
                                                          indio_dev->id);
-               if (!data->motion_trig)
-                       return -ENOMEM;
+               if (!data->motion_trig) {
+                       ret = -ENOMEM;
+                       goto err_poweroff;
+               }
  
                data->dready_trig->dev.parent = &client->dev;
                data->dready_trig->ops = &kxcjk1013_trigger_ops;
                iio_trigger_get(indio_dev->trig);
                ret = iio_trigger_register(data->dready_trig);
                if (ret)
-                       return ret;
+                       goto err_poweroff;
  
                data->motion_trig->dev.parent = &client->dev;
                data->motion_trig->ops = &kxcjk1013_trigger_ops;
@@@ -1300,6 -1317,8 +1319,8 @@@ err_trigger_unregister
                iio_trigger_unregister(data->dready_trig);
        if (data->motion_trig)
                iio_trigger_unregister(data->motion_trig);
+ err_poweroff:
+       kxcjk1013_set_mode(data, STANDBY);
  
        return ret;
  }
@@@ -1349,23 -1368,26 +1370,26 @@@ static int kxcjk1013_resume(struct devi
        int ret = 0;
  
        mutex_lock(&data->mutex);
-       /* Check, if the suspend occured while active */
-       if (data->dready_trigger_on || data->motion_trigger_on ||
-                                                       data->ev_enable_state)
-               ret = kxcjk1013_set_mode(data, OPERATION);
+       ret = kxcjk1013_set_mode(data, OPERATION);
        mutex_unlock(&data->mutex);
  
        return ret;
  }
  #endif
  
 -#ifdef CONFIG_PM_RUNTIME
 +#ifdef CONFIG_PM
  static int kxcjk1013_runtime_suspend(struct device *dev)
  {
        struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
        struct kxcjk1013_data *data = iio_priv(indio_dev);
+       int ret;
  
-       return kxcjk1013_set_mode(data, STANDBY);
+       ret = kxcjk1013_set_mode(data, STANDBY);
+       if (ret < 0) {
+               dev_err(&data->client->dev, "powering off device failed\n");
+               return -EAGAIN;
+       }
+       return 0;
  }
  
  static int kxcjk1013_runtime_resume(struct device *dev)
@@@ -1399,6 -1421,7 +1423,7 @@@ static const struct acpi_device_id kx_a
        {"KXCJ1013", KXCJK1013},
        {"KXCJ1008", KXCJ91008},
        {"KXTJ1009", KXTJ21009},
+       {"SMO8500",  KXCJ91008},
        { },
  };
  MODULE_DEVICE_TABLE(acpi, kx_acpi_match);
@@@ -1407,6 -1430,7 +1432,7 @@@ static const struct i2c_device_id kxcjk
        {"kxcjk1013", KXCJK1013},
        {"kxcj91008", KXCJ91008},
        {"kxtj21009", KXTJ21009},
+       {"SMO8500",   KXCJ91008},
        {}
  };
  
diff --combined drivers/iio/inkern.c
index 90c8cb727cc700b63f25c451c5eb4758bb3e400b,2800b80ea990a6c03dc7cbab71b06b179aeacf22..c8bad3cf891df0f1da009eeeeb1bc4809b879eda
@@@ -116,8 -116,11 +116,11 @@@ static int __of_iio_simple_xlate(struc
        if (!iiospec->args_count)
                return 0;
  
-       if (iiospec->args[0] >= indio_dev->num_channels)
+       if (iiospec->args[0] >= indio_dev->num_channels) {
+               dev_err(&indio_dev->dev, "invalid channel index %u\n",
+                       iiospec->args[0]);
                return -EINVAL;
+       }
  
        return iiospec->args[0];
  }
@@@ -449,9 -452,6 +452,9 @@@ static int iio_channel_read(struct iio_
        if (val2 == NULL)
                val2 = &unused;
  
 +      if(!iio_channel_has_info(chan->channel, info))
 +              return -EINVAL;
 +
        if (chan->indio_dev->info->read_raw_multi) {
                ret = chan->indio_dev->info->read_raw_multi(chan->indio_dev,
                                        chan->channel, INDIO_MAX_RAW_ELEMENTS,
@@@ -634,3 -634,28 +637,28 @@@ err_unlock
        return ret;
  }
  EXPORT_SYMBOL_GPL(iio_get_channel_type);
+ static int iio_channel_write(struct iio_channel *chan, int val, int val2,
+                            enum iio_chan_info_enum info)
+ {
+       return chan->indio_dev->info->write_raw(chan->indio_dev,
+                                               chan->channel, val, val2, info);
+ }
+ int iio_write_channel_raw(struct iio_channel *chan, int val)
+ {
+       int ret;
+       mutex_lock(&chan->indio_dev->info_exist_lock);
+       if (chan->indio_dev->info == NULL) {
+               ret = -ENODEV;
+               goto err_unlock;
+       }
+       ret = iio_channel_write(chan, val, 0, IIO_CHAN_INFO_RAW);
+ err_unlock:
+       mutex_unlock(&chan->indio_dev->info_exist_lock);
+       return ret;
+ }
+ EXPORT_SYMBOL_GPL(iio_write_channel_raw);
index f053535385bf94fbe56b57f31cb0225ff1f35953,e0e91836eec19b6d6c33bbc507b4959f3584897d..d9d6fad7cb00725f43142967bad4ca6b39a32b06
@@@ -436,7 -436,14 +436,14 @@@ static void mxs_lradc_setup_ts_channel(
         */
        mxs_lradc_reg_clear(lradc, LRADC_CH_VALUE_MASK, LRADC_CH(ch));
  
-       /* prepare the delay/loop unit according to the oversampling count */
+       /*
+        * prepare the delay/loop unit according to the oversampling count
+        *
+        * from the datasheet:
+        * "The DELAY fields in HW_LRADC_DELAY0, HW_LRADC_DELAY1,
+        * HW_LRADC_DELAY2, and HW_LRADC_DELAY3 must be non-zero; otherwise,
+        * the LRADC will not trigger the delay group."
+        */
        mxs_lradc_reg_wrt(lradc, LRADC_DELAY_TRIGGER(1 << ch) |
                LRADC_DELAY_TRIGGER_DELAYS(0) |
                LRADC_DELAY_LOOP(lradc->over_sample_cnt - 1) |
@@@ -1495,20 -1502,38 +1502,38 @@@ static int mxs_lradc_probe_touchscreen(
                return -EINVAL;
        }
  
-       lradc->over_sample_cnt = 4;
-       ret = of_property_read_u32(lradc_node, "fsl,ave-ctrl", &adapt);
-       if (ret == 0)
+       if (of_property_read_u32(lradc_node, "fsl,ave-ctrl", &adapt)) {
+               lradc->over_sample_cnt = 4;
+       } else {
+               if (adapt < 1 || adapt > 32) {
+                       dev_err(lradc->dev, "Invalid sample count (%u)\n",
+                               adapt);
+                       return -EINVAL;
+               }
                lradc->over_sample_cnt = adapt;
+       }
  
-       lradc->over_sample_delay = 2;
-       ret = of_property_read_u32(lradc_node, "fsl,ave-delay", &adapt);
-       if (ret == 0)
+       if (of_property_read_u32(lradc_node, "fsl,ave-delay", &adapt)) {
+               lradc->over_sample_delay = 2;
+       } else {
+               if (adapt < 2 || adapt > LRADC_DELAY_DELAY_MASK + 1) {
+                       dev_err(lradc->dev, "Invalid sample delay (%u)\n",
+                               adapt);
+                       return -EINVAL;
+               }
                lradc->over_sample_delay = adapt;
+       }
  
-       lradc->settling_delay = 10;
-       ret = of_property_read_u32(lradc_node, "fsl,settling", &adapt);
-       if (ret == 0)
+       if (of_property_read_u32(lradc_node, "fsl,settling", &adapt)) {
+               lradc->settling_delay = 10;
+       } else {
+               if (adapt < 1 || adapt > LRADC_DELAY_DELAY_MASK) {
+                       dev_err(lradc->dev, "Invalid settling delay (%u)\n",
+                               adapt);
+                       return -EINVAL;
+               }
                lradc->settling_delay = adapt;
+       }
  
        return 0;
  }
@@@ -1670,6 -1695,7 +1695,6 @@@ static int mxs_lradc_remove(struct plat
  static struct platform_driver mxs_lradc_driver = {
        .driver = {
                .name   = DRIVER_NAME,
 -              .owner  = THIS_MODULE,
                .of_match_table = mxs_lradc_dt_ids,
        },
        .probe  = mxs_lradc_probe,
index e8c98cf570701d4c32a51269c844862aea3c5f70,762d7dc0e6e2f0b6848866d1e62a6d1308ee1ca4..f6739e2c24b139271fe4c29ce20917896c554354
@@@ -119,6 -119,7 +119,6 @@@ struct ade7758_state 
        u8                      *tx;
        u8                      *rx;
        struct mutex            buf_lock;
 -      const struct iio_chan_spec *ade7758_ring_channels;
        struct spi_transfer     ring_xfer[4];
        struct spi_message      ring_msg;
        /*
@@@ -145,7 -146,6 +145,6 @@@ ssize_t ade7758_read_data_from_ring(str
  int ade7758_configure_ring(struct iio_dev *indio_dev);
  void ade7758_unconfigure_ring(struct iio_dev *indio_dev);
  
- void ade7758_uninitialize_ring(struct iio_dev *indio_dev);
  int ade7758_set_irq(struct device *dev, bool enable);
  
  int ade7758_spi_write_reg_8(struct device *dev,
index fb373b89dcc2c5f090f0b98b3173e4ffb0d3634f,6e8b01104a68f168429d2ce07f762ed56e244e95..70e96b20c2ebfbc8f57e6f280ddc4a9989bffce3
@@@ -634,6 -634,9 +634,6 @@@ static const struct iio_chan_spec ade77
                .type = IIO_VOLTAGE,
                .indexed = 1,
                .channel = 0,
 -              .extend_name = "raw",
 -              .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
 -              .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
                .address = AD7758_WT(AD7758_PHASE_A, AD7758_VOLTAGE),
                .scan_index = 0,
                .scan_type = {
                .type = IIO_CURRENT,
                .indexed = 1,
                .channel = 0,
 -              .extend_name = "raw",
 -              .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
 -              .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
                .address = AD7758_WT(AD7758_PHASE_A, AD7758_CURRENT),
                .scan_index = 1,
                .scan_type = {
                .type = IIO_POWER,
                .indexed = 1,
                .channel = 0,
 -              .extend_name = "apparent_raw",
 -              .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
 -              .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
 +              .extend_name = "apparent",
                .address = AD7758_WT(AD7758_PHASE_A, AD7758_APP_PWR),
                .scan_index = 2,
                .scan_type = {
                .type = IIO_POWER,
                .indexed = 1,
                .channel = 0,
 -              .extend_name = "active_raw",
 -              .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
 -              .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
 +              .extend_name = "active",
                .address = AD7758_WT(AD7758_PHASE_A, AD7758_ACT_PWR),
                .scan_index = 3,
                .scan_type = {
                .type = IIO_POWER,
                .indexed = 1,
                .channel = 0,
 -              .extend_name = "reactive_raw",
 -              .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
 -              .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
 +              .extend_name = "reactive",
                .address = AD7758_WT(AD7758_PHASE_A, AD7758_REACT_PWR),
                .scan_index = 4,
                .scan_type = {
                .type = IIO_VOLTAGE,
                .indexed = 1,
                .channel = 1,
 -              .extend_name = "raw",
 -              .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
 -              .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
                .address = AD7758_WT(AD7758_PHASE_B, AD7758_VOLTAGE),
                .scan_index = 5,
                .scan_type = {
                .type = IIO_CURRENT,
                .indexed = 1,
                .channel = 1,
 -              .extend_name = "raw",
 -              .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
 -              .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
                .address = AD7758_WT(AD7758_PHASE_B, AD7758_CURRENT),
                .scan_index = 6,
                .scan_type = {
                .type = IIO_POWER,
                .indexed = 1,
                .channel = 1,
 -              .extend_name = "apparent_raw",
 -              .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
 -              .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
 +              .extend_name = "apparent",
                .address = AD7758_WT(AD7758_PHASE_B, AD7758_APP_PWR),
                .scan_index = 7,
                .scan_type = {
                .type = IIO_POWER,
                .indexed = 1,
                .channel = 1,
 -              .extend_name = "active_raw",
 -              .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
 -              .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
 +              .extend_name = "active",
                .address = AD7758_WT(AD7758_PHASE_B, AD7758_ACT_PWR),
                .scan_index = 8,
                .scan_type = {
                .type = IIO_POWER,
                .indexed = 1,
                .channel = 1,
 -              .extend_name = "reactive_raw",
 -              .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
 -              .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
 +              .extend_name = "reactive",
                .address = AD7758_WT(AD7758_PHASE_B, AD7758_REACT_PWR),
                .scan_index = 9,
                .scan_type = {
                .type = IIO_VOLTAGE,
                .indexed = 1,
                .channel = 2,
 -              .extend_name = "raw",
 -              .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
 -              .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
                .address = AD7758_WT(AD7758_PHASE_C, AD7758_VOLTAGE),
                .scan_index = 10,
                .scan_type = {
                .type = IIO_CURRENT,
                .indexed = 1,
                .channel = 2,
 -              .extend_name = "raw",
 -              .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
 -              .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
                .address = AD7758_WT(AD7758_PHASE_C, AD7758_CURRENT),
                .scan_index = 11,
                .scan_type = {
                .type = IIO_POWER,
                .indexed = 1,
                .channel = 2,
 -              .extend_name = "apparent_raw",
 -              .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
 -              .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
 +              .extend_name = "apparent",
                .address = AD7758_WT(AD7758_PHASE_C, AD7758_APP_PWR),
                .scan_index = 12,
                .scan_type = {
                .type = IIO_POWER,
                .indexed = 1,
                .channel = 2,
 -              .extend_name = "active_raw",
 -              .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
 -              .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
 +              .extend_name = "active",
                .address = AD7758_WT(AD7758_PHASE_C, AD7758_ACT_PWR),
                .scan_index = 13,
                .scan_type = {
                .type = IIO_POWER,
                .indexed = 1,
                .channel = 2,
 -              .extend_name = "reactive_raw",
 -              .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
 -              .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
 +              .extend_name = "reactive",
                .address = AD7758_WT(AD7758_PHASE_C, AD7758_REACT_PWR),
                .scan_index = 14,
                .scan_type = {
@@@ -837,36 -873,27 +837,28 @@@ static int ade7758_probe(struct spi_dev
                goto error_free_rx;
        }
        st->us = spi;
 -      st->ade7758_ring_channels = &ade7758_channels[0];
        mutex_init(&st->buf_lock);
  
        indio_dev->name = spi->dev.driver->name;
        indio_dev->dev.parent = &spi->dev;
        indio_dev->info = &ade7758_info;
        indio_dev->modes = INDIO_DIRECT_MODE;
 +      indio_dev->channels = ade7758_channels;
 +      indio_dev->num_channels = ARRAY_SIZE(ade7758_channels);
  
        ret = ade7758_configure_ring(indio_dev);
        if (ret)
                goto error_free_tx;
  
-       ret = iio_buffer_register(indio_dev,
-                                 &ade7758_channels[0],
-                                 ARRAY_SIZE(ade7758_channels));
-       if (ret) {
-               dev_err(&spi->dev, "failed to initialize the ring\n");
-               goto error_unreg_ring_funcs;
-       }
        /* Get the device into a sane initial state */
        ret = ade7758_initial_setup(indio_dev);
        if (ret)
-               goto error_uninitialize_ring;
+               goto error_unreg_ring_funcs;
  
        if (spi->irq) {
                ret = ade7758_probe_trigger(indio_dev);
                if (ret)
-                       goto error_uninitialize_ring;
+                       goto error_unreg_ring_funcs;
        }
  
        ret = iio_device_register(indio_dev);
  error_remove_trigger:
        if (spi->irq)
                ade7758_remove_trigger(indio_dev);
- error_uninitialize_ring:
-       ade7758_uninitialize_ring(indio_dev);
  error_unreg_ring_funcs:
        ade7758_unconfigure_ring(indio_dev);
  error_free_tx:
@@@ -897,7 -922,6 +887,6 @@@ static int ade7758_remove(struct spi_de
        iio_device_unregister(indio_dev);
        ade7758_stop_device(&indio_dev->dev);
        ade7758_remove_trigger(indio_dev);
-       ade7758_uninitialize_ring(indio_dev);
        ade7758_unconfigure_ring(indio_dev);
        kfree(st->tx);
        kfree(st->rx);
index 6e90064907427596e8a5ee0d00c12ea046635874,782fd9a3bc0d2c620264404ccac28afad9bc36d9..3792b57616456c99c55ac6a35cb7b8adc97671dc
@@@ -85,16 -85,17 +85,16 @@@ static irqreturn_t ade7758_trigger_hand
   **/
  static int ade7758_ring_preenable(struct iio_dev *indio_dev)
  {
 -      struct ade7758_state *st = iio_priv(indio_dev);
        unsigned channel;
  
 -      if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
 +      if (bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
                return -EINVAL;
  
        channel = find_first_bit(indio_dev->active_scan_mask,
                                 indio_dev->masklength);
  
        ade7758_write_waveform_type(&indio_dev->dev,
 -              st->ade7758_ring_channels[channel].address);
 +              indio_dev->channels[channel].address);
  
        return 0;
  }
@@@ -118,7 -119,7 +118,7 @@@ int ade7758_configure_ring(struct iio_d
        struct iio_buffer *buffer;
        int ret = 0;
  
-       buffer = iio_kfifo_allocate(indio_dev);
+       buffer = iio_kfifo_allocate();
        if (!buffer) {
                ret = -ENOMEM;
                return ret;
@@@ -180,8 -181,3 +180,3 @@@ error_iio_kfifo_free
        iio_kfifo_free(indio_dev->buffer);
        return ret;
  }
- void ade7758_uninitialize_ring(struct iio_dev *indio_dev)
- {
-       iio_buffer_unregister(indio_dev);
- }