linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] staging:iio: Drop 4 meter drivers.
@ 2018-05-12 17:51 Jonathan Cameron
  2018-05-12 17:51 ` [PATCH 1/4] staging:iio:meter: Drop ADE7753 driver Jonathan Cameron
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Jonathan Cameron @ 2018-05-12 17:51 UTC (permalink / raw)
  To: linux-iio
  Cc: Rodrigo Siqueira, John Syne, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Hartmut Knaack, Michael Hennerich,
	Jonathan Cameron

I announced an intent to drop all the meter drivers from staging as
none of them have been the subject of substantial work in a very long
time indeed.

For the ADE7854 John Syne stepped forward to say he had test hardware
and Rodrigo Siqueira was keen to work on the cleanup.  Some extensive
conversations have been since had about the changes required in the IIO
core to support these devices and the resulting userspace and kernel
ABI that we need to get to for the drivers.

However, whilst this progress is excellent, the remaining four drivers
are for obsolete and more or less unobtainable hardware.  Hence I am
now proposing we drop them.  There are some great looking new meter
parts out there from ADI (and I'm hopeful we'll be able to add support
for some of those!), but they are very different devices.

I am going to take an increasingly hard look at the remaining IIO drivers
in staging.  Some have recieved considerable attention (quite a few have
graduated in the last few months) so I'm happy with the progress on them.
Others have sat there since before we took any of IIO out of staging
and are not showing any signs of moving in the right direction.

Anyhow, if no one shouts in the next week I'll apply this series.
Ideally I'd like some ack's on these, but appreciate that they are no longer
really in anyone's purview.

Jonathan Cameron (4):
  staging:iio:meter: Drop ADE7753 driver
  staging:iio:meter: Drop ADE7754 driver
  staging:iio:meter: Drop ADE7758 driver
  staging:iio:meter: Drop ADE7759 driver

 drivers/staging/iio/meter/Kconfig           |  42 -
 drivers/staging/iio/meter/Makefile          |   8 -
 drivers/staging/iio/meter/ade7753.c         | 630 -------------
 drivers/staging/iio/meter/ade7754.c         | 664 --------------
 drivers/staging/iio/meter/ade7758.h         | 183 ----
 drivers/staging/iio/meter/ade7758_core.c    | 955 --------------------
 drivers/staging/iio/meter/ade7758_ring.c    | 177 ----
 drivers/staging/iio/meter/ade7758_trigger.c | 108 ---
 drivers/staging/iio/meter/ade7759.c         | 558 ------------
 9 files changed, 3325 deletions(-)
 delete mode 100644 drivers/staging/iio/meter/ade7753.c
 delete mode 100644 drivers/staging/iio/meter/ade7754.c
 delete mode 100644 drivers/staging/iio/meter/ade7758.h
 delete mode 100644 drivers/staging/iio/meter/ade7758_core.c
 delete mode 100644 drivers/staging/iio/meter/ade7758_ring.c
 delete mode 100644 drivers/staging/iio/meter/ade7758_trigger.c
 delete mode 100644 drivers/staging/iio/meter/ade7759.c

-- 
2.17.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] staging:iio:meter: Drop ADE7753 driver
  2018-05-12 17:51 [PATCH 0/4] staging:iio: Drop 4 meter drivers Jonathan Cameron
@ 2018-05-12 17:51 ` Jonathan Cameron
  2018-05-20 11:21   ` Jonathan Cameron
  2018-05-12 17:51 ` [PATCH 2/4] staging:iio:meter: Drop ADE7754 driver Jonathan Cameron
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Jonathan Cameron @ 2018-05-12 17:51 UTC (permalink / raw)
  To: linux-iio
  Cc: Rodrigo Siqueira, John Syne, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Hartmut Knaack, Michael Hennerich,
	Jonathan Cameron

I announced the intent to drop some of these meter drivers
on the IIO list last cycle. This device is obsolete and not easily
obtained.  No one has come forward with suitable test hardware and
the driver would need a lot of work to move out of staging.

As such I am dropping it.  We can always bring it back again
if a user / tester emerges in the future.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/staging/iio/meter/Kconfig   |  10 -
 drivers/staging/iio/meter/Makefile  |   1 -
 drivers/staging/iio/meter/ade7753.c | 630 ----------------------------
 3 files changed, 641 deletions(-)

diff --git a/drivers/staging/iio/meter/Kconfig b/drivers/staging/iio/meter/Kconfig
index 64cd3704ec6e..62db8d6498f5 100644
--- a/drivers/staging/iio/meter/Kconfig
+++ b/drivers/staging/iio/meter/Kconfig
@@ -3,16 +3,6 @@
 #
 menu "Active energy metering IC"
 
-config ADE7753
-	tristate "Analog Devices ADE7753/6 Single-Phase Multifunction Metering IC Driver"
-	depends on SPI
-	help
-	  Say yes here to build support for Analog Devices ADE7753 Single-Phase Multifunction
-	  Metering IC with di/dt Sensor Interface.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called ade7753.
-
 config ADE7754
 	tristate "Analog Devices ADE7754 Polyphase Multifunction Energy Metering IC Driver"
 	depends on SPI
diff --git a/drivers/staging/iio/meter/Makefile b/drivers/staging/iio/meter/Makefile
index 19e7982f5563..8b2592b32845 100644
--- a/drivers/staging/iio/meter/Makefile
+++ b/drivers/staging/iio/meter/Makefile
@@ -3,7 +3,6 @@
 # Makefile for metering ic drivers
 #
 
-obj-$(CONFIG_ADE7753) += ade7753.o
 obj-$(CONFIG_ADE7754) += ade7754.o
 
 ade7758-y             := ade7758_core.o
diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c
deleted file mode 100644
index 275e8dfff836..000000000000
--- a/drivers/staging/iio/meter/ade7753.c
+++ /dev/null
@@ -1,630 +0,0 @@
-/*
- * ADE7753 Single-Phase Multifunction Metering IC with di/dt Sensor Interface
- *
- * Copyright 2010 Analog Devices Inc.
- *
- * Licensed under the GPL-2 or later.
- */
-
-#include <linux/delay.h>
-#include <linux/device.h>
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/kernel.h>
-#include <linux/list.h>
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
-#include <linux/spi/spi.h>
-#include "meter.h"
-
-#define ADE7753_WAVEFORM   0x01
-#define ADE7753_AENERGY    0x02
-#define ADE7753_RAENERGY   0x03
-#define ADE7753_LAENERGY   0x04
-#define ADE7753_VAENERGY   0x05
-#define ADE7753_RVAENERGY  0x06
-#define ADE7753_LVAENERGY  0x07
-#define ADE7753_LVARENERGY 0x08
-#define ADE7753_MODE       0x09
-#define ADE7753_IRQEN      0x0A
-#define ADE7753_STATUS     0x0B
-#define ADE7753_RSTSTATUS  0x0C
-#define ADE7753_CH1OS      0x0D
-#define ADE7753_CH2OS      0x0E
-#define ADE7753_GAIN       0x0F
-#define ADE7753_PHCAL      0x10
-#define ADE7753_APOS       0x11
-#define ADE7753_WGAIN      0x12
-#define ADE7753_WDIV       0x13
-#define ADE7753_CFNUM      0x14
-#define ADE7753_CFDEN      0x15
-#define ADE7753_IRMS       0x16
-#define ADE7753_VRMS       0x17
-#define ADE7753_IRMSOS     0x18
-#define ADE7753_VRMSOS     0x19
-#define ADE7753_VAGAIN     0x1A
-#define ADE7753_VADIV      0x1B
-#define ADE7753_LINECYC    0x1C
-#define ADE7753_ZXTOUT     0x1D
-#define ADE7753_SAGCYC     0x1E
-#define ADE7753_SAGLVL     0x1F
-#define ADE7753_IPKLVL     0x20
-#define ADE7753_VPKLVL     0x21
-#define ADE7753_IPEAK      0x22
-#define ADE7753_RSTIPEAK   0x23
-#define ADE7753_VPEAK      0x24
-#define ADE7753_RSTVPEAK   0x25
-#define ADE7753_TEMP       0x26
-#define ADE7753_PERIOD     0x27
-#define ADE7753_TMODE      0x3D
-#define ADE7753_CHKSUM     0x3E
-#define ADE7753_DIEREV     0x3F
-
-#define ADE7753_READ_REG(a)    a
-#define ADE7753_WRITE_REG(a) ((a) | 0x80)
-
-#define ADE7753_MAX_TX    4
-#define ADE7753_MAX_RX    4
-#define ADE7753_STARTUP_DELAY 1000
-
-#define ADE7753_SPI_SLOW    (u32)(300 * 1000)
-#define ADE7753_SPI_BURST   (u32)(1000 * 1000)
-#define ADE7753_SPI_FAST    (u32)(2000 * 1000)
-
-/**
- * struct ade7753_state - device instance specific data
- * @us:         actual spi_device
- * @tx:         transmit buffer
- * @rx:         receive buffer
- * @buf_lock:       mutex to protect tx, rx and write frequency
- **/
-struct ade7753_state {
-	struct spi_device   *us;
-	struct mutex        buf_lock;
-	u8          tx[ADE7753_MAX_TX] ____cacheline_aligned;
-	u8          rx[ADE7753_MAX_RX];
-};
-
-static int ade7753_spi_write_reg_8(struct device *dev,
-				   u8 reg_address,
-				   u8 val)
-{
-	int ret;
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7753_state *st = iio_priv(indio_dev);
-
-	mutex_lock(&st->buf_lock);
-	st->tx[0] = ADE7753_WRITE_REG(reg_address);
-	st->tx[1] = val;
-
-	ret = spi_write(st->us, st->tx, 2);
-	mutex_unlock(&st->buf_lock);
-
-	return ret;
-}
-
-static int __ade7753_spi_write_reg_16(struct device *dev, u8 reg_address,
-				      u16 value)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7753_state *st = iio_priv(indio_dev);
-
-	st->tx[0] = ADE7753_WRITE_REG(reg_address);
-	st->tx[1] = (value >> 8) & 0xFF;
-	st->tx[2] = value & 0xFF;
-
-	return spi_write(st->us, st->tx, 3);
-}
-
-static int ade7753_spi_write_reg_16(struct device *dev, u8 reg_address,
-				    u16 value)
-{
-	int ret;
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7753_state *st = iio_priv(indio_dev);
-
-	mutex_lock(&st->buf_lock);
-	ret = __ade7753_spi_write_reg_16(dev, reg_address, value);
-	mutex_unlock(&st->buf_lock);
-
-	return ret;
-}
-
-static int ade7753_spi_read_reg_8(struct device *dev,
-				  u8 reg_address,
-				  u8 *val)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7753_state *st = iio_priv(indio_dev);
-	ssize_t ret;
-
-	ret = spi_w8r8(st->us, ADE7753_READ_REG(reg_address));
-	if (ret < 0) {
-		dev_err(&st->us->dev, "problem when reading 8 bit register 0x%02X",
-			reg_address);
-		return ret;
-	}
-	*val = ret;
-
-	return 0;
-}
-
-static int ade7753_spi_read_reg_16(struct device *dev,
-				   u8 reg_address,
-				   u16 *val)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7753_state *st = iio_priv(indio_dev);
-	ssize_t ret;
-
-	ret = spi_w8r16be(st->us, ADE7753_READ_REG(reg_address));
-	if (ret < 0) {
-		dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
-			reg_address);
-		return ret;
-	}
-
-	*val = ret;
-
-	return 0;
-}
-
-static int ade7753_spi_read_reg_24(struct device *dev,
-				   u8 reg_address,
-				   u32 *val)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7753_state *st = iio_priv(indio_dev);
-	int ret;
-	struct spi_transfer xfers[] = {
-		{
-			.tx_buf = st->tx,
-			.bits_per_word = 8,
-			.len = 1,
-		}, {
-			.rx_buf = st->tx,
-			.bits_per_word = 8,
-			.len = 3,
-		}
-	};
-
-	mutex_lock(&st->buf_lock);
-	st->tx[0] = ADE7753_READ_REG(reg_address);
-
-	ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
-	if (ret) {
-		dev_err(&st->us->dev, "problem when reading 24 bit register 0x%02X",
-			reg_address);
-		goto error_ret;
-	}
-	*val = (st->rx[0] << 16) | (st->rx[1] << 8) | st->rx[2];
-
-error_ret:
-	mutex_unlock(&st->buf_lock);
-	return ret;
-}
-
-static ssize_t ade7753_read_8bit(struct device *dev,
-				 struct device_attribute *attr,
-				 char *buf)
-{
-	int ret;
-	u8 val;
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-	ret = ade7753_spi_read_reg_8(dev, this_attr->address, &val);
-	if (ret)
-		return ret;
-
-	return sprintf(buf, "%u\n", val);
-}
-
-static ssize_t ade7753_read_16bit(struct device *dev,
-				  struct device_attribute *attr,
-				  char *buf)
-{
-	int ret;
-	u16 val;
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-	ret = ade7753_spi_read_reg_16(dev, this_attr->address, &val);
-	if (ret)
-		return ret;
-
-	return sprintf(buf, "%u\n", val);
-}
-
-static ssize_t ade7753_read_24bit(struct device *dev,
-				  struct device_attribute *attr,
-				  char *buf)
-{
-	int ret;
-	u32 val;
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-	ret = ade7753_spi_read_reg_24(dev, this_attr->address, &val);
-	if (ret)
-		return ret;
-
-	return sprintf(buf, "%u\n", val);
-}
-
-static ssize_t ade7753_write_8bit(struct device *dev,
-				  struct device_attribute *attr,
-				  const char *buf,
-				  size_t len)
-{
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-	int ret;
-	u8 val;
-
-	ret = kstrtou8(buf, 10, &val);
-	if (ret)
-		goto error_ret;
-	ret = ade7753_spi_write_reg_8(dev, this_attr->address, val);
-
-error_ret:
-	return ret ? ret : len;
-}
-
-static ssize_t ade7753_write_16bit(struct device *dev,
-				   struct device_attribute *attr,
-				   const char *buf,
-				   size_t len)
-{
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-	int ret;
-	u16 val;
-
-	ret = kstrtou16(buf, 10, &val);
-	if (ret)
-		goto error_ret;
-	ret = ade7753_spi_write_reg_16(dev, this_attr->address, val);
-
-error_ret:
-	return ret ? ret : len;
-}
-
-static int ade7753_reset(struct device *dev)
-{
-	u16 val;
-	int ret;
-
-	ret = ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val);
-	if (ret)
-		return ret;
-
-	val |= BIT(6); /* Software Chip Reset */
-
-	return ade7753_spi_write_reg_16(dev, ADE7753_MODE, val);
-}
-
-static IIO_DEV_ATTR_AENERGY(ade7753_read_24bit, ADE7753_AENERGY);
-static IIO_DEV_ATTR_LAENERGY(ade7753_read_24bit, ADE7753_LAENERGY);
-static IIO_DEV_ATTR_VAENERGY(ade7753_read_24bit, ADE7753_VAENERGY);
-static IIO_DEV_ATTR_LVAENERGY(ade7753_read_24bit, ADE7753_LVAENERGY);
-static IIO_DEV_ATTR_CFDEN(0644,
-		ade7753_read_16bit,
-		ade7753_write_16bit,
-		ADE7753_CFDEN);
-static IIO_DEV_ATTR_CFNUM(0644,
-		ade7753_read_8bit,
-		ade7753_write_8bit,
-		ADE7753_CFNUM);
-static IIO_DEV_ATTR_CHKSUM(ade7753_read_8bit, ADE7753_CHKSUM);
-static IIO_DEV_ATTR_PHCAL(0644,
-		ade7753_read_16bit,
-		ade7753_write_16bit,
-		ADE7753_PHCAL);
-static IIO_DEV_ATTR_APOS(0644,
-		ade7753_read_16bit,
-		ade7753_write_16bit,
-		ADE7753_APOS);
-static IIO_DEV_ATTR_SAGCYC(0644,
-		ade7753_read_8bit,
-		ade7753_write_8bit,
-		ADE7753_SAGCYC);
-static IIO_DEV_ATTR_SAGLVL(0644,
-		ade7753_read_8bit,
-		ade7753_write_8bit,
-		ADE7753_SAGLVL);
-static IIO_DEV_ATTR_LINECYC(0644,
-		ade7753_read_8bit,
-		ade7753_write_8bit,
-		ADE7753_LINECYC);
-static IIO_DEV_ATTR_WDIV(0644,
-		ade7753_read_8bit,
-		ade7753_write_8bit,
-		ADE7753_WDIV);
-static IIO_DEV_ATTR_IRMS(0644,
-		ade7753_read_24bit,
-		NULL,
-		ADE7753_IRMS);
-static IIO_DEV_ATTR_VRMS(0444,
-		ade7753_read_24bit,
-		NULL,
-		ADE7753_VRMS);
-static IIO_DEV_ATTR_IRMSOS(0644,
-		ade7753_read_16bit,
-		ade7753_write_16bit,
-		ADE7753_IRMSOS);
-static IIO_DEV_ATTR_VRMSOS(0644,
-		ade7753_read_16bit,
-		ade7753_write_16bit,
-		ADE7753_VRMSOS);
-static IIO_DEV_ATTR_WGAIN(0644,
-		ade7753_read_16bit,
-		ade7753_write_16bit,
-		ADE7753_WGAIN);
-static IIO_DEV_ATTR_VAGAIN(0644,
-		ade7753_read_16bit,
-		ade7753_write_16bit,
-		ADE7753_VAGAIN);
-static IIO_DEV_ATTR_PGA_GAIN(0644,
-		ade7753_read_16bit,
-		ade7753_write_16bit,
-		ADE7753_GAIN);
-static IIO_DEV_ATTR_IPKLVL(0644,
-		ade7753_read_8bit,
-		ade7753_write_8bit,
-		ADE7753_IPKLVL);
-static IIO_DEV_ATTR_VPKLVL(0644,
-		ade7753_read_8bit,
-		ade7753_write_8bit,
-		ADE7753_VPKLVL);
-static IIO_DEV_ATTR_IPEAK(0444,
-		ade7753_read_24bit,
-		NULL,
-		ADE7753_IPEAK);
-static IIO_DEV_ATTR_VPEAK(0444,
-		ade7753_read_24bit,
-		NULL,
-		ADE7753_VPEAK);
-static IIO_DEV_ATTR_VPERIOD(0444,
-		ade7753_read_16bit,
-		NULL,
-		ADE7753_PERIOD);
-
-static IIO_DEVICE_ATTR(choff_1, 0644,
-			ade7753_read_8bit,
-			ade7753_write_8bit,
-			ADE7753_CH1OS);
-
-static IIO_DEVICE_ATTR(choff_2, 0644,
-			ade7753_read_8bit,
-			ade7753_write_8bit,
-			ADE7753_CH2OS);
-
-static int ade7753_set_irq(struct device *dev, bool enable)
-{
-	int ret;
-	u8 irqen;
-
-	ret = ade7753_spi_read_reg_8(dev, ADE7753_IRQEN, &irqen);
-	if (ret)
-		goto error_ret;
-
-	if (enable)
-		irqen |= BIT(3); /* Enables an interrupt when a data is
-				  * present in the waveform register
-				  */
-	else
-		irqen &= ~BIT(3);
-
-	ret = ade7753_spi_write_reg_8(dev, ADE7753_IRQEN, irqen);
-
-error_ret:
-	return ret;
-}
-
-/* Power down the device */
-static int ade7753_stop_device(struct device *dev)
-{
-	u16 val;
-	int ret;
-
-	ret = ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val);
-	if (ret)
-		return ret;
-
-	val |= BIT(4);  /* AD converters can be turned off */
-
-	return ade7753_spi_write_reg_16(dev, ADE7753_MODE, val);
-}
-
-static int ade7753_initial_setup(struct iio_dev *indio_dev)
-{
-	int ret;
-	struct device *dev = &indio_dev->dev;
-	struct ade7753_state *st = iio_priv(indio_dev);
-
-	/* use low spi speed for init */
-	st->us->mode = SPI_MODE_3;
-	spi_setup(st->us);
-
-	/* Disable IRQ */
-	ret = ade7753_set_irq(dev, false);
-	if (ret) {
-		dev_err(dev, "disable irq failed");
-		goto err_ret;
-	}
-
-	ade7753_reset(dev);
-	usleep_range(ADE7753_STARTUP_DELAY, ADE7753_STARTUP_DELAY + 100);
-
-err_ret:
-	return ret;
-}
-
-static ssize_t ade7753_read_frequency(struct device *dev,
-				      struct device_attribute *attr,
-				      char *buf)
-{
-	int ret;
-	u16 t;
-	int sps;
-
-	ret = ade7753_spi_read_reg_16(dev, ADE7753_MODE, &t);
-	if (ret)
-		return ret;
-
-	t = (t >> 11) & 0x3;
-	sps = 27900 / (1 + t);
-
-	return sprintf(buf, "%d\n", sps);
-}
-
-static ssize_t ade7753_write_frequency(struct device *dev,
-				       struct device_attribute *attr,
-				       const char *buf,
-				       size_t len)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7753_state *st = iio_priv(indio_dev);
-	u16 val;
-	int ret;
-	u16 reg, t;
-
-	ret = kstrtou16(buf, 10, &val);
-	if (ret)
-		return ret;
-	if (!val)
-		return -EINVAL;
-
-	mutex_lock(&st->buf_lock);
-
-	t = 27900 / val;
-	if (t > 0)
-		t--;
-
-	if (t > 1)
-		st->us->max_speed_hz = ADE7753_SPI_SLOW;
-	else
-		st->us->max_speed_hz = ADE7753_SPI_FAST;
-
-	ret = ade7753_spi_read_reg_16(dev, ADE7753_MODE, &reg);
-	if (ret)
-		goto out;
-
-	reg &= ~(3 << 11);
-	reg |= t << 11;
-
-	ret = __ade7753_spi_write_reg_16(dev, ADE7753_MODE, reg);
-
-out:
-	mutex_unlock(&st->buf_lock);
-
-	return ret ? ret : len;
-}
-
-static IIO_DEV_ATTR_TEMP_RAW(ade7753_read_8bit);
-static IIO_CONST_ATTR(in_temp_offset, "-25 C");
-static IIO_CONST_ATTR(in_temp_scale, "0.67 C");
-
-static IIO_DEV_ATTR_SAMP_FREQ(0644,
-		ade7753_read_frequency,
-		ade7753_write_frequency);
-
-static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("27900 14000 7000 3500");
-
-static struct attribute *ade7753_attributes[] = {
-	&iio_dev_attr_in_temp_raw.dev_attr.attr,
-	&iio_const_attr_in_temp_offset.dev_attr.attr,
-	&iio_const_attr_in_temp_scale.dev_attr.attr,
-	&iio_dev_attr_sampling_frequency.dev_attr.attr,
-	&iio_const_attr_sampling_frequency_available.dev_attr.attr,
-	&iio_dev_attr_phcal.dev_attr.attr,
-	&iio_dev_attr_cfden.dev_attr.attr,
-	&iio_dev_attr_aenergy.dev_attr.attr,
-	&iio_dev_attr_laenergy.dev_attr.attr,
-	&iio_dev_attr_vaenergy.dev_attr.attr,
-	&iio_dev_attr_lvaenergy.dev_attr.attr,
-	&iio_dev_attr_cfnum.dev_attr.attr,
-	&iio_dev_attr_apos.dev_attr.attr,
-	&iio_dev_attr_sagcyc.dev_attr.attr,
-	&iio_dev_attr_saglvl.dev_attr.attr,
-	&iio_dev_attr_linecyc.dev_attr.attr,
-	&iio_dev_attr_chksum.dev_attr.attr,
-	&iio_dev_attr_pga_gain.dev_attr.attr,
-	&iio_dev_attr_wgain.dev_attr.attr,
-	&iio_dev_attr_choff_1.dev_attr.attr,
-	&iio_dev_attr_choff_2.dev_attr.attr,
-	&iio_dev_attr_wdiv.dev_attr.attr,
-	&iio_dev_attr_irms.dev_attr.attr,
-	&iio_dev_attr_vrms.dev_attr.attr,
-	&iio_dev_attr_irmsos.dev_attr.attr,
-	&iio_dev_attr_vrmsos.dev_attr.attr,
-	&iio_dev_attr_vagain.dev_attr.attr,
-	&iio_dev_attr_ipklvl.dev_attr.attr,
-	&iio_dev_attr_vpklvl.dev_attr.attr,
-	&iio_dev_attr_ipeak.dev_attr.attr,
-	&iio_dev_attr_vpeak.dev_attr.attr,
-	&iio_dev_attr_vperiod.dev_attr.attr,
-	NULL,
-};
-
-static const struct attribute_group ade7753_attribute_group = {
-	.attrs = ade7753_attributes,
-};
-
-static const struct iio_info ade7753_info = {
-	.attrs = &ade7753_attribute_group,
-};
-
-static int ade7753_probe(struct spi_device *spi)
-{
-	int ret;
-	struct ade7753_state *st;
-	struct iio_dev *indio_dev;
-
-	/* setup the industrialio driver allocated elements */
-	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
-	if (!indio_dev)
-		return -ENOMEM;
-	/* this is only used for removal purposes */
-	spi_set_drvdata(spi, indio_dev);
-
-	st = iio_priv(indio_dev);
-	st->us = spi;
-	mutex_init(&st->buf_lock);
-
-	indio_dev->name = spi->dev.driver->name;
-	indio_dev->dev.parent = &spi->dev;
-	indio_dev->info = &ade7753_info;
-	indio_dev->modes = INDIO_DIRECT_MODE;
-
-	/* Get the device into a sane initial state */
-	ret = ade7753_initial_setup(indio_dev);
-	if (ret)
-		return ret;
-
-	return iio_device_register(indio_dev);
-}
-
-static int ade7753_remove(struct spi_device *spi)
-{
-	struct iio_dev *indio_dev = spi_get_drvdata(spi);
-
-	iio_device_unregister(indio_dev);
-	ade7753_stop_device(&indio_dev->dev);
-
-	return 0;
-}
-
-static struct spi_driver ade7753_driver = {
-	.driver = {
-		.name = "ade7753",
-	},
-	.probe = ade7753_probe,
-	.remove = ade7753_remove,
-};
-module_spi_driver(ade7753_driver);
-
-MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
-MODULE_DESCRIPTION("Analog Devices ADE7753/6 Single-Phase Multifunction Meter");
-MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("spi:ade7753");
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] staging:iio:meter: Drop ADE7754 driver
  2018-05-12 17:51 [PATCH 0/4] staging:iio: Drop 4 meter drivers Jonathan Cameron
  2018-05-12 17:51 ` [PATCH 1/4] staging:iio:meter: Drop ADE7753 driver Jonathan Cameron
@ 2018-05-12 17:51 ` Jonathan Cameron
  2018-05-20 11:22   ` Jonathan Cameron
  2018-05-12 17:51 ` [PATCH 3/4] staging:iio:meter: Drop ADE7758 driver Jonathan Cameron
  2018-05-12 17:51 ` [PATCH 4/4] staging:iio:meter: Drop ADE7759 driver Jonathan Cameron
  3 siblings, 1 reply; 9+ messages in thread
From: Jonathan Cameron @ 2018-05-12 17:51 UTC (permalink / raw)
  To: linux-iio
  Cc: Rodrigo Siqueira, John Syne, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Hartmut Knaack, Michael Hennerich,
	Jonathan Cameron

I announced the intent to drop some of these meter drivers
on the IIO list last cycle. This device is obsolete and not easily
obtained.  No one has come forward with suitable test hardware and
the driver would need a lot of work to move out of staging.

As such I am dropping it.  We can always bring it back again
if a user / tester emerges in the future.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/staging/iio/meter/Kconfig   |  10 -
 drivers/staging/iio/meter/Makefile  |   2 -
 drivers/staging/iio/meter/ade7754.c | 664 ----------------------------
 3 files changed, 676 deletions(-)

diff --git a/drivers/staging/iio/meter/Kconfig b/drivers/staging/iio/meter/Kconfig
index 62db8d6498f5..d60f052415c8 100644
--- a/drivers/staging/iio/meter/Kconfig
+++ b/drivers/staging/iio/meter/Kconfig
@@ -3,16 +3,6 @@
 #
 menu "Active energy metering IC"
 
-config ADE7754
-	tristate "Analog Devices ADE7754 Polyphase Multifunction Energy Metering IC Driver"
-	depends on SPI
-	help
-	  Say yes here to build support for Analog Devices ADE7754 Polyphase
-	  Multifunction Energy Metering IC Driver.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called ade7754.
-
 config ADE7758
 	tristate "Analog Devices ADE7758 Poly Phase Multifunction Energy Metering IC Driver"
 	depends on SPI
diff --git a/drivers/staging/iio/meter/Makefile b/drivers/staging/iio/meter/Makefile
index 8b2592b32845..42f4157969de 100644
--- a/drivers/staging/iio/meter/Makefile
+++ b/drivers/staging/iio/meter/Makefile
@@ -3,8 +3,6 @@
 # Makefile for metering ic drivers
 #
 
-obj-$(CONFIG_ADE7754) += ade7754.o
-
 ade7758-y             := ade7758_core.o
 ade7758-$(CONFIG_IIO_BUFFER) += ade7758_ring.o ade7758_trigger.o
 obj-$(CONFIG_ADE7758) += ade7758.o
diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c
deleted file mode 100644
index 9aa067736715..000000000000
--- a/drivers/staging/iio/meter/ade7754.c
+++ /dev/null
@@ -1,664 +0,0 @@
-/*
- * ADE7754 Polyphase Multifunction Energy Metering IC Driver
- *
- * Copyright 2010 Analog Devices Inc.
- *
- * Licensed under the GPL-2 or later.
- */
-
-#include <linux/delay.h>
-#include <linux/device.h>
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/kernel.h>
-#include <linux/list.h>
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
-#include "meter.h"
-
-#define ADE7754_AENERGY   0x01
-#define ADE7754_RAENERGY  0x02
-#define ADE7754_LAENERGY  0x03
-#define ADE7754_VAENERGY  0x04
-#define ADE7754_RVAENERGY 0x05
-#define ADE7754_LVAENERGY 0x06
-#define ADE7754_PERIOD    0x07
-#define ADE7754_TEMP      0x08
-#define ADE7754_WFORM     0x09
-#define ADE7754_OPMODE    0x0A
-#define ADE7754_MMODE     0x0B
-#define ADE7754_WAVMODE   0x0C
-#define ADE7754_WATMODE   0x0D
-#define ADE7754_VAMODE    0x0E
-#define ADE7754_IRQEN     0x0F
-#define ADE7754_STATUS    0x10
-#define ADE7754_RSTATUS   0x11
-#define ADE7754_ZXTOUT    0x12
-#define ADE7754_LINCYC    0x13
-#define ADE7754_SAGCYC    0x14
-#define ADE7754_SAGLVL    0x15
-#define ADE7754_VPEAK     0x16
-#define ADE7754_IPEAK     0x17
-#define ADE7754_GAIN      0x18
-#define ADE7754_AWG       0x19
-#define ADE7754_BWG       0x1A
-#define ADE7754_CWG       0x1B
-#define ADE7754_AVAG      0x1C
-#define ADE7754_BVAG      0x1D
-#define ADE7754_CVAG      0x1E
-#define ADE7754_APHCAL    0x1F
-#define ADE7754_BPHCAL    0x20
-#define ADE7754_CPHCAL    0x21
-#define ADE7754_AAPOS     0x22
-#define ADE7754_BAPOS     0x23
-#define ADE7754_CAPOS     0x24
-#define ADE7754_CFNUM     0x25
-#define ADE7754_CFDEN     0x26
-#define ADE7754_WDIV      0x27
-#define ADE7754_VADIV     0x28
-#define ADE7754_AIRMS     0x29
-#define ADE7754_BIRMS     0x2A
-#define ADE7754_CIRMS     0x2B
-#define ADE7754_AVRMS     0x2C
-#define ADE7754_BVRMS     0x2D
-#define ADE7754_CVRMS     0x2E
-#define ADE7754_AIRMSOS   0x2F
-#define ADE7754_BIRMSOS   0x30
-#define ADE7754_CIRMSOS   0x31
-#define ADE7754_AVRMSOS   0x32
-#define ADE7754_BVRMSOS   0x33
-#define ADE7754_CVRMSOS   0x34
-#define ADE7754_AAPGAIN   0x35
-#define ADE7754_BAPGAIN   0x36
-#define ADE7754_CAPGAIN   0x37
-#define ADE7754_AVGAIN    0x38
-#define ADE7754_BVGAIN    0x39
-#define ADE7754_CVGAIN    0x3A
-#define ADE7754_CHKSUM    0x3E
-#define ADE7754_VERSION   0x3F
-
-#define ADE7754_READ_REG(a)    a
-#define ADE7754_WRITE_REG(a) ((a) | 0x80)
-
-#define ADE7754_MAX_TX    4
-#define ADE7754_MAX_RX    4
-#define ADE7754_STARTUP_DELAY 1000
-
-#define ADE7754_SPI_SLOW	(u32)(300 * 1000)
-#define ADE7754_SPI_BURST	(u32)(1000 * 1000)
-#define ADE7754_SPI_FAST	(u32)(2000 * 1000)
-
-/**
- * struct ade7754_state - device instance specific data
- * @us:			actual spi_device
- * @buf_lock:		mutex to protect tx, rx and write frequency
- * @tx:			transmit buffer
- * @rx:			receive buffer
- **/
-struct ade7754_state {
-	struct spi_device	*us;
-	struct mutex		buf_lock;
-	u8			tx[ADE7754_MAX_TX] ____cacheline_aligned;
-	u8			rx[ADE7754_MAX_RX];
-};
-
-/* Unlocked version of ade7754_spi_write_reg_8 function */
-static int __ade7754_spi_write_reg_8(struct device *dev, u8 reg_address, u8 val)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7754_state *st = iio_priv(indio_dev);
-
-	st->tx[0] = ADE7754_WRITE_REG(reg_address);
-	st->tx[1] = val;
-	return spi_write(st->us, st->tx, 2);
-}
-
-static int ade7754_spi_write_reg_8(struct device *dev, u8 reg_address, u8 val)
-{
-	int ret;
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7754_state *st = iio_priv(indio_dev);
-
-	mutex_lock(&st->buf_lock);
-	ret = __ade7754_spi_write_reg_8(dev, reg_address, val);
-	mutex_unlock(&st->buf_lock);
-
-	return ret;
-}
-
-static int ade7754_spi_write_reg_16(struct device *dev,
-				    u8 reg_address, u16 val)
-{
-	int ret;
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7754_state *st = iio_priv(indio_dev);
-
-	mutex_lock(&st->buf_lock);
-	st->tx[0] = ADE7754_WRITE_REG(reg_address);
-	st->tx[1] = (val >> 8) & 0xFF;
-	st->tx[2] = val & 0xFF;
-	ret = spi_write(st->us, st->tx, 3);
-	mutex_unlock(&st->buf_lock);
-
-	return ret;
-}
-
-static int ade7754_spi_read_reg_8(struct device *dev, u8 reg_address, u8 *val)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7754_state *st = iio_priv(indio_dev);
-	int ret;
-
-	ret = spi_w8r8(st->us, ADE7754_READ_REG(reg_address));
-	if (ret < 0) {
-		dev_err(&st->us->dev, "problem when reading 8 bit register 0x%02X",
-			reg_address);
-		return ret;
-	}
-	*val = ret;
-
-	return 0;
-}
-
-static int ade7754_spi_read_reg_16(struct device *dev,
-				   u8 reg_address, u16 *val)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7754_state *st = iio_priv(indio_dev);
-	int ret;
-
-	ret = spi_w8r16be(st->us, ADE7754_READ_REG(reg_address));
-	if (ret < 0) {
-		dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
-			reg_address);
-		return ret;
-	}
-
-	*val = ret;
-
-	return 0;
-}
-
-static int ade7754_spi_read_reg_24(struct device *dev,
-				   u8 reg_address, u32 *val)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7754_state *st = iio_priv(indio_dev);
-	int ret;
-	struct spi_transfer xfers[] = {
-		{
-			.tx_buf = st->tx,
-			.rx_buf = st->rx,
-			.bits_per_word = 8,
-			.len = 4,
-		},
-	};
-
-	mutex_lock(&st->buf_lock);
-	st->tx[0] = ADE7754_READ_REG(reg_address);
-	st->tx[1] = 0;
-	st->tx[2] = 0;
-	st->tx[3] = 0;
-
-	ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
-	if (ret) {
-		dev_err(&st->us->dev, "problem when reading 24 bit register 0x%02X",
-			reg_address);
-		goto error_ret;
-	}
-	*val = (st->rx[1] << 16) | (st->rx[2] << 8) | st->rx[3];
-
-error_ret:
-	mutex_unlock(&st->buf_lock);
-	return ret;
-}
-
-static ssize_t ade7754_read_8bit(struct device *dev,
-				 struct device_attribute *attr,
-				 char *buf)
-{
-	int ret;
-	u8 val = 0;
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-	ret = ade7754_spi_read_reg_8(dev, this_attr->address, &val);
-	if (ret)
-		return ret;
-
-	return sprintf(buf, "%u\n", val);
-}
-
-static ssize_t ade7754_read_16bit(struct device *dev,
-				  struct device_attribute *attr,
-				  char *buf)
-{
-	int ret;
-	u16 val = 0;
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-	ret = ade7754_spi_read_reg_16(dev, this_attr->address, &val);
-	if (ret)
-		return ret;
-
-	return sprintf(buf, "%u\n", val);
-}
-
-static ssize_t ade7754_read_24bit(struct device *dev,
-				  struct device_attribute *attr,
-				  char *buf)
-{
-	int ret;
-	u32 val = 0;
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-	ret = ade7754_spi_read_reg_24(dev, this_attr->address, &val);
-	if (ret)
-		return ret;
-
-	return sprintf(buf, "%u\n", val & 0xFFFFFF);
-}
-
-static ssize_t ade7754_write_8bit(struct device *dev,
-				  struct device_attribute *attr,
-				  const char *buf,
-				  size_t len)
-{
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-	int ret;
-	u8 val;
-
-	ret = kstrtou8(buf, 10, &val);
-	if (ret)
-		goto error_ret;
-	ret = ade7754_spi_write_reg_8(dev, this_attr->address, val);
-
-error_ret:
-	return ret ? ret : len;
-}
-
-static ssize_t ade7754_write_16bit(struct device *dev,
-				   struct device_attribute *attr,
-				   const char *buf,
-				   size_t len)
-{
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-	int ret;
-	u16 val;
-
-	ret = kstrtou16(buf, 10, &val);
-	if (ret)
-		goto error_ret;
-	ret = ade7754_spi_write_reg_16(dev, this_attr->address, val);
-
-error_ret:
-	return ret ? ret : len;
-}
-
-static int ade7754_reset(struct device *dev)
-{
-	int ret;
-	u8 val;
-
-	ret = ade7754_spi_read_reg_8(dev, ADE7754_OPMODE, &val);
-	if (ret < 0)
-		return ret;
-
-	val |= BIT(6); /* Software Chip Reset */
-	return ade7754_spi_write_reg_8(dev, ADE7754_OPMODE, val);
-}
-
-static IIO_DEV_ATTR_AENERGY(ade7754_read_24bit, ADE7754_AENERGY);
-static IIO_DEV_ATTR_LAENERGY(ade7754_read_24bit, ADE7754_LAENERGY);
-static IIO_DEV_ATTR_VAENERGY(ade7754_read_24bit, ADE7754_VAENERGY);
-static IIO_DEV_ATTR_LVAENERGY(ade7754_read_24bit, ADE7754_LVAENERGY);
-static IIO_DEV_ATTR_VPEAK(0644,
-		ade7754_read_8bit,
-		ade7754_write_8bit,
-		ADE7754_VPEAK);
-static IIO_DEV_ATTR_IPEAK(0644,
-		ade7754_read_8bit,
-		ade7754_write_8bit,
-		ADE7754_VPEAK);
-static IIO_DEV_ATTR_APHCAL(0644,
-		ade7754_read_8bit,
-		ade7754_write_8bit,
-		ADE7754_APHCAL);
-static IIO_DEV_ATTR_BPHCAL(0644,
-		ade7754_read_8bit,
-		ade7754_write_8bit,
-		ADE7754_BPHCAL);
-static IIO_DEV_ATTR_CPHCAL(0644,
-		ade7754_read_8bit,
-		ade7754_write_8bit,
-		ADE7754_CPHCAL);
-static IIO_DEV_ATTR_AAPOS(0644,
-		ade7754_read_16bit,
-		ade7754_write_16bit,
-		ADE7754_AAPOS);
-static IIO_DEV_ATTR_BAPOS(0644,
-		ade7754_read_16bit,
-		ade7754_write_16bit,
-		ADE7754_BAPOS);
-static IIO_DEV_ATTR_CAPOS(0644,
-		ade7754_read_16bit,
-		ade7754_write_16bit,
-		ADE7754_CAPOS);
-static IIO_DEV_ATTR_WDIV(0644,
-		ade7754_read_8bit,
-		ade7754_write_8bit,
-		ADE7754_WDIV);
-static IIO_DEV_ATTR_VADIV(0644,
-		ade7754_read_8bit,
-		ade7754_write_8bit,
-		ADE7754_VADIV);
-static IIO_DEV_ATTR_CFNUM(0644,
-		ade7754_read_16bit,
-		ade7754_write_16bit,
-		ADE7754_CFNUM);
-static IIO_DEV_ATTR_CFDEN(0644,
-		ade7754_read_16bit,
-		ade7754_write_16bit,
-		ADE7754_CFDEN);
-static IIO_DEV_ATTR_ACTIVE_POWER_A_GAIN(0644,
-		ade7754_read_16bit,
-		ade7754_write_16bit,
-		ADE7754_AAPGAIN);
-static IIO_DEV_ATTR_ACTIVE_POWER_B_GAIN(0644,
-		ade7754_read_16bit,
-		ade7754_write_16bit,
-		ADE7754_BAPGAIN);
-static IIO_DEV_ATTR_ACTIVE_POWER_C_GAIN(0644,
-		ade7754_read_16bit,
-		ade7754_write_16bit,
-		ADE7754_CAPGAIN);
-static IIO_DEV_ATTR_AIRMS(0444,
-		ade7754_read_24bit,
-		NULL,
-		ADE7754_AIRMS);
-static IIO_DEV_ATTR_BIRMS(0444,
-		ade7754_read_24bit,
-		NULL,
-		ADE7754_BIRMS);
-static IIO_DEV_ATTR_CIRMS(0444,
-		ade7754_read_24bit,
-		NULL,
-		ADE7754_CIRMS);
-static IIO_DEV_ATTR_AVRMS(0444,
-		ade7754_read_24bit,
-		NULL,
-		ADE7754_AVRMS);
-static IIO_DEV_ATTR_BVRMS(0444,
-		ade7754_read_24bit,
-		NULL,
-		ADE7754_BVRMS);
-static IIO_DEV_ATTR_CVRMS(0444,
-		ade7754_read_24bit,
-		NULL,
-		ADE7754_CVRMS);
-static IIO_DEV_ATTR_AIRMSOS(0444,
-		ade7754_read_16bit,
-		ade7754_write_16bit,
-		ADE7754_AIRMSOS);
-static IIO_DEV_ATTR_BIRMSOS(0444,
-		ade7754_read_16bit,
-		ade7754_write_16bit,
-		ADE7754_BIRMSOS);
-static IIO_DEV_ATTR_CIRMSOS(0444,
-		ade7754_read_16bit,
-		ade7754_write_16bit,
-		ADE7754_CIRMSOS);
-static IIO_DEV_ATTR_AVRMSOS(0444,
-		ade7754_read_16bit,
-		ade7754_write_16bit,
-		ADE7754_AVRMSOS);
-static IIO_DEV_ATTR_BVRMSOS(0444,
-		ade7754_read_16bit,
-		ade7754_write_16bit,
-		ADE7754_BVRMSOS);
-static IIO_DEV_ATTR_CVRMSOS(0444,
-		ade7754_read_16bit,
-		ade7754_write_16bit,
-		ADE7754_CVRMSOS);
-
-static int ade7754_set_irq(struct device *dev, bool enable)
-{
-	int ret;
-	u16 irqen;
-
-	ret = ade7754_spi_read_reg_16(dev, ADE7754_IRQEN, &irqen);
-	if (ret)
-		return ret;
-
-	if (enable)
-		irqen |= BIT(14); /* Enables an interrupt when a data is
-				   * present in the waveform register
-				   */
-	else
-		irqen &= ~BIT(14);
-
-	return ade7754_spi_write_reg_16(dev, ADE7754_IRQEN, irqen);
-}
-
-/* Power down the device */
-static int ade7754_stop_device(struct device *dev)
-{
-	int ret;
-	u8 val;
-
-	ret = ade7754_spi_read_reg_8(dev, ADE7754_OPMODE, &val);
-	if (ret < 0) {
-		dev_err(dev, "unable to power down the device, error: %d",
-			ret);
-		return ret;
-	}
-
-	val |= 7 << 3;  /* ADE7754 powered down */
-	return ade7754_spi_write_reg_8(dev, ADE7754_OPMODE, val);
-}
-
-static int ade7754_initial_setup(struct iio_dev *indio_dev)
-{
-	int ret;
-	struct ade7754_state *st = iio_priv(indio_dev);
-	struct device *dev = &indio_dev->dev;
-
-	/* use low spi speed for init */
-	st->us->mode = SPI_MODE_3;
-	spi_setup(st->us);
-
-	/* Disable IRQ */
-	ret = ade7754_set_irq(dev, false);
-	if (ret) {
-		dev_err(dev, "disable irq failed");
-		goto err_ret;
-	}
-
-	ade7754_reset(dev);
-	usleep_range(ADE7754_STARTUP_DELAY, ADE7754_STARTUP_DELAY + 100);
-
-err_ret:
-	return ret;
-}
-
-static ssize_t ade7754_read_frequency(struct device *dev,
-				      struct device_attribute *attr,
-				      char *buf)
-{
-	int ret;
-	u8 t;
-	int sps;
-
-	ret = ade7754_spi_read_reg_8(dev, ADE7754_WAVMODE, &t);
-	if (ret)
-		return ret;
-
-	t = (t >> 3) & 0x3;
-	sps = 26000 / (1 + t);
-
-	return sprintf(buf, "%d\n", sps);
-}
-
-static ssize_t ade7754_write_frequency(struct device *dev,
-				       struct device_attribute *attr,
-				       const char *buf,
-				       size_t len)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7754_state *st = iio_priv(indio_dev);
-	u16 val;
-	int ret;
-	u8 reg, t;
-
-	ret = kstrtou16(buf, 10, &val);
-	if (ret)
-		return ret;
-	if (!val)
-		return -EINVAL;
-
-	mutex_lock(&st->buf_lock);
-
-	t = 26000 / val;
-	if (t > 0)
-		t--;
-
-	if (t > 1)
-		st->us->max_speed_hz = ADE7754_SPI_SLOW;
-	else
-		st->us->max_speed_hz = ADE7754_SPI_FAST;
-
-	ret = ade7754_spi_read_reg_8(dev, ADE7754_WAVMODE, &reg);
-	if (ret)
-		goto out;
-
-	reg &= ~(3 << 3);
-	reg |= t << 3;
-
-	ret = __ade7754_spi_write_reg_8(dev, ADE7754_WAVMODE, reg);
-
-out:
-	mutex_unlock(&st->buf_lock);
-
-	return ret ? ret : len;
-}
-static IIO_DEV_ATTR_TEMP_RAW(ade7754_read_8bit);
-static IIO_CONST_ATTR(in_temp_offset, "129 C");
-static IIO_CONST_ATTR(in_temp_scale, "4 C");
-
-static IIO_DEV_ATTR_SAMP_FREQ(0644,
-		ade7754_read_frequency,
-		ade7754_write_frequency);
-
-static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("26000 13000 65000 33000");
-
-static struct attribute *ade7754_attributes[] = {
-	&iio_dev_attr_in_temp_raw.dev_attr.attr,
-	&iio_const_attr_in_temp_offset.dev_attr.attr,
-	&iio_const_attr_in_temp_scale.dev_attr.attr,
-	&iio_dev_attr_sampling_frequency.dev_attr.attr,
-	&iio_const_attr_sampling_frequency_available.dev_attr.attr,
-	&iio_dev_attr_aenergy.dev_attr.attr,
-	&iio_dev_attr_laenergy.dev_attr.attr,
-	&iio_dev_attr_vaenergy.dev_attr.attr,
-	&iio_dev_attr_lvaenergy.dev_attr.attr,
-	&iio_dev_attr_vpeak.dev_attr.attr,
-	&iio_dev_attr_ipeak.dev_attr.attr,
-	&iio_dev_attr_aphcal.dev_attr.attr,
-	&iio_dev_attr_bphcal.dev_attr.attr,
-	&iio_dev_attr_cphcal.dev_attr.attr,
-	&iio_dev_attr_aapos.dev_attr.attr,
-	&iio_dev_attr_bapos.dev_attr.attr,
-	&iio_dev_attr_capos.dev_attr.attr,
-	&iio_dev_attr_wdiv.dev_attr.attr,
-	&iio_dev_attr_vadiv.dev_attr.attr,
-	&iio_dev_attr_cfnum.dev_attr.attr,
-	&iio_dev_attr_cfden.dev_attr.attr,
-	&iio_dev_attr_active_power_a_gain.dev_attr.attr,
-	&iio_dev_attr_active_power_b_gain.dev_attr.attr,
-	&iio_dev_attr_active_power_c_gain.dev_attr.attr,
-	&iio_dev_attr_airms.dev_attr.attr,
-	&iio_dev_attr_birms.dev_attr.attr,
-	&iio_dev_attr_cirms.dev_attr.attr,
-	&iio_dev_attr_avrms.dev_attr.attr,
-	&iio_dev_attr_bvrms.dev_attr.attr,
-	&iio_dev_attr_cvrms.dev_attr.attr,
-	&iio_dev_attr_airmsos.dev_attr.attr,
-	&iio_dev_attr_birmsos.dev_attr.attr,
-	&iio_dev_attr_cirmsos.dev_attr.attr,
-	&iio_dev_attr_avrmsos.dev_attr.attr,
-	&iio_dev_attr_bvrmsos.dev_attr.attr,
-	&iio_dev_attr_cvrmsos.dev_attr.attr,
-	NULL,
-};
-
-static const struct attribute_group ade7754_attribute_group = {
-	.attrs = ade7754_attributes,
-};
-
-static const struct iio_info ade7754_info = {
-	.attrs = &ade7754_attribute_group,
-};
-
-static int ade7754_probe(struct spi_device *spi)
-{
-	int ret;
-	struct ade7754_state *st;
-	struct iio_dev *indio_dev;
-
-	/* setup the industrialio driver allocated elements */
-	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
-	if (!indio_dev)
-		return -ENOMEM;
-	/* this is only used for removal purposes */
-	spi_set_drvdata(spi, indio_dev);
-
-	st = iio_priv(indio_dev);
-	st->us = spi;
-	mutex_init(&st->buf_lock);
-
-	indio_dev->name = spi->dev.driver->name;
-	indio_dev->dev.parent = &spi->dev;
-	indio_dev->info = &ade7754_info;
-	indio_dev->modes = INDIO_DIRECT_MODE;
-
-	/* Get the device into a sane initial state */
-	ret = ade7754_initial_setup(indio_dev);
-	if (ret)
-		goto powerdown_on_error;
-	ret = iio_device_register(indio_dev);
-	if (ret)
-		goto powerdown_on_error;
-	return ret;
-
-powerdown_on_error:
-	ade7754_stop_device(&indio_dev->dev);
-	return ret;
-}
-
-static int ade7754_remove(struct spi_device *spi)
-{
-	struct iio_dev *indio_dev = spi_get_drvdata(spi);
-
-	iio_device_unregister(indio_dev);
-	ade7754_stop_device(&indio_dev->dev);
-
-	return 0;
-}
-
-static struct spi_driver ade7754_driver = {
-	.driver = {
-		.name = "ade7754",
-	},
-	.probe = ade7754_probe,
-	.remove = ade7754_remove,
-};
-module_spi_driver(ade7754_driver);
-
-MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
-MODULE_DESCRIPTION("Analog Devices ADE7754 Polyphase Multifunction Energy Metering IC Driver");
-MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("spi:ad7754");
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] staging:iio:meter: Drop ADE7758 driver
  2018-05-12 17:51 [PATCH 0/4] staging:iio: Drop 4 meter drivers Jonathan Cameron
  2018-05-12 17:51 ` [PATCH 1/4] staging:iio:meter: Drop ADE7753 driver Jonathan Cameron
  2018-05-12 17:51 ` [PATCH 2/4] staging:iio:meter: Drop ADE7754 driver Jonathan Cameron
@ 2018-05-12 17:51 ` Jonathan Cameron
  2018-05-20 11:22   ` Jonathan Cameron
  2018-05-12 17:51 ` [PATCH 4/4] staging:iio:meter: Drop ADE7759 driver Jonathan Cameron
  3 siblings, 1 reply; 9+ messages in thread
From: Jonathan Cameron @ 2018-05-12 17:51 UTC (permalink / raw)
  To: linux-iio
  Cc: Rodrigo Siqueira, John Syne, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Hartmut Knaack, Michael Hennerich,
	Jonathan Cameron

I announced the intent to drop some of these meter drivers
on the IIO list last cycle. This device is obsolete and not easily
obtained.  No one has come forward with suitable test hardware and
the driver would need a lot of work to move out of staging.

As such I am dropping it.  We can always bring it back again
if a user / tester emerges in the future.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/staging/iio/meter/Kconfig           |  12 -
 drivers/staging/iio/meter/Makefile          |   4 -
 drivers/staging/iio/meter/ade7758.h         | 183 ----
 drivers/staging/iio/meter/ade7758_core.c    | 955 --------------------
 drivers/staging/iio/meter/ade7758_ring.c    | 177 ----
 drivers/staging/iio/meter/ade7758_trigger.c | 108 ---
 6 files changed, 1439 deletions(-)

diff --git a/drivers/staging/iio/meter/Kconfig b/drivers/staging/iio/meter/Kconfig
index d60f052415c8..451ac47bb0cc 100644
--- a/drivers/staging/iio/meter/Kconfig
+++ b/drivers/staging/iio/meter/Kconfig
@@ -3,18 +3,6 @@
 #
 menu "Active energy metering IC"
 
-config ADE7758
-	tristate "Analog Devices ADE7758 Poly Phase Multifunction Energy Metering IC Driver"
-	depends on SPI
-	select IIO_TRIGGER if IIO_BUFFER
-	select IIO_KFIFO_BUF if IIO_BUFFER
-	help
-	  Say yes here to build support for Analog Devices ADE7758 Polyphase
-	  Multifunction Energy Metering IC with Per Phase Information Driver.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called ade7758.
-
 config ADE7759
 	tristate "Analog Devices ADE7759 Active Energy Metering IC Driver"
 	depends on SPI
diff --git a/drivers/staging/iio/meter/Makefile b/drivers/staging/iio/meter/Makefile
index 42f4157969de..a36ff1668275 100644
--- a/drivers/staging/iio/meter/Makefile
+++ b/drivers/staging/iio/meter/Makefile
@@ -3,10 +3,6 @@
 # Makefile for metering ic drivers
 #
 
-ade7758-y             := ade7758_core.o
-ade7758-$(CONFIG_IIO_BUFFER) += ade7758_ring.o ade7758_trigger.o
-obj-$(CONFIG_ADE7758) += ade7758.o
-
 obj-$(CONFIG_ADE7759) += ade7759.o
 obj-$(CONFIG_ADE7854) += ade7854.o
 obj-$(CONFIG_ADE7854_I2C) += ade7854-i2c.o
diff --git a/drivers/staging/iio/meter/ade7758.h b/drivers/staging/iio/meter/ade7758.h
deleted file mode 100644
index 2de81b53e786..000000000000
--- a/drivers/staging/iio/meter/ade7758.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * ADE7758 Poly Phase Multifunction Energy Metering IC driver
- *
- * Copyright 2010-2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#ifndef _ADE7758_H
-#define _ADE7758_H
-
-#define ADE7758_AWATTHR   0x01
-#define ADE7758_BWATTHR   0x02
-#define ADE7758_CWATTHR   0x03
-#define ADE7758_AVARHR    0x04
-#define ADE7758_BVARHR    0x05
-#define ADE7758_CVARHR    0x06
-#define ADE7758_AVAHR     0x07
-#define ADE7758_BVAHR     0x08
-#define ADE7758_CVAHR     0x09
-#define ADE7758_AIRMS     0x0A
-#define ADE7758_BIRMS     0x0B
-#define ADE7758_CIRMS     0x0C
-#define ADE7758_AVRMS     0x0D
-#define ADE7758_BVRMS     0x0E
-#define ADE7758_CVRMS     0x0F
-#define ADE7758_FREQ      0x10
-#define ADE7758_TEMP      0x11
-#define ADE7758_WFORM     0x12
-#define ADE7758_OPMODE    0x13
-#define ADE7758_MMODE     0x14
-#define ADE7758_WAVMODE   0x15
-#define ADE7758_COMPMODE  0x16
-#define ADE7758_LCYCMODE  0x17
-#define ADE7758_MASK      0x18
-#define ADE7758_STATUS    0x19
-#define ADE7758_RSTATUS   0x1A
-#define ADE7758_ZXTOUT    0x1B
-#define ADE7758_LINECYC   0x1C
-#define ADE7758_SAGCYC    0x1D
-#define ADE7758_SAGLVL    0x1E
-#define ADE7758_VPINTLVL  0x1F
-#define ADE7758_IPINTLVL  0x20
-#define ADE7758_VPEAK     0x21
-#define ADE7758_IPEAK     0x22
-#define ADE7758_GAIN      0x23
-#define ADE7758_AVRMSGAIN 0x24
-#define ADE7758_BVRMSGAIN 0x25
-#define ADE7758_CVRMSGAIN 0x26
-#define ADE7758_AIGAIN    0x27
-#define ADE7758_BIGAIN    0x28
-#define ADE7758_CIGAIN    0x29
-#define ADE7758_AWG       0x2A
-#define ADE7758_BWG       0x2B
-#define ADE7758_CWG       0x2C
-#define ADE7758_AVARG     0x2D
-#define ADE7758_BVARG     0x2E
-#define ADE7758_CVARG     0x2F
-#define ADE7758_AVAG      0x30
-#define ADE7758_BVAG      0x31
-#define ADE7758_CVAG      0x32
-#define ADE7758_AVRMSOS   0x33
-#define ADE7758_BVRMSOS   0x34
-#define ADE7758_CVRMSOS   0x35
-#define ADE7758_AIRMSOS   0x36
-#define ADE7758_BIRMSOS   0x37
-#define ADE7758_CIRMSOS   0x38
-#define ADE7758_AWAITOS   0x39
-#define ADE7758_BWAITOS   0x3A
-#define ADE7758_CWAITOS   0x3B
-#define ADE7758_AVAROS    0x3C
-#define ADE7758_BVAROS    0x3D
-#define ADE7758_CVAROS    0x3E
-#define ADE7758_APHCAL    0x3F
-#define ADE7758_BPHCAL    0x40
-#define ADE7758_CPHCAL    0x41
-#define ADE7758_WDIV      0x42
-#define ADE7758_VADIV     0x44
-#define ADE7758_VARDIV    0x43
-#define ADE7758_APCFNUM   0x45
-#define ADE7758_APCFDEN   0x46
-#define ADE7758_VARCFNUM  0x47
-#define ADE7758_VARCFDEN  0x48
-#define ADE7758_CHKSUM    0x7E
-#define ADE7758_VERSION   0x7F
-
-#define ADE7758_READ_REG(a)    a
-#define ADE7758_WRITE_REG(a) ((a) | 0x80)
-
-#define ADE7758_MAX_TX    8
-#define ADE7758_MAX_RX    4
-#define ADE7758_STARTUP_DELAY 1000
-
-#define AD7758_NUM_WAVSEL	5
-#define AD7758_NUM_PHSEL	3
-#define AD7758_NUM_WAVESRC	(AD7758_NUM_WAVSEL * AD7758_NUM_PHSEL)
-
-#define AD7758_PHASE_A		0
-#define AD7758_PHASE_B		1
-#define AD7758_PHASE_C		2
-#define AD7758_CURRENT		0
-#define AD7758_VOLTAGE		1
-#define AD7758_ACT_PWR		2
-#define AD7758_REACT_PWR	3
-#define AD7758_APP_PWR		4
-#define AD7758_WT(p, w)		(((w) << 2) | (p))
-
-/**
- * struct ade7758_state - device instance specific data
- * @us:			actual spi_device
- * @trig:		data ready trigger registered with iio
- * @tx:			transmit buffer
- * @rx:			receive buffer
- * @buf_lock:		mutex to protect tx, rx, read and write frequency
- **/
-struct ade7758_state {
-	struct spi_device	*us;
-	struct iio_trigger	*trig;
-	u8			*tx;
-	u8			*rx;
-	struct mutex		buf_lock;
-	struct spi_transfer	ring_xfer[4];
-	struct spi_message	ring_msg;
-	/*
-	 * DMA (thus cache coherency maintenance) requires the
-	 * transfer buffers to live in their own cache lines.
-	 */
-	unsigned char		rx_buf[8] ____cacheline_aligned;
-	unsigned char		tx_buf[8];
-
-};
-
-#ifdef CONFIG_IIO_BUFFER
-/* At the moment triggers are only used for ring buffer
- * filling. This may change!
- */
-
-void ade7758_remove_trigger(struct iio_dev *indio_dev);
-int ade7758_probe_trigger(struct iio_dev *indio_dev);
-
-ssize_t ade7758_read_data_from_ring(struct device *dev,
-				    struct device_attribute *attr, char *buf);
-
-int ade7758_configure_ring(struct iio_dev *indio_dev);
-void ade7758_unconfigure_ring(struct iio_dev *indio_dev);
-
-int ade7758_set_irq(struct device *dev, bool enable);
-
-int ade7758_spi_write_reg_8(struct device *dev, u8 reg_address, u8 val);
-int ade7758_spi_read_reg_8(struct device *dev, u8 reg_address, u8 *val);
-
-#else /* CONFIG_IIO_BUFFER */
-
-static inline void ade7758_remove_trigger(struct iio_dev *indio_dev)
-{
-}
-
-static inline int ade7758_probe_trigger(struct iio_dev *indio_dev)
-{
-	return 0;
-}
-
-static int ade7758_configure_ring(struct iio_dev *indio_dev)
-{
-	return 0;
-}
-
-static inline void ade7758_unconfigure_ring(struct iio_dev *indio_dev)
-{
-}
-
-static inline int ade7758_initialize_ring(struct iio_ring_buffer *ring)
-{
-	return 0;
-}
-
-static inline void ade7758_uninitialize_ring(struct iio_dev *indio_dev)
-{
-}
-
-#endif /* CONFIG_IIO_BUFFER */
-
-#endif
diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c
deleted file mode 100644
index 4e0dbf5c5705..000000000000
--- a/drivers/staging/iio/meter/ade7758_core.c
+++ /dev/null
@@ -1,955 +0,0 @@
-/*
- * ADE7758 Poly Phase Multifunction Energy Metering IC driver
- *
- * Copyright 2010-2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/delay.h>
-#include <linux/mutex.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/list.h>
-#include <linux/module.h>
-
-#include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
-#include <linux/iio/buffer.h>
-#include "meter.h"
-#include "ade7758.h"
-
-static int __ade7758_spi_write_reg_8(struct device *dev, u8 reg_address, u8 val)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7758_state *st = iio_priv(indio_dev);
-
-	st->tx[0] = ADE7758_WRITE_REG(reg_address);
-	st->tx[1] = val;
-
-	return spi_write(st->us, st->tx, 2);
-}
-
-int ade7758_spi_write_reg_8(struct device *dev, u8 reg_address, u8 val)
-{
-	int ret;
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7758_state *st = iio_priv(indio_dev);
-
-	mutex_lock(&st->buf_lock);
-	ret = __ade7758_spi_write_reg_8(dev, reg_address, val);
-	mutex_unlock(&st->buf_lock);
-
-	return ret;
-}
-
-static int ade7758_spi_write_reg_16(struct device *dev, u8 reg_address,
-				    u16 value)
-{
-	int ret;
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7758_state *st = iio_priv(indio_dev);
-	struct spi_transfer xfers[] = {
-		{
-			.tx_buf = st->tx,
-			.bits_per_word = 8,
-			.len = 3,
-		}
-	};
-
-	mutex_lock(&st->buf_lock);
-	st->tx[0] = ADE7758_WRITE_REG(reg_address);
-	st->tx[1] = (value >> 8) & 0xFF;
-	st->tx[2] = value & 0xFF;
-
-	ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
-	mutex_unlock(&st->buf_lock);
-
-	return ret;
-}
-
-static int ade7758_spi_write_reg_24(struct device *dev, u8 reg_address,
-				    u32 value)
-{
-	int ret;
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7758_state *st = iio_priv(indio_dev);
-	struct spi_transfer xfers[] = {
-		{
-			.tx_buf = st->tx,
-			.bits_per_word = 8,
-			.len = 4,
-		}
-	};
-
-	mutex_lock(&st->buf_lock);
-	st->tx[0] = ADE7758_WRITE_REG(reg_address);
-	st->tx[1] = (value >> 16) & 0xFF;
-	st->tx[2] = (value >> 8) & 0xFF;
-	st->tx[3] = value & 0xFF;
-
-	ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
-	mutex_unlock(&st->buf_lock);
-
-	return ret;
-}
-
-static int __ade7758_spi_read_reg_8(struct device *dev, u8 reg_address, u8 *val)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7758_state *st = iio_priv(indio_dev);
-	int ret;
-	struct spi_transfer xfers[] = {
-		{
-			.tx_buf = st->tx,
-			.bits_per_word = 8,
-			.len = 1,
-			.delay_usecs = 4,
-		},
-		{
-			.tx_buf = &st->tx[1],
-			.rx_buf = st->rx,
-			.bits_per_word = 8,
-			.len = 1,
-		},
-	};
-
-	st->tx[0] = ADE7758_READ_REG(reg_address);
-	st->tx[1] = 0;
-
-	ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
-	if (ret) {
-		dev_err(&st->us->dev, "problem when reading 8 bit register 0x%02X",
-			reg_address);
-		goto error_ret;
-	}
-	*val = st->rx[0];
-
-error_ret:
-	return ret;
-}
-
-int ade7758_spi_read_reg_8(struct device *dev, u8 reg_address, u8 *val)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7758_state *st = iio_priv(indio_dev);
-	int ret;
-
-	mutex_lock(&st->buf_lock);
-	ret = __ade7758_spi_read_reg_8(dev, reg_address, val);
-	mutex_unlock(&st->buf_lock);
-
-	return ret;
-}
-
-static int ade7758_spi_read_reg_16(struct device *dev, u8 reg_address,
-				   u16 *val)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7758_state *st = iio_priv(indio_dev);
-	int ret;
-	struct spi_transfer xfers[] = {
-		{
-			.tx_buf = st->tx,
-			.bits_per_word = 8,
-			.len = 1,
-			.delay_usecs = 4,
-		},
-		{
-			.tx_buf = &st->tx[1],
-			.rx_buf = st->rx,
-			.bits_per_word = 8,
-			.len = 2,
-		},
-	};
-
-	mutex_lock(&st->buf_lock);
-	st->tx[0] = ADE7758_READ_REG(reg_address);
-	st->tx[1] = 0;
-	st->tx[2] = 0;
-
-	ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
-	if (ret) {
-		dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
-			reg_address);
-		goto error_ret;
-	}
-
-	*val = (st->rx[0] << 8) | st->rx[1];
-
-error_ret:
-	mutex_unlock(&st->buf_lock);
-	return ret;
-}
-
-static int ade7758_spi_read_reg_24(struct device *dev, u8 reg_address,
-				   u32 *val)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7758_state *st = iio_priv(indio_dev);
-	int ret;
-	struct spi_transfer xfers[] = {
-		{
-			.tx_buf = st->tx,
-			.bits_per_word = 8,
-			.len = 1,
-			.delay_usecs = 4,
-		},
-		{
-			.tx_buf = &st->tx[1],
-			.rx_buf = st->rx,
-			.bits_per_word = 8,
-			.len = 3,
-		},
-	};
-
-	mutex_lock(&st->buf_lock);
-	st->tx[0] = ADE7758_READ_REG(reg_address);
-	st->tx[1] = 0;
-	st->tx[2] = 0;
-	st->tx[3] = 0;
-
-	ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
-	if (ret) {
-		dev_err(&st->us->dev, "problem when reading 24 bit register 0x%02X",
-			reg_address);
-		goto error_ret;
-	}
-	*val = (st->rx[0] << 16) | (st->rx[1] << 8) | st->rx[2];
-
-error_ret:
-	mutex_unlock(&st->buf_lock);
-	return ret;
-}
-
-static ssize_t ade7758_read_8bit(struct device *dev,
-				 struct device_attribute *attr, char *buf)
-{
-	int ret;
-	u8 val = 0;
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-	ret = ade7758_spi_read_reg_8(dev, this_attr->address, &val);
-	if (ret)
-		return ret;
-
-	return sprintf(buf, "%u\n", val);
-}
-
-static ssize_t ade7758_read_16bit(struct device *dev,
-				  struct device_attribute *attr, char *buf)
-{
-	int ret;
-	u16 val = 0;
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-	ret = ade7758_spi_read_reg_16(dev, this_attr->address, &val);
-	if (ret)
-		return ret;
-
-	return sprintf(buf, "%u\n", val);
-}
-
-static ssize_t ade7758_read_24bit(struct device *dev,
-				  struct device_attribute *attr, char *buf)
-{
-	int ret;
-	u32 val = 0;
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-	ret = ade7758_spi_read_reg_24(dev, this_attr->address, &val);
-	if (ret)
-		return ret;
-
-	return sprintf(buf, "%u\n", val & 0xFFFFFF);
-}
-
-static ssize_t ade7758_write_8bit(struct device *dev,
-				  struct device_attribute *attr,
-				  const char *buf, size_t len)
-{
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-	int ret;
-	u8 val;
-
-	ret = kstrtou8(buf, 10, &val);
-	if (ret)
-		goto error_ret;
-	ret = ade7758_spi_write_reg_8(dev, this_attr->address, val);
-
-error_ret:
-	return ret ? ret : len;
-}
-
-static ssize_t ade7758_write_16bit(struct device *dev,
-				   struct device_attribute *attr,
-				   const char *buf, size_t len)
-{
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-	int ret;
-	u16 val;
-
-	ret = kstrtou16(buf, 10, &val);
-	if (ret)
-		goto error_ret;
-	ret = ade7758_spi_write_reg_16(dev, this_attr->address, val);
-
-error_ret:
-	return ret ? ret : len;
-}
-
-static int ade7758_reset(struct device *dev)
-{
-	int ret;
-	u8 val;
-
-	ret = ade7758_spi_read_reg_8(dev, ADE7758_OPMODE, &val);
-	if (ret < 0) {
-		dev_err(dev, "Failed to read opmode reg\n");
-		return ret;
-	}
-	val |= BIT(6); /* Software Chip Reset */
-	ret = ade7758_spi_write_reg_8(dev, ADE7758_OPMODE, val);
-	if (ret < 0)
-		dev_err(dev, "Failed to write opmode reg\n");
-	return ret;
-}
-
-static IIO_DEV_ATTR_VPEAK(0644,
-		ade7758_read_8bit,
-		ade7758_write_8bit,
-		ADE7758_VPEAK);
-static IIO_DEV_ATTR_IPEAK(0644,
-		ade7758_read_8bit,
-		ade7758_write_8bit,
-		ADE7758_VPEAK);
-static IIO_DEV_ATTR_APHCAL(0644,
-		ade7758_read_8bit,
-		ade7758_write_8bit,
-		ADE7758_APHCAL);
-static IIO_DEV_ATTR_BPHCAL(0644,
-		ade7758_read_8bit,
-		ade7758_write_8bit,
-		ADE7758_BPHCAL);
-static IIO_DEV_ATTR_CPHCAL(0644,
-		ade7758_read_8bit,
-		ade7758_write_8bit,
-		ADE7758_CPHCAL);
-static IIO_DEV_ATTR_WDIV(0644,
-		ade7758_read_8bit,
-		ade7758_write_8bit,
-		ADE7758_WDIV);
-static IIO_DEV_ATTR_VADIV(0644,
-		ade7758_read_8bit,
-		ade7758_write_8bit,
-		ADE7758_VADIV);
-static IIO_DEV_ATTR_AIRMS(0444,
-		ade7758_read_24bit,
-		NULL,
-		ADE7758_AIRMS);
-static IIO_DEV_ATTR_BIRMS(0444,
-		ade7758_read_24bit,
-		NULL,
-		ADE7758_BIRMS);
-static IIO_DEV_ATTR_CIRMS(0444,
-		ade7758_read_24bit,
-		NULL,
-		ADE7758_CIRMS);
-static IIO_DEV_ATTR_AVRMS(0444,
-		ade7758_read_24bit,
-		NULL,
-		ADE7758_AVRMS);
-static IIO_DEV_ATTR_BVRMS(0444,
-		ade7758_read_24bit,
-		NULL,
-		ADE7758_BVRMS);
-static IIO_DEV_ATTR_CVRMS(0444,
-		ade7758_read_24bit,
-		NULL,
-		ADE7758_CVRMS);
-static IIO_DEV_ATTR_AIRMSOS(0644,
-		ade7758_read_16bit,
-		ade7758_write_16bit,
-		ADE7758_AIRMSOS);
-static IIO_DEV_ATTR_BIRMSOS(0644,
-		ade7758_read_16bit,
-		ade7758_write_16bit,
-		ADE7758_BIRMSOS);
-static IIO_DEV_ATTR_CIRMSOS(0644,
-		ade7758_read_16bit,
-		ade7758_write_16bit,
-		ADE7758_CIRMSOS);
-static IIO_DEV_ATTR_AVRMSOS(0644,
-		ade7758_read_16bit,
-		ade7758_write_16bit,
-		ADE7758_AVRMSOS);
-static IIO_DEV_ATTR_BVRMSOS(0644,
-		ade7758_read_16bit,
-		ade7758_write_16bit,
-		ADE7758_BVRMSOS);
-static IIO_DEV_ATTR_CVRMSOS(0644,
-		ade7758_read_16bit,
-		ade7758_write_16bit,
-		ADE7758_CVRMSOS);
-static IIO_DEV_ATTR_AIGAIN(0644,
-		ade7758_read_16bit,
-		ade7758_write_16bit,
-		ADE7758_AIGAIN);
-static IIO_DEV_ATTR_BIGAIN(0644,
-		ade7758_read_16bit,
-		ade7758_write_16bit,
-		ADE7758_BIGAIN);
-static IIO_DEV_ATTR_CIGAIN(0644,
-		ade7758_read_16bit,
-		ade7758_write_16bit,
-		ADE7758_CIGAIN);
-static IIO_DEV_ATTR_AVRMSGAIN(0644,
-		ade7758_read_16bit,
-		ade7758_write_16bit,
-		ADE7758_AVRMSGAIN);
-static IIO_DEV_ATTR_BVRMSGAIN(0644,
-		ade7758_read_16bit,
-		ade7758_write_16bit,
-		ADE7758_BVRMSGAIN);
-static IIO_DEV_ATTR_CVRMSGAIN(0644,
-		ade7758_read_16bit,
-		ade7758_write_16bit,
-		ADE7758_CVRMSGAIN);
-
-int ade7758_set_irq(struct device *dev, bool enable)
-{
-	int ret;
-	u32 irqen;
-
-	ret = ade7758_spi_read_reg_24(dev, ADE7758_MASK, &irqen);
-	if (ret)
-		return ret;
-
-	if (enable)
-		irqen |= BIT(16); /* Enables an interrupt when a data is
-				   * present in the waveform register
-				   */
-	else
-		irqen &= ~BIT(16);
-
-	ret = ade7758_spi_write_reg_24(dev, ADE7758_MASK, irqen);
-
-	return ret;
-}
-
-/* Power down the device */
-static int ade7758_stop_device(struct device *dev)
-{
-	int ret;
-	u8 val;
-
-	ret = ade7758_spi_read_reg_8(dev, ADE7758_OPMODE, &val);
-	if (ret < 0) {
-		dev_err(dev, "Failed to read opmode reg\n");
-		return ret;
-	}
-	val |= 7 << 3;  /* ADE7758 powered down */
-	ret = ade7758_spi_write_reg_8(dev, ADE7758_OPMODE, val);
-	if (ret < 0)
-		dev_err(dev, "Failed to write opmode reg\n");
-	return ret;
-}
-
-static int ade7758_initial_setup(struct iio_dev *indio_dev)
-{
-	struct ade7758_state *st = iio_priv(indio_dev);
-	struct device *dev = &indio_dev->dev;
-	int ret;
-
-	/* use low spi speed for init */
-	st->us->mode = SPI_MODE_1;
-	spi_setup(st->us);
-
-	/* Disable IRQ */
-	ret = ade7758_set_irq(dev, false);
-	if (ret) {
-		dev_err(dev, "disable irq failed");
-		goto err_ret;
-	}
-
-	ade7758_reset(dev);
-	usleep_range(ADE7758_STARTUP_DELAY, ADE7758_STARTUP_DELAY + 100);
-
-err_ret:
-	return ret;
-}
-
-static int ade7758_read_samp_freq(struct device *dev, int *val)
-{
-	int ret;
-	u8 t;
-
-	ret = ade7758_spi_read_reg_8(dev, ADE7758_WAVMODE, &t);
-	if (ret)
-		return ret;
-
-	t = (t >> 5) & 0x3;
-	*val = 26040 / (1 << t);
-
-	return 0;
-}
-
-static int ade7758_write_samp_freq(struct device *dev, int val)
-{
-	int ret;
-	u8 reg, t;
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7758_state *st = iio_priv(indio_dev);
-
-	switch (val) {
-	case 26040:
-		t = 0;
-		break;
-	case 13020:
-		t = 1;
-		break;
-	case 6510:
-		t = 2;
-		break;
-	case 3255:
-		t = 3;
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	mutex_lock(&st->buf_lock);
-
-	ret = __ade7758_spi_read_reg_8(dev, ADE7758_WAVMODE, &reg);
-	if (ret)
-		goto out;
-
-	reg &= ~(5 << 3);
-	reg |= t << 5;
-
-	ret = __ade7758_spi_write_reg_8(dev, ADE7758_WAVMODE, reg);
-
-out:
-	mutex_unlock(&st->buf_lock);
-
-	return ret;
-}
-
-static int ade7758_read_raw(struct iio_dev *indio_dev,
-			    struct iio_chan_spec const *chan,
-			    int *val,
-			    int *val2,
-			    long mask)
-{
-	int ret;
-
-	switch (mask) {
-	case IIO_CHAN_INFO_SAMP_FREQ:
-
-		ret = ade7758_read_samp_freq(&indio_dev->dev, val);
-
-		return ret;
-	default:
-		return -EINVAL;
-	}
-
-	return ret;
-}
-
-static int ade7758_write_raw(struct iio_dev *indio_dev,
-			     struct iio_chan_spec const *chan,
-			     int val, int val2, long mask)
-{
-	int ret;
-
-	switch (mask) {
-	case IIO_CHAN_INFO_SAMP_FREQ:
-		if (val2)
-			return -EINVAL;
-
-		ret = ade7758_write_samp_freq(&indio_dev->dev, val);
-
-		return ret;
-	default:
-		return -EINVAL;
-	}
-
-	return ret;
-}
-
-static IIO_DEV_ATTR_TEMP_RAW(ade7758_read_8bit);
-static IIO_CONST_ATTR(in_temp_offset, "129 C");
-static IIO_CONST_ATTR(in_temp_scale, "4 C");
-
-static IIO_DEV_ATTR_AWATTHR(ade7758_read_16bit,
-		ADE7758_AWATTHR);
-static IIO_DEV_ATTR_BWATTHR(ade7758_read_16bit,
-		ADE7758_BWATTHR);
-static IIO_DEV_ATTR_CWATTHR(ade7758_read_16bit,
-		ADE7758_CWATTHR);
-static IIO_DEV_ATTR_AVARHR(ade7758_read_16bit,
-		ADE7758_AVARHR);
-static IIO_DEV_ATTR_BVARHR(ade7758_read_16bit,
-		ADE7758_BVARHR);
-static IIO_DEV_ATTR_CVARHR(ade7758_read_16bit,
-		ADE7758_CVARHR);
-static IIO_DEV_ATTR_AVAHR(ade7758_read_16bit,
-		ADE7758_AVAHR);
-static IIO_DEV_ATTR_BVAHR(ade7758_read_16bit,
-		ADE7758_BVAHR);
-static IIO_DEV_ATTR_CVAHR(ade7758_read_16bit,
-		ADE7758_CVAHR);
-
-static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("26040 13020 6510 3255");
-
-static struct attribute *ade7758_attributes[] = {
-	&iio_dev_attr_in_temp_raw.dev_attr.attr,
-	&iio_const_attr_in_temp_offset.dev_attr.attr,
-	&iio_const_attr_in_temp_scale.dev_attr.attr,
-	&iio_const_attr_sampling_frequency_available.dev_attr.attr,
-	&iio_dev_attr_awatthr.dev_attr.attr,
-	&iio_dev_attr_bwatthr.dev_attr.attr,
-	&iio_dev_attr_cwatthr.dev_attr.attr,
-	&iio_dev_attr_avarhr.dev_attr.attr,
-	&iio_dev_attr_bvarhr.dev_attr.attr,
-	&iio_dev_attr_cvarhr.dev_attr.attr,
-	&iio_dev_attr_avahr.dev_attr.attr,
-	&iio_dev_attr_bvahr.dev_attr.attr,
-	&iio_dev_attr_cvahr.dev_attr.attr,
-	&iio_dev_attr_vpeak.dev_attr.attr,
-	&iio_dev_attr_ipeak.dev_attr.attr,
-	&iio_dev_attr_aphcal.dev_attr.attr,
-	&iio_dev_attr_bphcal.dev_attr.attr,
-	&iio_dev_attr_cphcal.dev_attr.attr,
-	&iio_dev_attr_wdiv.dev_attr.attr,
-	&iio_dev_attr_vadiv.dev_attr.attr,
-	&iio_dev_attr_airms.dev_attr.attr,
-	&iio_dev_attr_birms.dev_attr.attr,
-	&iio_dev_attr_cirms.dev_attr.attr,
-	&iio_dev_attr_avrms.dev_attr.attr,
-	&iio_dev_attr_bvrms.dev_attr.attr,
-	&iio_dev_attr_cvrms.dev_attr.attr,
-	&iio_dev_attr_aigain.dev_attr.attr,
-	&iio_dev_attr_bigain.dev_attr.attr,
-	&iio_dev_attr_cigain.dev_attr.attr,
-	&iio_dev_attr_avrmsgain.dev_attr.attr,
-	&iio_dev_attr_bvrmsgain.dev_attr.attr,
-	&iio_dev_attr_cvrmsgain.dev_attr.attr,
-	&iio_dev_attr_airmsos.dev_attr.attr,
-	&iio_dev_attr_birmsos.dev_attr.attr,
-	&iio_dev_attr_cirmsos.dev_attr.attr,
-	&iio_dev_attr_avrmsos.dev_attr.attr,
-	&iio_dev_attr_bvrmsos.dev_attr.attr,
-	&iio_dev_attr_cvrmsos.dev_attr.attr,
-	NULL,
-};
-
-static const struct attribute_group ade7758_attribute_group = {
-	.attrs = ade7758_attributes,
-};
-
-static const struct iio_chan_spec ade7758_channels[] = {
-	{
-		.type = IIO_VOLTAGE,
-		.indexed = 1,
-		.channel = 0,
-		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
-		.address = AD7758_WT(AD7758_PHASE_A, AD7758_VOLTAGE),
-		.scan_index = 0,
-		.scan_type = {
-			.sign = 's',
-			.realbits = 24,
-			.storagebits = 32,
-		},
-	}, {
-		.type = IIO_CURRENT,
-		.indexed = 1,
-		.channel = 0,
-		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
-		.address = AD7758_WT(AD7758_PHASE_A, AD7758_CURRENT),
-		.scan_index = 1,
-		.scan_type = {
-			.sign = 's',
-			.realbits = 24,
-			.storagebits = 32,
-		},
-	}, {
-		.type = IIO_POWER,
-		.indexed = 1,
-		.channel = 0,
-		.extend_name = "apparent",
-		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
-		.address = AD7758_WT(AD7758_PHASE_A, AD7758_APP_PWR),
-		.scan_index = 2,
-		.scan_type = {
-			.sign = 's',
-			.realbits = 24,
-			.storagebits = 32,
-		},
-	}, {
-		.type = IIO_POWER,
-		.indexed = 1,
-		.channel = 0,
-		.extend_name = "active",
-		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
-		.address = AD7758_WT(AD7758_PHASE_A, AD7758_ACT_PWR),
-		.scan_index = 3,
-		.scan_type = {
-			.sign = 's',
-			.realbits = 24,
-			.storagebits = 32,
-		},
-	}, {
-		.type = IIO_POWER,
-		.indexed = 1,
-		.channel = 0,
-		.extend_name = "reactive",
-		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
-		.address = AD7758_WT(AD7758_PHASE_A, AD7758_REACT_PWR),
-		.scan_index = 4,
-		.scan_type = {
-			.sign = 's',
-			.realbits = 24,
-			.storagebits = 32,
-		},
-	}, {
-		.type = IIO_VOLTAGE,
-		.indexed = 1,
-		.channel = 1,
-		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
-		.address = AD7758_WT(AD7758_PHASE_B, AD7758_VOLTAGE),
-		.scan_index = 5,
-		.scan_type = {
-			.sign = 's',
-			.realbits = 24,
-			.storagebits = 32,
-		},
-	}, {
-		.type = IIO_CURRENT,
-		.indexed = 1,
-		.channel = 1,
-		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
-		.address = AD7758_WT(AD7758_PHASE_B, AD7758_CURRENT),
-		.scan_index = 6,
-		.scan_type = {
-			.sign = 's',
-			.realbits = 24,
-			.storagebits = 32,
-		},
-	}, {
-		.type = IIO_POWER,
-		.indexed = 1,
-		.channel = 1,
-		.extend_name = "apparent",
-		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
-		.address = AD7758_WT(AD7758_PHASE_B, AD7758_APP_PWR),
-		.scan_index = 7,
-		.scan_type = {
-			.sign = 's',
-			.realbits = 24,
-			.storagebits = 32,
-		},
-	}, {
-		.type = IIO_POWER,
-		.indexed = 1,
-		.channel = 1,
-		.extend_name = "active",
-		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
-		.address = AD7758_WT(AD7758_PHASE_B, AD7758_ACT_PWR),
-		.scan_index = 8,
-		.scan_type = {
-			.sign = 's',
-			.realbits = 24,
-			.storagebits = 32,
-		},
-	}, {
-		.type = IIO_POWER,
-		.indexed = 1,
-		.channel = 1,
-		.extend_name = "reactive",
-		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
-		.address = AD7758_WT(AD7758_PHASE_B, AD7758_REACT_PWR),
-		.scan_index = 9,
-		.scan_type = {
-			.sign = 's',
-			.realbits = 24,
-			.storagebits = 32,
-		},
-	}, {
-		.type = IIO_VOLTAGE,
-		.indexed = 1,
-		.channel = 2,
-		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
-		.address = AD7758_WT(AD7758_PHASE_C, AD7758_VOLTAGE),
-		.scan_index = 10,
-		.scan_type = {
-			.sign = 's',
-			.realbits = 24,
-			.storagebits = 32,
-		},
-	}, {
-		.type = IIO_CURRENT,
-		.indexed = 1,
-		.channel = 2,
-		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
-		.address = AD7758_WT(AD7758_PHASE_C, AD7758_CURRENT),
-		.scan_index = 11,
-		.scan_type = {
-			.sign = 's',
-			.realbits = 24,
-			.storagebits = 32,
-		},
-	}, {
-		.type = IIO_POWER,
-		.indexed = 1,
-		.channel = 2,
-		.extend_name = "apparent",
-		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
-		.address = AD7758_WT(AD7758_PHASE_C, AD7758_APP_PWR),
-		.scan_index = 12,
-		.scan_type = {
-			.sign = 's',
-			.realbits = 24,
-			.storagebits = 32,
-		},
-	}, {
-		.type = IIO_POWER,
-		.indexed = 1,
-		.channel = 2,
-		.extend_name = "active",
-		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
-		.address = AD7758_WT(AD7758_PHASE_C, AD7758_ACT_PWR),
-		.scan_index = 13,
-		.scan_type = {
-			.sign = 's',
-			.realbits = 24,
-			.storagebits = 32,
-		},
-	}, {
-		.type = IIO_POWER,
-		.indexed = 1,
-		.channel = 2,
-		.extend_name = "reactive",
-		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
-		.address = AD7758_WT(AD7758_PHASE_C, AD7758_REACT_PWR),
-		.scan_index = 14,
-		.scan_type = {
-			.sign = 's',
-			.realbits = 24,
-			.storagebits = 32,
-		},
-	},
-	IIO_CHAN_SOFT_TIMESTAMP(15),
-};
-
-static const struct iio_info ade7758_info = {
-	.attrs = &ade7758_attribute_group,
-	.read_raw = &ade7758_read_raw,
-	.write_raw = &ade7758_write_raw,
-};
-
-static int ade7758_probe(struct spi_device *spi)
-{
-	int ret;
-	struct ade7758_state *st;
-	struct iio_dev *indio_dev;
-
-	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
-	if (!indio_dev)
-		return -ENOMEM;
-
-	st = iio_priv(indio_dev);
-	/* this is only used for removal purposes */
-	spi_set_drvdata(spi, indio_dev);
-
-	/* Allocate the comms buffers */
-	st->rx = kcalloc(ADE7758_MAX_RX, sizeof(*st->rx), GFP_KERNEL);
-	if (!st->rx)
-		return -ENOMEM;
-	st->tx = kcalloc(ADE7758_MAX_TX, sizeof(*st->tx), GFP_KERNEL);
-	if (!st->tx) {
-		ret = -ENOMEM;
-		goto error_free_rx;
-	}
-	st->us = spi;
-	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;
-
-	/* Get the device into a sane initial state */
-	ret = ade7758_initial_setup(indio_dev);
-	if (ret)
-		goto error_unreg_ring_funcs;
-
-	if (spi->irq) {
-		ret = ade7758_probe_trigger(indio_dev);
-		if (ret)
-			goto error_unreg_ring_funcs;
-	}
-
-	ret = iio_device_register(indio_dev);
-	if (ret)
-		goto error_remove_trigger;
-
-	return 0;
-
-error_remove_trigger:
-	if (spi->irq)
-		ade7758_remove_trigger(indio_dev);
-error_unreg_ring_funcs:
-	ade7758_unconfigure_ring(indio_dev);
-error_free_tx:
-	kfree(st->tx);
-error_free_rx:
-	kfree(st->rx);
-	return ret;
-}
-
-static int ade7758_remove(struct spi_device *spi)
-{
-	struct iio_dev *indio_dev = spi_get_drvdata(spi);
-	struct ade7758_state *st = iio_priv(indio_dev);
-
-	iio_device_unregister(indio_dev);
-	ade7758_stop_device(&indio_dev->dev);
-	ade7758_remove_trigger(indio_dev);
-	ade7758_unconfigure_ring(indio_dev);
-	kfree(st->tx);
-	kfree(st->rx);
-
-	return 0;
-}
-
-static const struct spi_device_id ade7758_id[] = {
-	{"ade7758", 0},
-	{}
-};
-MODULE_DEVICE_TABLE(spi, ade7758_id);
-
-static struct spi_driver ade7758_driver = {
-	.driver = {
-		.name = "ade7758",
-	},
-	.probe = ade7758_probe,
-	.remove = ade7758_remove,
-	.id_table = ade7758_id,
-};
-module_spi_driver(ade7758_driver);
-
-MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
-MODULE_DESCRIPTION("Analog Devices ADE7758 Polyphase Multifunction Energy Metering IC Driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c
deleted file mode 100644
index 6d7444d6e880..000000000000
--- a/drivers/staging/iio/meter/ade7758_ring.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * ADE7758 Poly Phase Multifunction Energy Metering IC driver
- *
- * Copyright 2010-2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-#include <linux/export.h>
-#include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <asm/unaligned.h>
-
-#include <linux/iio/iio.h>
-#include <linux/iio/buffer.h>
-#include <linux/iio/kfifo_buf.h>
-#include <linux/iio/trigger_consumer.h>
-#include "ade7758.h"
-
-/**
- * ade7758_spi_read_burst() - read data registers
- * @indio_dev: the IIO device
- **/
-static int ade7758_spi_read_burst(struct iio_dev *indio_dev)
-{
-	struct ade7758_state *st = iio_priv(indio_dev);
-	int ret;
-
-	ret = spi_sync(st->us, &st->ring_msg);
-	if (ret)
-		dev_err(&st->us->dev, "problem when reading WFORM value\n");
-
-	return ret;
-}
-
-static int ade7758_write_waveform_type(struct device *dev, unsigned int type)
-{
-	int ret;
-	u8 reg;
-
-	ret = ade7758_spi_read_reg_8(dev, ADE7758_WAVMODE, &reg);
-	if (ret)
-		goto out;
-
-	reg &= ~0x1F;
-	reg |= type & 0x1F;
-
-	ret = ade7758_spi_write_reg_8(dev, ADE7758_WAVMODE, reg);
-out:
-	return ret;
-}
-
-/* Whilst this makes a lot of calls to iio_sw_ring functions - it is too device
- * specific to be rolled into the core.
- */
-static irqreturn_t ade7758_trigger_handler(int irq, void *p)
-{
-	struct iio_poll_func *pf = p;
-	struct iio_dev *indio_dev = pf->indio_dev;
-	struct ade7758_state *st = iio_priv(indio_dev);
-	s64 dat64[2];
-	u32 *dat32 = (u32 *)dat64;
-
-	if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
-		if (ade7758_spi_read_burst(indio_dev) >= 0)
-			*dat32 = get_unaligned_be32(&st->rx_buf[5]) & 0xFFFFFF;
-
-	iio_push_to_buffers_with_timestamp(indio_dev, dat64, pf->timestamp);
-
-	iio_trigger_notify_done(indio_dev->trig);
-
-	return IRQ_HANDLED;
-}
-
-/**
- * ade7758_ring_preenable() setup the parameters of the ring before enabling
- *
- * The complex nature of the setting of the number of bytes per datum is due
- * to this driver currently ensuring that the timestamp is stored at an 8
- * byte boundary.
- **/
-static int ade7758_ring_preenable(struct iio_dev *indio_dev)
-{
-	unsigned int channel;
-
-	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,
-				    indio_dev->channels[channel].address);
-
-	return 0;
-}
-
-static const struct iio_buffer_setup_ops ade7758_ring_setup_ops = {
-	.preenable = &ade7758_ring_preenable,
-	.postenable = &iio_triggered_buffer_postenable,
-	.predisable = &iio_triggered_buffer_predisable,
-	.validate_scan_mask = &iio_validate_scan_mask_onehot,
-};
-
-void ade7758_unconfigure_ring(struct iio_dev *indio_dev)
-{
-	iio_dealloc_pollfunc(indio_dev->pollfunc);
-	iio_kfifo_free(indio_dev->buffer);
-}
-
-int ade7758_configure_ring(struct iio_dev *indio_dev)
-{
-	struct ade7758_state *st = iio_priv(indio_dev);
-	struct iio_buffer *buffer;
-	int ret = 0;
-
-	buffer = iio_kfifo_allocate();
-	if (!buffer)
-		return -ENOMEM;
-
-	iio_device_attach_buffer(indio_dev, buffer);
-
-	indio_dev->setup_ops = &ade7758_ring_setup_ops;
-
-	indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
-						 &ade7758_trigger_handler,
-						 0,
-						 indio_dev,
-						 "ade7759_consumer%d",
-						 indio_dev->id);
-	if (!indio_dev->pollfunc) {
-		ret = -ENOMEM;
-		goto error_iio_kfifo_free;
-	}
-
-	indio_dev->modes |= INDIO_BUFFER_TRIGGERED;
-
-	st->tx_buf[0] = ADE7758_READ_REG(ADE7758_RSTATUS);
-	st->tx_buf[1] = 0;
-	st->tx_buf[2] = 0;
-	st->tx_buf[3] = 0;
-	st->tx_buf[4] = ADE7758_READ_REG(ADE7758_WFORM);
-	st->tx_buf[5] = 0;
-	st->tx_buf[6] = 0;
-	st->tx_buf[7] = 0;
-
-	/* build spi ring message */
-	st->ring_xfer[0].tx_buf = &st->tx_buf[0];
-	st->ring_xfer[0].len = 1;
-	st->ring_xfer[0].bits_per_word = 8;
-	st->ring_xfer[0].delay_usecs = 4;
-	st->ring_xfer[1].rx_buf = &st->rx_buf[1];
-	st->ring_xfer[1].len = 3;
-	st->ring_xfer[1].bits_per_word = 8;
-	st->ring_xfer[1].cs_change = 1;
-
-	st->ring_xfer[2].tx_buf = &st->tx_buf[4];
-	st->ring_xfer[2].len = 1;
-	st->ring_xfer[2].bits_per_word = 8;
-	st->ring_xfer[2].delay_usecs = 1;
-	st->ring_xfer[3].rx_buf = &st->rx_buf[5];
-	st->ring_xfer[3].len = 3;
-	st->ring_xfer[3].bits_per_word = 8;
-
-	spi_message_init(&st->ring_msg);
-	spi_message_add_tail(&st->ring_xfer[0], &st->ring_msg);
-	spi_message_add_tail(&st->ring_xfer[1], &st->ring_msg);
-	spi_message_add_tail(&st->ring_xfer[2], &st->ring_msg);
-	spi_message_add_tail(&st->ring_xfer[3], &st->ring_msg);
-
-	return 0;
-
-error_iio_kfifo_free:
-	iio_kfifo_free(indio_dev->buffer);
-	return ret;
-}
diff --git a/drivers/staging/iio/meter/ade7758_trigger.c b/drivers/staging/iio/meter/ade7758_trigger.c
deleted file mode 100644
index 4f6b338cffeb..000000000000
--- a/drivers/staging/iio/meter/ade7758_trigger.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * ADE7758 Poly Phase Multifunction Energy Metering IC driver
- *
- * Copyright 2010-2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/export.h>
-
-#include <linux/iio/iio.h>
-#include <linux/iio/trigger.h>
-#include "ade7758.h"
-
-/**
- * ade7758_data_rdy_trig_poll() the event handler for the data rdy trig
- **/
-static irqreturn_t ade7758_data_rdy_trig_poll(int irq, void *private)
-{
-	disable_irq_nosync(irq);
-	iio_trigger_poll(private);
-
-	return IRQ_HANDLED;
-}
-
-/**
- * ade7758_data_rdy_trigger_set_state() set datardy interrupt state
- **/
-static int ade7758_data_rdy_trigger_set_state(struct iio_trigger *trig,
-					      bool state)
-{
-	struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
-
-	dev_dbg(&indio_dev->dev, "(%d)\n", state);
-	return ade7758_set_irq(&indio_dev->dev, state);
-}
-
-/**
- * ade7758_trig_try_reen() try renabling irq for data rdy trigger
- * @trig:	the datardy trigger
- **/
-static int ade7758_trig_try_reen(struct iio_trigger *trig)
-{
-	struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
-	struct ade7758_state *st = iio_priv(indio_dev);
-
-	enable_irq(st->us->irq);
-	/* irq reenabled so success! */
-	return 0;
-}
-
-static const struct iio_trigger_ops ade7758_trigger_ops = {
-	.set_trigger_state = &ade7758_data_rdy_trigger_set_state,
-	.try_reenable = &ade7758_trig_try_reen,
-};
-
-int ade7758_probe_trigger(struct iio_dev *indio_dev)
-{
-	struct ade7758_state *st = iio_priv(indio_dev);
-	int ret;
-
-	st->trig = iio_trigger_alloc("%s-dev%d",
-				     spi_get_device_id(st->us)->name,
-				     indio_dev->id);
-	if (!st->trig) {
-		ret = -ENOMEM;
-		goto error_ret;
-	}
-
-	ret = request_irq(st->us->irq,
-			  ade7758_data_rdy_trig_poll,
-			  IRQF_TRIGGER_LOW,
-			  spi_get_device_id(st->us)->name,
-			  st->trig);
-	if (ret)
-		goto error_free_trig;
-
-	st->trig->dev.parent = &st->us->dev;
-	st->trig->ops = &ade7758_trigger_ops;
-	iio_trigger_set_drvdata(st->trig, indio_dev);
-	ret = iio_trigger_register(st->trig);
-
-	/* select default trigger */
-	indio_dev->trig = iio_trigger_get(st->trig);
-	if (ret)
-		goto error_free_irq;
-
-	return 0;
-
-error_free_irq:
-	free_irq(st->us->irq, st->trig);
-error_free_trig:
-	iio_trigger_free(st->trig);
-error_ret:
-	return ret;
-}
-
-void ade7758_remove_trigger(struct iio_dev *indio_dev)
-{
-	struct ade7758_state *st = iio_priv(indio_dev);
-
-	iio_trigger_unregister(st->trig);
-	free_irq(st->us->irq, st->trig);
-	iio_trigger_free(st->trig);
-}
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] staging:iio:meter: Drop ADE7759 driver
  2018-05-12 17:51 [PATCH 0/4] staging:iio: Drop 4 meter drivers Jonathan Cameron
                   ` (2 preceding siblings ...)
  2018-05-12 17:51 ` [PATCH 3/4] staging:iio:meter: Drop ADE7758 driver Jonathan Cameron
@ 2018-05-12 17:51 ` Jonathan Cameron
  2018-05-20 11:22   ` Jonathan Cameron
  3 siblings, 1 reply; 9+ messages in thread
From: Jonathan Cameron @ 2018-05-12 17:51 UTC (permalink / raw)
  To: linux-iio
  Cc: Rodrigo Siqueira, John Syne, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Hartmut Knaack, Michael Hennerich,
	Jonathan Cameron

I announced the intent to drop some of these meter drivers
on the IIO list last cycle. This device is obsolete and not easily
obtained.  No one has come forward with suitable test hardware and
the driver would need a lot of work to move out of staging.

As such I am dropping it.  We can always bring it back again
if a user / tester emerges in the future.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/staging/iio/meter/Kconfig   |  10 -
 drivers/staging/iio/meter/Makefile  |   1 -
 drivers/staging/iio/meter/ade7759.c | 558 ----------------------------
 3 files changed, 569 deletions(-)

diff --git a/drivers/staging/iio/meter/Kconfig b/drivers/staging/iio/meter/Kconfig
index 451ac47bb0cc..e01eb8abcdce 100644
--- a/drivers/staging/iio/meter/Kconfig
+++ b/drivers/staging/iio/meter/Kconfig
@@ -3,16 +3,6 @@
 #
 menu "Active energy metering IC"
 
-config ADE7759
-	tristate "Analog Devices ADE7759 Active Energy Metering IC Driver"
-	depends on SPI
-	help
-	  Say yes here to build support for Analog Devices ADE7758 Active Energy
-	  Metering IC with di/dt Sensor Interface.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called ade7759.
-
 config ADE7854
 	tristate "Analog Devices ADE7854/58/68/78 Polyphase Multifunction Energy Metering IC Driver"
 	depends on SPI || I2C
diff --git a/drivers/staging/iio/meter/Makefile b/drivers/staging/iio/meter/Makefile
index a36ff1668275..ed4547e38f3a 100644
--- a/drivers/staging/iio/meter/Makefile
+++ b/drivers/staging/iio/meter/Makefile
@@ -3,7 +3,6 @@
 # Makefile for metering ic drivers
 #
 
-obj-$(CONFIG_ADE7759) += ade7759.o
 obj-$(CONFIG_ADE7854) += ade7854.o
 obj-$(CONFIG_ADE7854_I2C) += ade7854-i2c.o
 obj-$(CONFIG_ADE7854_SPI) += ade7854-spi.o
diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c
deleted file mode 100644
index c078b770fa53..000000000000
--- a/drivers/staging/iio/meter/ade7759.c
+++ /dev/null
@@ -1,558 +0,0 @@
-/*
- * ADE7759 Active Energy Metering IC with di/dt Sensor Interface Driver
- *
- * Copyright 2010 Analog Devices Inc.
- *
- * Licensed under the GPL-2 or later.
- */
-
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/delay.h>
-#include <linux/mutex.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/list.h>
-#include <linux/module.h>
-
-#include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
-#include "meter.h"
-
-#define ADE7759_WAVEFORM  0x01
-#define ADE7759_AENERGY   0x02
-#define ADE7759_RSTENERGY 0x03
-#define ADE7759_STATUS    0x04
-#define ADE7759_RSTSTATUS 0x05
-#define ADE7759_MODE      0x06
-#define ADE7759_CFDEN     0x07
-#define ADE7759_CH1OS     0x08
-#define ADE7759_CH2OS     0x09
-#define ADE7759_GAIN      0x0A
-#define ADE7759_APGAIN    0x0B
-#define ADE7759_PHCAL     0x0C
-#define ADE7759_APOS      0x0D
-#define ADE7759_ZXTOUT    0x0E
-#define ADE7759_SAGCYC    0x0F
-#define ADE7759_IRQEN     0x10
-#define ADE7759_SAGLVL    0x11
-#define ADE7759_TEMP      0x12
-#define ADE7759_LINECYC   0x13
-#define ADE7759_LENERGY   0x14
-#define ADE7759_CFNUM     0x15
-#define ADE7759_CHKSUM    0x1E
-#define ADE7759_DIEREV    0x1F
-
-#define ADE7759_READ_REG(a)    a
-#define ADE7759_WRITE_REG(a) ((a) | 0x80)
-
-#define ADE7759_MAX_TX    6
-#define ADE7759_MAX_RX    6
-#define ADE7759_STARTUP_DELAY 1000
-
-#define ADE7759_SPI_SLOW	(u32)(300 * 1000)
-#define ADE7759_SPI_BURST	(u32)(1000 * 1000)
-#define ADE7759_SPI_FAST	(u32)(2000 * 1000)
-
-/**
- * struct ade7759_state - device instance specific data
- * @us:			actual spi_device
- * @buf_lock:		mutex to protect tx and rx and write frequency
- * @tx:			transmit buffer
- * @rx:			receive buffer
- **/
-struct ade7759_state {
-	struct spi_device	*us;
-	struct mutex		buf_lock;
-	u8			tx[ADE7759_MAX_TX] ____cacheline_aligned;
-	u8			rx[ADE7759_MAX_RX];
-};
-
-static int ade7759_spi_write_reg_8(struct device *dev,
-				   u8 reg_address,
-				   u8 val)
-{
-	int ret;
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7759_state *st = iio_priv(indio_dev);
-
-	mutex_lock(&st->buf_lock);
-	st->tx[0] = ADE7759_WRITE_REG(reg_address);
-	st->tx[1] = val;
-
-	ret = spi_write(st->us, st->tx, 2);
-	mutex_unlock(&st->buf_lock);
-
-	return ret;
-}
-
-/*Unlocked version of ade7759_spi_write_reg_16 function */
-static int __ade7759_spi_write_reg_16(struct device *dev,
-				      u8 reg_address,
-				      u16 value)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7759_state *st = iio_priv(indio_dev);
-
-	st->tx[0] = ADE7759_WRITE_REG(reg_address);
-	st->tx[1] = (value >> 8) & 0xFF;
-	st->tx[2] = value & 0xFF;
-	return spi_write(st->us, st->tx, 3);
-}
-
-static int ade7759_spi_write_reg_16(struct device *dev,
-				    u8 reg_address,
-				    u16 value)
-{
-	int ret;
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7759_state *st = iio_priv(indio_dev);
-
-	mutex_lock(&st->buf_lock);
-	ret = __ade7759_spi_write_reg_16(dev, reg_address, value);
-	mutex_unlock(&st->buf_lock);
-
-	return ret;
-}
-
-static int ade7759_spi_read_reg_8(struct device *dev,
-				  u8 reg_address,
-				  u8 *val)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7759_state *st = iio_priv(indio_dev);
-	int ret;
-
-	ret = spi_w8r8(st->us, ADE7759_READ_REG(reg_address));
-	if (ret < 0) {
-		dev_err(&st->us->dev,
-			"problem when reading 8 bit register 0x%02X",
-			reg_address);
-		return ret;
-	}
-	*val = ret;
-
-	return 0;
-}
-
-static int ade7759_spi_read_reg_16(struct device *dev,
-				   u8 reg_address,
-				   u16 *val)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7759_state *st = iio_priv(indio_dev);
-	int ret;
-
-	ret = spi_w8r16be(st->us, ADE7759_READ_REG(reg_address));
-	if (ret < 0) {
-		dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
-			reg_address);
-		return ret;
-	}
-
-	*val = ret;
-
-	return 0;
-}
-
-static int ade7759_spi_read_reg_40(struct device *dev,
-				   u8 reg_address,
-				   u64 *val)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7759_state *st = iio_priv(indio_dev);
-	int ret;
-	struct spi_transfer xfers[] = {
-		{
-			.tx_buf = st->tx,
-			.rx_buf = st->rx,
-			.bits_per_word = 8,
-			.len = 6,
-		},
-	};
-
-	mutex_lock(&st->buf_lock);
-	st->tx[0] = ADE7759_READ_REG(reg_address);
-	memset(&st->tx[1], 0, 5);
-
-	ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
-	if (ret) {
-		dev_err(&st->us->dev,
-			"problem when reading 40 bit register 0x%02X",
-			reg_address);
-		goto error_ret;
-	}
-	*val = ((u64)st->rx[1] << 32) | ((u64)st->rx[2] << 24) |
-		(st->rx[3] << 16) | (st->rx[4] << 8) | st->rx[5];
-
-error_ret:
-	mutex_unlock(&st->buf_lock);
-	return ret;
-}
-
-static ssize_t ade7759_read_8bit(struct device *dev,
-				 struct device_attribute *attr,
-				 char *buf)
-{
-	int ret;
-	u8 val = 0;
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-	ret = ade7759_spi_read_reg_8(dev, this_attr->address, &val);
-	if (ret)
-		return ret;
-
-	return sprintf(buf, "%u\n", val);
-}
-
-static ssize_t ade7759_read_16bit(struct device *dev,
-				  struct device_attribute *attr,
-				  char *buf)
-{
-	int ret;
-	u16 val = 0;
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-	ret = ade7759_spi_read_reg_16(dev, this_attr->address, &val);
-	if (ret)
-		return ret;
-
-	return sprintf(buf, "%u\n", val);
-}
-
-static ssize_t ade7759_read_40bit(struct device *dev,
-				  struct device_attribute *attr,
-				  char *buf)
-{
-	int ret;
-	u64 val = 0;
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-	ret = ade7759_spi_read_reg_40(dev, this_attr->address, &val);
-	if (ret)
-		return ret;
-
-	return sprintf(buf, "%llu\n", val);
-}
-
-static ssize_t ade7759_write_8bit(struct device *dev,
-				  struct device_attribute *attr,
-				  const char *buf,
-				  size_t len)
-{
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-	int ret;
-	u8 val;
-
-	ret = kstrtou8(buf, 10, &val);
-	if (ret)
-		goto error_ret;
-	ret = ade7759_spi_write_reg_8(dev, this_attr->address, val);
-
-error_ret:
-	return ret ? ret : len;
-}
-
-static ssize_t ade7759_write_16bit(struct device *dev,
-				   struct device_attribute *attr,
-				   const char *buf,
-				   size_t len)
-{
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-	int ret;
-	u16 val;
-
-	ret = kstrtou16(buf, 10, &val);
-	if (ret)
-		goto error_ret;
-	ret = ade7759_spi_write_reg_16(dev, this_attr->address, val);
-
-error_ret:
-	return ret ? ret : len;
-}
-
-static int ade7759_reset(struct device *dev)
-{
-	int ret;
-	u16 val;
-
-	ret = ade7759_spi_read_reg_16(dev, ADE7759_MODE, &val);
-	if (ret < 0)
-		return ret;
-
-	val |= BIT(6); /* Software Chip Reset */
-	return ade7759_spi_write_reg_16(dev,
-			ADE7759_MODE,
-			val);
-}
-
-static IIO_DEV_ATTR_AENERGY(ade7759_read_40bit, ADE7759_AENERGY);
-static IIO_DEV_ATTR_CFDEN(0644,
-		ade7759_read_16bit,
-		ade7759_write_16bit,
-		ADE7759_CFDEN);
-static IIO_DEV_ATTR_CFNUM(0644,
-		ade7759_read_8bit,
-		ade7759_write_8bit,
-		ADE7759_CFNUM);
-static IIO_DEV_ATTR_CHKSUM(ade7759_read_8bit, ADE7759_CHKSUM);
-static IIO_DEV_ATTR_PHCAL(0644,
-		ade7759_read_16bit,
-		ade7759_write_16bit,
-		ADE7759_PHCAL);
-static IIO_DEV_ATTR_APOS(0644,
-		ade7759_read_16bit,
-		ade7759_write_16bit,
-		ADE7759_APOS);
-static IIO_DEV_ATTR_SAGCYC(0644,
-		ade7759_read_8bit,
-		ade7759_write_8bit,
-		ADE7759_SAGCYC);
-static IIO_DEV_ATTR_SAGLVL(0644,
-		ade7759_read_8bit,
-		ade7759_write_8bit,
-		ADE7759_SAGLVL);
-static IIO_DEV_ATTR_LINECYC(0644,
-		ade7759_read_8bit,
-		ade7759_write_8bit,
-		ADE7759_LINECYC);
-static IIO_DEV_ATTR_LENERGY(ade7759_read_40bit, ADE7759_LENERGY);
-static IIO_DEV_ATTR_PGA_GAIN(0644,
-		ade7759_read_8bit,
-		ade7759_write_8bit,
-		ADE7759_GAIN);
-static IIO_DEV_ATTR_ACTIVE_POWER_GAIN(0644,
-		ade7759_read_16bit,
-		ade7759_write_16bit,
-		ADE7759_APGAIN);
-
-static IIO_DEVICE_ATTR(choff_1, 0644,
-			ade7759_read_8bit,
-			ade7759_write_8bit,
-			ADE7759_CH1OS);
-
-static IIO_DEVICE_ATTR(choff_2, 0644,
-			ade7759_read_8bit,
-			ade7759_write_8bit,
-			ADE7759_CH2OS);
-
-static int ade7759_set_irq(struct device *dev, bool enable)
-{
-	int ret;
-	u8 irqen;
-
-	ret = ade7759_spi_read_reg_8(dev, ADE7759_IRQEN, &irqen);
-	if (ret)
-		goto error_ret;
-
-	if (enable)
-		irqen |= BIT(3); /* Enables an interrupt when a data is
-				  * present in the waveform register
-				  */
-	else
-		irqen &= ~BIT(3);
-
-	ret = ade7759_spi_write_reg_8(dev, ADE7759_IRQEN, irqen);
-
-error_ret:
-	return ret;
-}
-
-/* Power down the device */
-static int ade7759_stop_device(struct device *dev)
-{
-	int ret;
-	u16 val;
-
-	ret = ade7759_spi_read_reg_16(dev, ADE7759_MODE, &val);
-	if (ret < 0) {
-		dev_err(dev, "unable to power down the device, error: %d\n",
-			ret);
-		return ret;
-	}
-
-	val |= BIT(4);  /* AD converters can be turned off */
-
-	return ade7759_spi_write_reg_16(dev, ADE7759_MODE, val);
-}
-
-static int ade7759_initial_setup(struct iio_dev *indio_dev)
-{
-	int ret;
-	struct ade7759_state *st = iio_priv(indio_dev);
-	struct device *dev = &indio_dev->dev;
-
-	/* use low spi speed for init */
-	st->us->mode = SPI_MODE_3;
-	spi_setup(st->us);
-
-	/* Disable IRQ */
-	ret = ade7759_set_irq(dev, false);
-	if (ret) {
-		dev_err(dev, "disable irq failed");
-		goto err_ret;
-	}
-
-	ade7759_reset(dev);
-	usleep_range(ADE7759_STARTUP_DELAY, ADE7759_STARTUP_DELAY + 100);
-
-err_ret:
-	return ret;
-}
-
-static ssize_t ade7759_read_frequency(struct device *dev,
-				      struct device_attribute *attr,
-				      char *buf)
-{
-	int ret;
-	u16 t;
-	int sps;
-
-	ret = ade7759_spi_read_reg_16(dev, ADE7759_MODE, &t);
-	if (ret)
-		return ret;
-
-	t = (t >> 3) & 0x3;
-	sps = 27900 / (1 + t);
-
-	return sprintf(buf, "%d\n", sps);
-}
-
-static ssize_t ade7759_write_frequency(struct device *dev,
-				       struct device_attribute *attr,
-				       const char *buf,
-				       size_t len)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct ade7759_state *st = iio_priv(indio_dev);
-	u16 val;
-	int ret;
-	u16 reg, t;
-
-	ret = kstrtou16(buf, 10, &val);
-	if (ret)
-		return ret;
-	if (!val)
-		return -EINVAL;
-
-	mutex_lock(&st->buf_lock);
-
-	t = 27900 / val;
-	if (t > 0)
-		t--;
-
-	if (t > 1)
-		st->us->max_speed_hz = ADE7759_SPI_SLOW;
-	else
-		st->us->max_speed_hz = ADE7759_SPI_FAST;
-
-	ret = ade7759_spi_read_reg_16(dev, ADE7759_MODE, &reg);
-	if (ret)
-		goto out;
-
-	reg &= ~(3 << 13);
-	reg |= t << 13;
-
-	ret = __ade7759_spi_write_reg_16(dev, ADE7759_MODE, reg);
-
-out:
-	mutex_unlock(&st->buf_lock);
-
-	return ret ? ret : len;
-}
-static IIO_DEV_ATTR_TEMP_RAW(ade7759_read_8bit);
-static IIO_CONST_ATTR(in_temp_offset, "70 C");
-static IIO_CONST_ATTR(in_temp_scale, "1 C");
-
-static IIO_DEV_ATTR_SAMP_FREQ(0644,
-		ade7759_read_frequency,
-		ade7759_write_frequency);
-
-static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("27900 14000 7000 3500");
-
-static struct attribute *ade7759_attributes[] = {
-	&iio_dev_attr_in_temp_raw.dev_attr.attr,
-	&iio_const_attr_in_temp_offset.dev_attr.attr,
-	&iio_const_attr_in_temp_scale.dev_attr.attr,
-	&iio_dev_attr_sampling_frequency.dev_attr.attr,
-	&iio_const_attr_sampling_frequency_available.dev_attr.attr,
-	&iio_dev_attr_phcal.dev_attr.attr,
-	&iio_dev_attr_cfden.dev_attr.attr,
-	&iio_dev_attr_aenergy.dev_attr.attr,
-	&iio_dev_attr_cfnum.dev_attr.attr,
-	&iio_dev_attr_apos.dev_attr.attr,
-	&iio_dev_attr_sagcyc.dev_attr.attr,
-	&iio_dev_attr_saglvl.dev_attr.attr,
-	&iio_dev_attr_linecyc.dev_attr.attr,
-	&iio_dev_attr_lenergy.dev_attr.attr,
-	&iio_dev_attr_chksum.dev_attr.attr,
-	&iio_dev_attr_pga_gain.dev_attr.attr,
-	&iio_dev_attr_active_power_gain.dev_attr.attr,
-	&iio_dev_attr_choff_1.dev_attr.attr,
-	&iio_dev_attr_choff_2.dev_attr.attr,
-	NULL,
-};
-
-static const struct attribute_group ade7759_attribute_group = {
-	.attrs = ade7759_attributes,
-};
-
-static const struct iio_info ade7759_info = {
-	.attrs = &ade7759_attribute_group,
-};
-
-static int ade7759_probe(struct spi_device *spi)
-{
-	int ret;
-	struct ade7759_state *st;
-	struct iio_dev *indio_dev;
-
-	/* setup the industrialio driver allocated elements */
-	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
-	if (!indio_dev)
-		return -ENOMEM;
-	/* this is only used for removal purposes */
-	spi_set_drvdata(spi, indio_dev);
-
-	st = iio_priv(indio_dev);
-	st->us = spi;
-	mutex_init(&st->buf_lock);
-	indio_dev->name = spi->dev.driver->name;
-	indio_dev->dev.parent = &spi->dev;
-	indio_dev->info = &ade7759_info;
-	indio_dev->modes = INDIO_DIRECT_MODE;
-
-	/* Get the device into a sane initial state */
-	ret = ade7759_initial_setup(indio_dev);
-	if (ret)
-		return ret;
-
-	return iio_device_register(indio_dev);
-}
-
-static int ade7759_remove(struct spi_device *spi)
-{
-	struct iio_dev *indio_dev = spi_get_drvdata(spi);
-
-	iio_device_unregister(indio_dev);
-	ade7759_stop_device(&indio_dev->dev);
-
-	return 0;
-}
-
-static struct spi_driver ade7759_driver = {
-	.driver = {
-		.name = "ade7759",
-	},
-	.probe = ade7759_probe,
-	.remove = ade7759_remove,
-};
-module_spi_driver(ade7759_driver);
-
-MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
-MODULE_DESCRIPTION("Analog Devices ADE7759 Active Energy Metering IC Driver");
-MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("spi:ad7759");
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] staging:iio:meter: Drop ADE7753 driver
  2018-05-12 17:51 ` [PATCH 1/4] staging:iio:meter: Drop ADE7753 driver Jonathan Cameron
@ 2018-05-20 11:21   ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2018-05-20 11:21 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Rodrigo Siqueira, John Syne, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Hartmut Knaack, Michael Hennerich

On Sat, 12 May 2018 18:51:01 +0100
Jonathan Cameron <Jonathan.Cameron@huawei.com> wrote:

> I announced the intent to drop some of these meter drivers
> on the IIO list last cycle. This device is obsolete and not easily
> obtained.  No one has come forward with suitable test hardware and
> the driver would need a lot of work to move out of staging.
> 
> As such I am dropping it.  We can always bring it back again
> if a user / tester emerges in the future.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to not care.

Thanks,

Jonathan
> ---
>  drivers/staging/iio/meter/Kconfig   |  10 -
>  drivers/staging/iio/meter/Makefile  |   1 -
>  drivers/staging/iio/meter/ade7753.c | 630 ----------------------------
>  3 files changed, 641 deletions(-)
> 
> diff --git a/drivers/staging/iio/meter/Kconfig b/drivers/staging/iio/meter/Kconfig
> index 64cd3704ec6e..62db8d6498f5 100644
> --- a/drivers/staging/iio/meter/Kconfig
> +++ b/drivers/staging/iio/meter/Kconfig
> @@ -3,16 +3,6 @@
>  #
>  menu "Active energy metering IC"
>  
> -config ADE7753
> -	tristate "Analog Devices ADE7753/6 Single-Phase Multifunction Metering IC Driver"
> -	depends on SPI
> -	help
> -	  Say yes here to build support for Analog Devices ADE7753 Single-Phase Multifunction
> -	  Metering IC with di/dt Sensor Interface.
> -
> -	  To compile this driver as a module, choose M here: the
> -	  module will be called ade7753.
> -
>  config ADE7754
>  	tristate "Analog Devices ADE7754 Polyphase Multifunction Energy Metering IC Driver"
>  	depends on SPI
> diff --git a/drivers/staging/iio/meter/Makefile b/drivers/staging/iio/meter/Makefile
> index 19e7982f5563..8b2592b32845 100644
> --- a/drivers/staging/iio/meter/Makefile
> +++ b/drivers/staging/iio/meter/Makefile
> @@ -3,7 +3,6 @@
>  # Makefile for metering ic drivers
>  #
>  
> -obj-$(CONFIG_ADE7753) += ade7753.o
>  obj-$(CONFIG_ADE7754) += ade7754.o
>  
>  ade7758-y             := ade7758_core.o
> diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c
> deleted file mode 100644
> index 275e8dfff836..000000000000
> --- a/drivers/staging/iio/meter/ade7753.c
> +++ /dev/null
> @@ -1,630 +0,0 @@
> -/*
> - * ADE7753 Single-Phase Multifunction Metering IC with di/dt Sensor Interface
> - *
> - * Copyright 2010 Analog Devices Inc.
> - *
> - * Licensed under the GPL-2 or later.
> - */
> -
> -#include <linux/delay.h>
> -#include <linux/device.h>
> -#include <linux/interrupt.h>
> -#include <linux/irq.h>
> -#include <linux/kernel.h>
> -#include <linux/list.h>
> -#include <linux/module.h>
> -#include <linux/mutex.h>
> -#include <linux/slab.h>
> -#include <linux/sysfs.h>
> -#include <linux/iio/iio.h>
> -#include <linux/iio/sysfs.h>
> -#include <linux/spi/spi.h>
> -#include "meter.h"
> -
> -#define ADE7753_WAVEFORM   0x01
> -#define ADE7753_AENERGY    0x02
> -#define ADE7753_RAENERGY   0x03
> -#define ADE7753_LAENERGY   0x04
> -#define ADE7753_VAENERGY   0x05
> -#define ADE7753_RVAENERGY  0x06
> -#define ADE7753_LVAENERGY  0x07
> -#define ADE7753_LVARENERGY 0x08
> -#define ADE7753_MODE       0x09
> -#define ADE7753_IRQEN      0x0A
> -#define ADE7753_STATUS     0x0B
> -#define ADE7753_RSTSTATUS  0x0C
> -#define ADE7753_CH1OS      0x0D
> -#define ADE7753_CH2OS      0x0E
> -#define ADE7753_GAIN       0x0F
> -#define ADE7753_PHCAL      0x10
> -#define ADE7753_APOS       0x11
> -#define ADE7753_WGAIN      0x12
> -#define ADE7753_WDIV       0x13
> -#define ADE7753_CFNUM      0x14
> -#define ADE7753_CFDEN      0x15
> -#define ADE7753_IRMS       0x16
> -#define ADE7753_VRMS       0x17
> -#define ADE7753_IRMSOS     0x18
> -#define ADE7753_VRMSOS     0x19
> -#define ADE7753_VAGAIN     0x1A
> -#define ADE7753_VADIV      0x1B
> -#define ADE7753_LINECYC    0x1C
> -#define ADE7753_ZXTOUT     0x1D
> -#define ADE7753_SAGCYC     0x1E
> -#define ADE7753_SAGLVL     0x1F
> -#define ADE7753_IPKLVL     0x20
> -#define ADE7753_VPKLVL     0x21
> -#define ADE7753_IPEAK      0x22
> -#define ADE7753_RSTIPEAK   0x23
> -#define ADE7753_VPEAK      0x24
> -#define ADE7753_RSTVPEAK   0x25
> -#define ADE7753_TEMP       0x26
> -#define ADE7753_PERIOD     0x27
> -#define ADE7753_TMODE      0x3D
> -#define ADE7753_CHKSUM     0x3E
> -#define ADE7753_DIEREV     0x3F
> -
> -#define ADE7753_READ_REG(a)    a
> -#define ADE7753_WRITE_REG(a) ((a) | 0x80)
> -
> -#define ADE7753_MAX_TX    4
> -#define ADE7753_MAX_RX    4
> -#define ADE7753_STARTUP_DELAY 1000
> -
> -#define ADE7753_SPI_SLOW    (u32)(300 * 1000)
> -#define ADE7753_SPI_BURST   (u32)(1000 * 1000)
> -#define ADE7753_SPI_FAST    (u32)(2000 * 1000)
> -
> -/**
> - * struct ade7753_state - device instance specific data
> - * @us:         actual spi_device
> - * @tx:         transmit buffer
> - * @rx:         receive buffer
> - * @buf_lock:       mutex to protect tx, rx and write frequency
> - **/
> -struct ade7753_state {
> -	struct spi_device   *us;
> -	struct mutex        buf_lock;
> -	u8          tx[ADE7753_MAX_TX] ____cacheline_aligned;
> -	u8          rx[ADE7753_MAX_RX];
> -};
> -
> -static int ade7753_spi_write_reg_8(struct device *dev,
> -				   u8 reg_address,
> -				   u8 val)
> -{
> -	int ret;
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7753_state *st = iio_priv(indio_dev);
> -
> -	mutex_lock(&st->buf_lock);
> -	st->tx[0] = ADE7753_WRITE_REG(reg_address);
> -	st->tx[1] = val;
> -
> -	ret = spi_write(st->us, st->tx, 2);
> -	mutex_unlock(&st->buf_lock);
> -
> -	return ret;
> -}
> -
> -static int __ade7753_spi_write_reg_16(struct device *dev, u8 reg_address,
> -				      u16 value)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7753_state *st = iio_priv(indio_dev);
> -
> -	st->tx[0] = ADE7753_WRITE_REG(reg_address);
> -	st->tx[1] = (value >> 8) & 0xFF;
> -	st->tx[2] = value & 0xFF;
> -
> -	return spi_write(st->us, st->tx, 3);
> -}
> -
> -static int ade7753_spi_write_reg_16(struct device *dev, u8 reg_address,
> -				    u16 value)
> -{
> -	int ret;
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7753_state *st = iio_priv(indio_dev);
> -
> -	mutex_lock(&st->buf_lock);
> -	ret = __ade7753_spi_write_reg_16(dev, reg_address, value);
> -	mutex_unlock(&st->buf_lock);
> -
> -	return ret;
> -}
> -
> -static int ade7753_spi_read_reg_8(struct device *dev,
> -				  u8 reg_address,
> -				  u8 *val)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7753_state *st = iio_priv(indio_dev);
> -	ssize_t ret;
> -
> -	ret = spi_w8r8(st->us, ADE7753_READ_REG(reg_address));
> -	if (ret < 0) {
> -		dev_err(&st->us->dev, "problem when reading 8 bit register 0x%02X",
> -			reg_address);
> -		return ret;
> -	}
> -	*val = ret;
> -
> -	return 0;
> -}
> -
> -static int ade7753_spi_read_reg_16(struct device *dev,
> -				   u8 reg_address,
> -				   u16 *val)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7753_state *st = iio_priv(indio_dev);
> -	ssize_t ret;
> -
> -	ret = spi_w8r16be(st->us, ADE7753_READ_REG(reg_address));
> -	if (ret < 0) {
> -		dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
> -			reg_address);
> -		return ret;
> -	}
> -
> -	*val = ret;
> -
> -	return 0;
> -}
> -
> -static int ade7753_spi_read_reg_24(struct device *dev,
> -				   u8 reg_address,
> -				   u32 *val)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7753_state *st = iio_priv(indio_dev);
> -	int ret;
> -	struct spi_transfer xfers[] = {
> -		{
> -			.tx_buf = st->tx,
> -			.bits_per_word = 8,
> -			.len = 1,
> -		}, {
> -			.rx_buf = st->tx,
> -			.bits_per_word = 8,
> -			.len = 3,
> -		}
> -	};
> -
> -	mutex_lock(&st->buf_lock);
> -	st->tx[0] = ADE7753_READ_REG(reg_address);
> -
> -	ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
> -	if (ret) {
> -		dev_err(&st->us->dev, "problem when reading 24 bit register 0x%02X",
> -			reg_address);
> -		goto error_ret;
> -	}
> -	*val = (st->rx[0] << 16) | (st->rx[1] << 8) | st->rx[2];
> -
> -error_ret:
> -	mutex_unlock(&st->buf_lock);
> -	return ret;
> -}
> -
> -static ssize_t ade7753_read_8bit(struct device *dev,
> -				 struct device_attribute *attr,
> -				 char *buf)
> -{
> -	int ret;
> -	u8 val;
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -
> -	ret = ade7753_spi_read_reg_8(dev, this_attr->address, &val);
> -	if (ret)
> -		return ret;
> -
> -	return sprintf(buf, "%u\n", val);
> -}
> -
> -static ssize_t ade7753_read_16bit(struct device *dev,
> -				  struct device_attribute *attr,
> -				  char *buf)
> -{
> -	int ret;
> -	u16 val;
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -
> -	ret = ade7753_spi_read_reg_16(dev, this_attr->address, &val);
> -	if (ret)
> -		return ret;
> -
> -	return sprintf(buf, "%u\n", val);
> -}
> -
> -static ssize_t ade7753_read_24bit(struct device *dev,
> -				  struct device_attribute *attr,
> -				  char *buf)
> -{
> -	int ret;
> -	u32 val;
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -
> -	ret = ade7753_spi_read_reg_24(dev, this_attr->address, &val);
> -	if (ret)
> -		return ret;
> -
> -	return sprintf(buf, "%u\n", val);
> -}
> -
> -static ssize_t ade7753_write_8bit(struct device *dev,
> -				  struct device_attribute *attr,
> -				  const char *buf,
> -				  size_t len)
> -{
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -	int ret;
> -	u8 val;
> -
> -	ret = kstrtou8(buf, 10, &val);
> -	if (ret)
> -		goto error_ret;
> -	ret = ade7753_spi_write_reg_8(dev, this_attr->address, val);
> -
> -error_ret:
> -	return ret ? ret : len;
> -}
> -
> -static ssize_t ade7753_write_16bit(struct device *dev,
> -				   struct device_attribute *attr,
> -				   const char *buf,
> -				   size_t len)
> -{
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -	int ret;
> -	u16 val;
> -
> -	ret = kstrtou16(buf, 10, &val);
> -	if (ret)
> -		goto error_ret;
> -	ret = ade7753_spi_write_reg_16(dev, this_attr->address, val);
> -
> -error_ret:
> -	return ret ? ret : len;
> -}
> -
> -static int ade7753_reset(struct device *dev)
> -{
> -	u16 val;
> -	int ret;
> -
> -	ret = ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val);
> -	if (ret)
> -		return ret;
> -
> -	val |= BIT(6); /* Software Chip Reset */
> -
> -	return ade7753_spi_write_reg_16(dev, ADE7753_MODE, val);
> -}
> -
> -static IIO_DEV_ATTR_AENERGY(ade7753_read_24bit, ADE7753_AENERGY);
> -static IIO_DEV_ATTR_LAENERGY(ade7753_read_24bit, ADE7753_LAENERGY);
> -static IIO_DEV_ATTR_VAENERGY(ade7753_read_24bit, ADE7753_VAENERGY);
> -static IIO_DEV_ATTR_LVAENERGY(ade7753_read_24bit, ADE7753_LVAENERGY);
> -static IIO_DEV_ATTR_CFDEN(0644,
> -		ade7753_read_16bit,
> -		ade7753_write_16bit,
> -		ADE7753_CFDEN);
> -static IIO_DEV_ATTR_CFNUM(0644,
> -		ade7753_read_8bit,
> -		ade7753_write_8bit,
> -		ADE7753_CFNUM);
> -static IIO_DEV_ATTR_CHKSUM(ade7753_read_8bit, ADE7753_CHKSUM);
> -static IIO_DEV_ATTR_PHCAL(0644,
> -		ade7753_read_16bit,
> -		ade7753_write_16bit,
> -		ADE7753_PHCAL);
> -static IIO_DEV_ATTR_APOS(0644,
> -		ade7753_read_16bit,
> -		ade7753_write_16bit,
> -		ADE7753_APOS);
> -static IIO_DEV_ATTR_SAGCYC(0644,
> -		ade7753_read_8bit,
> -		ade7753_write_8bit,
> -		ADE7753_SAGCYC);
> -static IIO_DEV_ATTR_SAGLVL(0644,
> -		ade7753_read_8bit,
> -		ade7753_write_8bit,
> -		ADE7753_SAGLVL);
> -static IIO_DEV_ATTR_LINECYC(0644,
> -		ade7753_read_8bit,
> -		ade7753_write_8bit,
> -		ADE7753_LINECYC);
> -static IIO_DEV_ATTR_WDIV(0644,
> -		ade7753_read_8bit,
> -		ade7753_write_8bit,
> -		ADE7753_WDIV);
> -static IIO_DEV_ATTR_IRMS(0644,
> -		ade7753_read_24bit,
> -		NULL,
> -		ADE7753_IRMS);
> -static IIO_DEV_ATTR_VRMS(0444,
> -		ade7753_read_24bit,
> -		NULL,
> -		ADE7753_VRMS);
> -static IIO_DEV_ATTR_IRMSOS(0644,
> -		ade7753_read_16bit,
> -		ade7753_write_16bit,
> -		ADE7753_IRMSOS);
> -static IIO_DEV_ATTR_VRMSOS(0644,
> -		ade7753_read_16bit,
> -		ade7753_write_16bit,
> -		ADE7753_VRMSOS);
> -static IIO_DEV_ATTR_WGAIN(0644,
> -		ade7753_read_16bit,
> -		ade7753_write_16bit,
> -		ADE7753_WGAIN);
> -static IIO_DEV_ATTR_VAGAIN(0644,
> -		ade7753_read_16bit,
> -		ade7753_write_16bit,
> -		ADE7753_VAGAIN);
> -static IIO_DEV_ATTR_PGA_GAIN(0644,
> -		ade7753_read_16bit,
> -		ade7753_write_16bit,
> -		ADE7753_GAIN);
> -static IIO_DEV_ATTR_IPKLVL(0644,
> -		ade7753_read_8bit,
> -		ade7753_write_8bit,
> -		ADE7753_IPKLVL);
> -static IIO_DEV_ATTR_VPKLVL(0644,
> -		ade7753_read_8bit,
> -		ade7753_write_8bit,
> -		ADE7753_VPKLVL);
> -static IIO_DEV_ATTR_IPEAK(0444,
> -		ade7753_read_24bit,
> -		NULL,
> -		ADE7753_IPEAK);
> -static IIO_DEV_ATTR_VPEAK(0444,
> -		ade7753_read_24bit,
> -		NULL,
> -		ADE7753_VPEAK);
> -static IIO_DEV_ATTR_VPERIOD(0444,
> -		ade7753_read_16bit,
> -		NULL,
> -		ADE7753_PERIOD);
> -
> -static IIO_DEVICE_ATTR(choff_1, 0644,
> -			ade7753_read_8bit,
> -			ade7753_write_8bit,
> -			ADE7753_CH1OS);
> -
> -static IIO_DEVICE_ATTR(choff_2, 0644,
> -			ade7753_read_8bit,
> -			ade7753_write_8bit,
> -			ADE7753_CH2OS);
> -
> -static int ade7753_set_irq(struct device *dev, bool enable)
> -{
> -	int ret;
> -	u8 irqen;
> -
> -	ret = ade7753_spi_read_reg_8(dev, ADE7753_IRQEN, &irqen);
> -	if (ret)
> -		goto error_ret;
> -
> -	if (enable)
> -		irqen |= BIT(3); /* Enables an interrupt when a data is
> -				  * present in the waveform register
> -				  */
> -	else
> -		irqen &= ~BIT(3);
> -
> -	ret = ade7753_spi_write_reg_8(dev, ADE7753_IRQEN, irqen);
> -
> -error_ret:
> -	return ret;
> -}
> -
> -/* Power down the device */
> -static int ade7753_stop_device(struct device *dev)
> -{
> -	u16 val;
> -	int ret;
> -
> -	ret = ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val);
> -	if (ret)
> -		return ret;
> -
> -	val |= BIT(4);  /* AD converters can be turned off */
> -
> -	return ade7753_spi_write_reg_16(dev, ADE7753_MODE, val);
> -}
> -
> -static int ade7753_initial_setup(struct iio_dev *indio_dev)
> -{
> -	int ret;
> -	struct device *dev = &indio_dev->dev;
> -	struct ade7753_state *st = iio_priv(indio_dev);
> -
> -	/* use low spi speed for init */
> -	st->us->mode = SPI_MODE_3;
> -	spi_setup(st->us);
> -
> -	/* Disable IRQ */
> -	ret = ade7753_set_irq(dev, false);
> -	if (ret) {
> -		dev_err(dev, "disable irq failed");
> -		goto err_ret;
> -	}
> -
> -	ade7753_reset(dev);
> -	usleep_range(ADE7753_STARTUP_DELAY, ADE7753_STARTUP_DELAY + 100);
> -
> -err_ret:
> -	return ret;
> -}
> -
> -static ssize_t ade7753_read_frequency(struct device *dev,
> -				      struct device_attribute *attr,
> -				      char *buf)
> -{
> -	int ret;
> -	u16 t;
> -	int sps;
> -
> -	ret = ade7753_spi_read_reg_16(dev, ADE7753_MODE, &t);
> -	if (ret)
> -		return ret;
> -
> -	t = (t >> 11) & 0x3;
> -	sps = 27900 / (1 + t);
> -
> -	return sprintf(buf, "%d\n", sps);
> -}
> -
> -static ssize_t ade7753_write_frequency(struct device *dev,
> -				       struct device_attribute *attr,
> -				       const char *buf,
> -				       size_t len)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7753_state *st = iio_priv(indio_dev);
> -	u16 val;
> -	int ret;
> -	u16 reg, t;
> -
> -	ret = kstrtou16(buf, 10, &val);
> -	if (ret)
> -		return ret;
> -	if (!val)
> -		return -EINVAL;
> -
> -	mutex_lock(&st->buf_lock);
> -
> -	t = 27900 / val;
> -	if (t > 0)
> -		t--;
> -
> -	if (t > 1)
> -		st->us->max_speed_hz = ADE7753_SPI_SLOW;
> -	else
> -		st->us->max_speed_hz = ADE7753_SPI_FAST;
> -
> -	ret = ade7753_spi_read_reg_16(dev, ADE7753_MODE, &reg);
> -	if (ret)
> -		goto out;
> -
> -	reg &= ~(3 << 11);
> -	reg |= t << 11;
> -
> -	ret = __ade7753_spi_write_reg_16(dev, ADE7753_MODE, reg);
> -
> -out:
> -	mutex_unlock(&st->buf_lock);
> -
> -	return ret ? ret : len;
> -}
> -
> -static IIO_DEV_ATTR_TEMP_RAW(ade7753_read_8bit);
> -static IIO_CONST_ATTR(in_temp_offset, "-25 C");
> -static IIO_CONST_ATTR(in_temp_scale, "0.67 C");
> -
> -static IIO_DEV_ATTR_SAMP_FREQ(0644,
> -		ade7753_read_frequency,
> -		ade7753_write_frequency);
> -
> -static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("27900 14000 7000 3500");
> -
> -static struct attribute *ade7753_attributes[] = {
> -	&iio_dev_attr_in_temp_raw.dev_attr.attr,
> -	&iio_const_attr_in_temp_offset.dev_attr.attr,
> -	&iio_const_attr_in_temp_scale.dev_attr.attr,
> -	&iio_dev_attr_sampling_frequency.dev_attr.attr,
> -	&iio_const_attr_sampling_frequency_available.dev_attr.attr,
> -	&iio_dev_attr_phcal.dev_attr.attr,
> -	&iio_dev_attr_cfden.dev_attr.attr,
> -	&iio_dev_attr_aenergy.dev_attr.attr,
> -	&iio_dev_attr_laenergy.dev_attr.attr,
> -	&iio_dev_attr_vaenergy.dev_attr.attr,
> -	&iio_dev_attr_lvaenergy.dev_attr.attr,
> -	&iio_dev_attr_cfnum.dev_attr.attr,
> -	&iio_dev_attr_apos.dev_attr.attr,
> -	&iio_dev_attr_sagcyc.dev_attr.attr,
> -	&iio_dev_attr_saglvl.dev_attr.attr,
> -	&iio_dev_attr_linecyc.dev_attr.attr,
> -	&iio_dev_attr_chksum.dev_attr.attr,
> -	&iio_dev_attr_pga_gain.dev_attr.attr,
> -	&iio_dev_attr_wgain.dev_attr.attr,
> -	&iio_dev_attr_choff_1.dev_attr.attr,
> -	&iio_dev_attr_choff_2.dev_attr.attr,
> -	&iio_dev_attr_wdiv.dev_attr.attr,
> -	&iio_dev_attr_irms.dev_attr.attr,
> -	&iio_dev_attr_vrms.dev_attr.attr,
> -	&iio_dev_attr_irmsos.dev_attr.attr,
> -	&iio_dev_attr_vrmsos.dev_attr.attr,
> -	&iio_dev_attr_vagain.dev_attr.attr,
> -	&iio_dev_attr_ipklvl.dev_attr.attr,
> -	&iio_dev_attr_vpklvl.dev_attr.attr,
> -	&iio_dev_attr_ipeak.dev_attr.attr,
> -	&iio_dev_attr_vpeak.dev_attr.attr,
> -	&iio_dev_attr_vperiod.dev_attr.attr,
> -	NULL,
> -};
> -
> -static const struct attribute_group ade7753_attribute_group = {
> -	.attrs = ade7753_attributes,
> -};
> -
> -static const struct iio_info ade7753_info = {
> -	.attrs = &ade7753_attribute_group,
> -};
> -
> -static int ade7753_probe(struct spi_device *spi)
> -{
> -	int ret;
> -	struct ade7753_state *st;
> -	struct iio_dev *indio_dev;
> -
> -	/* setup the industrialio driver allocated elements */
> -	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> -	if (!indio_dev)
> -		return -ENOMEM;
> -	/* this is only used for removal purposes */
> -	spi_set_drvdata(spi, indio_dev);
> -
> -	st = iio_priv(indio_dev);
> -	st->us = spi;
> -	mutex_init(&st->buf_lock);
> -
> -	indio_dev->name = spi->dev.driver->name;
> -	indio_dev->dev.parent = &spi->dev;
> -	indio_dev->info = &ade7753_info;
> -	indio_dev->modes = INDIO_DIRECT_MODE;
> -
> -	/* Get the device into a sane initial state */
> -	ret = ade7753_initial_setup(indio_dev);
> -	if (ret)
> -		return ret;
> -
> -	return iio_device_register(indio_dev);
> -}
> -
> -static int ade7753_remove(struct spi_device *spi)
> -{
> -	struct iio_dev *indio_dev = spi_get_drvdata(spi);
> -
> -	iio_device_unregister(indio_dev);
> -	ade7753_stop_device(&indio_dev->dev);
> -
> -	return 0;
> -}
> -
> -static struct spi_driver ade7753_driver = {
> -	.driver = {
> -		.name = "ade7753",
> -	},
> -	.probe = ade7753_probe,
> -	.remove = ade7753_remove,
> -};
> -module_spi_driver(ade7753_driver);
> -
> -MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
> -MODULE_DESCRIPTION("Analog Devices ADE7753/6 Single-Phase Multifunction Meter");
> -MODULE_LICENSE("GPL v2");
> -MODULE_ALIAS("spi:ade7753");


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] staging:iio:meter: Drop ADE7754 driver
  2018-05-12 17:51 ` [PATCH 2/4] staging:iio:meter: Drop ADE7754 driver Jonathan Cameron
@ 2018-05-20 11:22   ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2018-05-20 11:22 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Rodrigo Siqueira, John Syne, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Hartmut Knaack, Michael Hennerich

On Sat, 12 May 2018 18:51:02 +0100
Jonathan Cameron <Jonathan.Cameron@huawei.com> wrote:

> I announced the intent to drop some of these meter drivers
> on the IIO list last cycle. This device is obsolete and not easily
> obtained.  No one has come forward with suitable test hardware and
> the driver would need a lot of work to move out of staging.
> 
> As such I am dropping it.  We can always bring it back again
> if a user / tester emerges in the future.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Applied

> ---
>  drivers/staging/iio/meter/Kconfig   |  10 -
>  drivers/staging/iio/meter/Makefile  |   2 -
>  drivers/staging/iio/meter/ade7754.c | 664 ----------------------------
>  3 files changed, 676 deletions(-)
> 
> diff --git a/drivers/staging/iio/meter/Kconfig b/drivers/staging/iio/meter/Kconfig
> index 62db8d6498f5..d60f052415c8 100644
> --- a/drivers/staging/iio/meter/Kconfig
> +++ b/drivers/staging/iio/meter/Kconfig
> @@ -3,16 +3,6 @@
>  #
>  menu "Active energy metering IC"
>  
> -config ADE7754
> -	tristate "Analog Devices ADE7754 Polyphase Multifunction Energy Metering IC Driver"
> -	depends on SPI
> -	help
> -	  Say yes here to build support for Analog Devices ADE7754 Polyphase
> -	  Multifunction Energy Metering IC Driver.
> -
> -	  To compile this driver as a module, choose M here: the
> -	  module will be called ade7754.
> -
>  config ADE7758
>  	tristate "Analog Devices ADE7758 Poly Phase Multifunction Energy Metering IC Driver"
>  	depends on SPI
> diff --git a/drivers/staging/iio/meter/Makefile b/drivers/staging/iio/meter/Makefile
> index 8b2592b32845..42f4157969de 100644
> --- a/drivers/staging/iio/meter/Makefile
> +++ b/drivers/staging/iio/meter/Makefile
> @@ -3,8 +3,6 @@
>  # Makefile for metering ic drivers
>  #
>  
> -obj-$(CONFIG_ADE7754) += ade7754.o
> -
>  ade7758-y             := ade7758_core.o
>  ade7758-$(CONFIG_IIO_BUFFER) += ade7758_ring.o ade7758_trigger.o
>  obj-$(CONFIG_ADE7758) += ade7758.o
> diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c
> deleted file mode 100644
> index 9aa067736715..000000000000
> --- a/drivers/staging/iio/meter/ade7754.c
> +++ /dev/null
> @@ -1,664 +0,0 @@
> -/*
> - * ADE7754 Polyphase Multifunction Energy Metering IC Driver
> - *
> - * Copyright 2010 Analog Devices Inc.
> - *
> - * Licensed under the GPL-2 or later.
> - */
> -
> -#include <linux/delay.h>
> -#include <linux/device.h>
> -#include <linux/interrupt.h>
> -#include <linux/irq.h>
> -#include <linux/kernel.h>
> -#include <linux/list.h>
> -#include <linux/module.h>
> -#include <linux/mutex.h>
> -#include <linux/spi/spi.h>
> -#include <linux/slab.h>
> -#include <linux/sysfs.h>
> -#include <linux/iio/iio.h>
> -#include <linux/iio/sysfs.h>
> -#include "meter.h"
> -
> -#define ADE7754_AENERGY   0x01
> -#define ADE7754_RAENERGY  0x02
> -#define ADE7754_LAENERGY  0x03
> -#define ADE7754_VAENERGY  0x04
> -#define ADE7754_RVAENERGY 0x05
> -#define ADE7754_LVAENERGY 0x06
> -#define ADE7754_PERIOD    0x07
> -#define ADE7754_TEMP      0x08
> -#define ADE7754_WFORM     0x09
> -#define ADE7754_OPMODE    0x0A
> -#define ADE7754_MMODE     0x0B
> -#define ADE7754_WAVMODE   0x0C
> -#define ADE7754_WATMODE   0x0D
> -#define ADE7754_VAMODE    0x0E
> -#define ADE7754_IRQEN     0x0F
> -#define ADE7754_STATUS    0x10
> -#define ADE7754_RSTATUS   0x11
> -#define ADE7754_ZXTOUT    0x12
> -#define ADE7754_LINCYC    0x13
> -#define ADE7754_SAGCYC    0x14
> -#define ADE7754_SAGLVL    0x15
> -#define ADE7754_VPEAK     0x16
> -#define ADE7754_IPEAK     0x17
> -#define ADE7754_GAIN      0x18
> -#define ADE7754_AWG       0x19
> -#define ADE7754_BWG       0x1A
> -#define ADE7754_CWG       0x1B
> -#define ADE7754_AVAG      0x1C
> -#define ADE7754_BVAG      0x1D
> -#define ADE7754_CVAG      0x1E
> -#define ADE7754_APHCAL    0x1F
> -#define ADE7754_BPHCAL    0x20
> -#define ADE7754_CPHCAL    0x21
> -#define ADE7754_AAPOS     0x22
> -#define ADE7754_BAPOS     0x23
> -#define ADE7754_CAPOS     0x24
> -#define ADE7754_CFNUM     0x25
> -#define ADE7754_CFDEN     0x26
> -#define ADE7754_WDIV      0x27
> -#define ADE7754_VADIV     0x28
> -#define ADE7754_AIRMS     0x29
> -#define ADE7754_BIRMS     0x2A
> -#define ADE7754_CIRMS     0x2B
> -#define ADE7754_AVRMS     0x2C
> -#define ADE7754_BVRMS     0x2D
> -#define ADE7754_CVRMS     0x2E
> -#define ADE7754_AIRMSOS   0x2F
> -#define ADE7754_BIRMSOS   0x30
> -#define ADE7754_CIRMSOS   0x31
> -#define ADE7754_AVRMSOS   0x32
> -#define ADE7754_BVRMSOS   0x33
> -#define ADE7754_CVRMSOS   0x34
> -#define ADE7754_AAPGAIN   0x35
> -#define ADE7754_BAPGAIN   0x36
> -#define ADE7754_CAPGAIN   0x37
> -#define ADE7754_AVGAIN    0x38
> -#define ADE7754_BVGAIN    0x39
> -#define ADE7754_CVGAIN    0x3A
> -#define ADE7754_CHKSUM    0x3E
> -#define ADE7754_VERSION   0x3F
> -
> -#define ADE7754_READ_REG(a)    a
> -#define ADE7754_WRITE_REG(a) ((a) | 0x80)
> -
> -#define ADE7754_MAX_TX    4
> -#define ADE7754_MAX_RX    4
> -#define ADE7754_STARTUP_DELAY 1000
> -
> -#define ADE7754_SPI_SLOW	(u32)(300 * 1000)
> -#define ADE7754_SPI_BURST	(u32)(1000 * 1000)
> -#define ADE7754_SPI_FAST	(u32)(2000 * 1000)
> -
> -/**
> - * struct ade7754_state - device instance specific data
> - * @us:			actual spi_device
> - * @buf_lock:		mutex to protect tx, rx and write frequency
> - * @tx:			transmit buffer
> - * @rx:			receive buffer
> - **/
> -struct ade7754_state {
> -	struct spi_device	*us;
> -	struct mutex		buf_lock;
> -	u8			tx[ADE7754_MAX_TX] ____cacheline_aligned;
> -	u8			rx[ADE7754_MAX_RX];
> -};
> -
> -/* Unlocked version of ade7754_spi_write_reg_8 function */
> -static int __ade7754_spi_write_reg_8(struct device *dev, u8 reg_address, u8 val)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7754_state *st = iio_priv(indio_dev);
> -
> -	st->tx[0] = ADE7754_WRITE_REG(reg_address);
> -	st->tx[1] = val;
> -	return spi_write(st->us, st->tx, 2);
> -}
> -
> -static int ade7754_spi_write_reg_8(struct device *dev, u8 reg_address, u8 val)
> -{
> -	int ret;
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7754_state *st = iio_priv(indio_dev);
> -
> -	mutex_lock(&st->buf_lock);
> -	ret = __ade7754_spi_write_reg_8(dev, reg_address, val);
> -	mutex_unlock(&st->buf_lock);
> -
> -	return ret;
> -}
> -
> -static int ade7754_spi_write_reg_16(struct device *dev,
> -				    u8 reg_address, u16 val)
> -{
> -	int ret;
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7754_state *st = iio_priv(indio_dev);
> -
> -	mutex_lock(&st->buf_lock);
> -	st->tx[0] = ADE7754_WRITE_REG(reg_address);
> -	st->tx[1] = (val >> 8) & 0xFF;
> -	st->tx[2] = val & 0xFF;
> -	ret = spi_write(st->us, st->tx, 3);
> -	mutex_unlock(&st->buf_lock);
> -
> -	return ret;
> -}
> -
> -static int ade7754_spi_read_reg_8(struct device *dev, u8 reg_address, u8 *val)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7754_state *st = iio_priv(indio_dev);
> -	int ret;
> -
> -	ret = spi_w8r8(st->us, ADE7754_READ_REG(reg_address));
> -	if (ret < 0) {
> -		dev_err(&st->us->dev, "problem when reading 8 bit register 0x%02X",
> -			reg_address);
> -		return ret;
> -	}
> -	*val = ret;
> -
> -	return 0;
> -}
> -
> -static int ade7754_spi_read_reg_16(struct device *dev,
> -				   u8 reg_address, u16 *val)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7754_state *st = iio_priv(indio_dev);
> -	int ret;
> -
> -	ret = spi_w8r16be(st->us, ADE7754_READ_REG(reg_address));
> -	if (ret < 0) {
> -		dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
> -			reg_address);
> -		return ret;
> -	}
> -
> -	*val = ret;
> -
> -	return 0;
> -}
> -
> -static int ade7754_spi_read_reg_24(struct device *dev,
> -				   u8 reg_address, u32 *val)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7754_state *st = iio_priv(indio_dev);
> -	int ret;
> -	struct spi_transfer xfers[] = {
> -		{
> -			.tx_buf = st->tx,
> -			.rx_buf = st->rx,
> -			.bits_per_word = 8,
> -			.len = 4,
> -		},
> -	};
> -
> -	mutex_lock(&st->buf_lock);
> -	st->tx[0] = ADE7754_READ_REG(reg_address);
> -	st->tx[1] = 0;
> -	st->tx[2] = 0;
> -	st->tx[3] = 0;
> -
> -	ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
> -	if (ret) {
> -		dev_err(&st->us->dev, "problem when reading 24 bit register 0x%02X",
> -			reg_address);
> -		goto error_ret;
> -	}
> -	*val = (st->rx[1] << 16) | (st->rx[2] << 8) | st->rx[3];
> -
> -error_ret:
> -	mutex_unlock(&st->buf_lock);
> -	return ret;
> -}
> -
> -static ssize_t ade7754_read_8bit(struct device *dev,
> -				 struct device_attribute *attr,
> -				 char *buf)
> -{
> -	int ret;
> -	u8 val = 0;
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -
> -	ret = ade7754_spi_read_reg_8(dev, this_attr->address, &val);
> -	if (ret)
> -		return ret;
> -
> -	return sprintf(buf, "%u\n", val);
> -}
> -
> -static ssize_t ade7754_read_16bit(struct device *dev,
> -				  struct device_attribute *attr,
> -				  char *buf)
> -{
> -	int ret;
> -	u16 val = 0;
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -
> -	ret = ade7754_spi_read_reg_16(dev, this_attr->address, &val);
> -	if (ret)
> -		return ret;
> -
> -	return sprintf(buf, "%u\n", val);
> -}
> -
> -static ssize_t ade7754_read_24bit(struct device *dev,
> -				  struct device_attribute *attr,
> -				  char *buf)
> -{
> -	int ret;
> -	u32 val = 0;
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -
> -	ret = ade7754_spi_read_reg_24(dev, this_attr->address, &val);
> -	if (ret)
> -		return ret;
> -
> -	return sprintf(buf, "%u\n", val & 0xFFFFFF);
> -}
> -
> -static ssize_t ade7754_write_8bit(struct device *dev,
> -				  struct device_attribute *attr,
> -				  const char *buf,
> -				  size_t len)
> -{
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -	int ret;
> -	u8 val;
> -
> -	ret = kstrtou8(buf, 10, &val);
> -	if (ret)
> -		goto error_ret;
> -	ret = ade7754_spi_write_reg_8(dev, this_attr->address, val);
> -
> -error_ret:
> -	return ret ? ret : len;
> -}
> -
> -static ssize_t ade7754_write_16bit(struct device *dev,
> -				   struct device_attribute *attr,
> -				   const char *buf,
> -				   size_t len)
> -{
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -	int ret;
> -	u16 val;
> -
> -	ret = kstrtou16(buf, 10, &val);
> -	if (ret)
> -		goto error_ret;
> -	ret = ade7754_spi_write_reg_16(dev, this_attr->address, val);
> -
> -error_ret:
> -	return ret ? ret : len;
> -}
> -
> -static int ade7754_reset(struct device *dev)
> -{
> -	int ret;
> -	u8 val;
> -
> -	ret = ade7754_spi_read_reg_8(dev, ADE7754_OPMODE, &val);
> -	if (ret < 0)
> -		return ret;
> -
> -	val |= BIT(6); /* Software Chip Reset */
> -	return ade7754_spi_write_reg_8(dev, ADE7754_OPMODE, val);
> -}
> -
> -static IIO_DEV_ATTR_AENERGY(ade7754_read_24bit, ADE7754_AENERGY);
> -static IIO_DEV_ATTR_LAENERGY(ade7754_read_24bit, ADE7754_LAENERGY);
> -static IIO_DEV_ATTR_VAENERGY(ade7754_read_24bit, ADE7754_VAENERGY);
> -static IIO_DEV_ATTR_LVAENERGY(ade7754_read_24bit, ADE7754_LVAENERGY);
> -static IIO_DEV_ATTR_VPEAK(0644,
> -		ade7754_read_8bit,
> -		ade7754_write_8bit,
> -		ADE7754_VPEAK);
> -static IIO_DEV_ATTR_IPEAK(0644,
> -		ade7754_read_8bit,
> -		ade7754_write_8bit,
> -		ADE7754_VPEAK);
> -static IIO_DEV_ATTR_APHCAL(0644,
> -		ade7754_read_8bit,
> -		ade7754_write_8bit,
> -		ADE7754_APHCAL);
> -static IIO_DEV_ATTR_BPHCAL(0644,
> -		ade7754_read_8bit,
> -		ade7754_write_8bit,
> -		ADE7754_BPHCAL);
> -static IIO_DEV_ATTR_CPHCAL(0644,
> -		ade7754_read_8bit,
> -		ade7754_write_8bit,
> -		ADE7754_CPHCAL);
> -static IIO_DEV_ATTR_AAPOS(0644,
> -		ade7754_read_16bit,
> -		ade7754_write_16bit,
> -		ADE7754_AAPOS);
> -static IIO_DEV_ATTR_BAPOS(0644,
> -		ade7754_read_16bit,
> -		ade7754_write_16bit,
> -		ADE7754_BAPOS);
> -static IIO_DEV_ATTR_CAPOS(0644,
> -		ade7754_read_16bit,
> -		ade7754_write_16bit,
> -		ADE7754_CAPOS);
> -static IIO_DEV_ATTR_WDIV(0644,
> -		ade7754_read_8bit,
> -		ade7754_write_8bit,
> -		ADE7754_WDIV);
> -static IIO_DEV_ATTR_VADIV(0644,
> -		ade7754_read_8bit,
> -		ade7754_write_8bit,
> -		ADE7754_VADIV);
> -static IIO_DEV_ATTR_CFNUM(0644,
> -		ade7754_read_16bit,
> -		ade7754_write_16bit,
> -		ADE7754_CFNUM);
> -static IIO_DEV_ATTR_CFDEN(0644,
> -		ade7754_read_16bit,
> -		ade7754_write_16bit,
> -		ADE7754_CFDEN);
> -static IIO_DEV_ATTR_ACTIVE_POWER_A_GAIN(0644,
> -		ade7754_read_16bit,
> -		ade7754_write_16bit,
> -		ADE7754_AAPGAIN);
> -static IIO_DEV_ATTR_ACTIVE_POWER_B_GAIN(0644,
> -		ade7754_read_16bit,
> -		ade7754_write_16bit,
> -		ADE7754_BAPGAIN);
> -static IIO_DEV_ATTR_ACTIVE_POWER_C_GAIN(0644,
> -		ade7754_read_16bit,
> -		ade7754_write_16bit,
> -		ADE7754_CAPGAIN);
> -static IIO_DEV_ATTR_AIRMS(0444,
> -		ade7754_read_24bit,
> -		NULL,
> -		ADE7754_AIRMS);
> -static IIO_DEV_ATTR_BIRMS(0444,
> -		ade7754_read_24bit,
> -		NULL,
> -		ADE7754_BIRMS);
> -static IIO_DEV_ATTR_CIRMS(0444,
> -		ade7754_read_24bit,
> -		NULL,
> -		ADE7754_CIRMS);
> -static IIO_DEV_ATTR_AVRMS(0444,
> -		ade7754_read_24bit,
> -		NULL,
> -		ADE7754_AVRMS);
> -static IIO_DEV_ATTR_BVRMS(0444,
> -		ade7754_read_24bit,
> -		NULL,
> -		ADE7754_BVRMS);
> -static IIO_DEV_ATTR_CVRMS(0444,
> -		ade7754_read_24bit,
> -		NULL,
> -		ADE7754_CVRMS);
> -static IIO_DEV_ATTR_AIRMSOS(0444,
> -		ade7754_read_16bit,
> -		ade7754_write_16bit,
> -		ADE7754_AIRMSOS);
> -static IIO_DEV_ATTR_BIRMSOS(0444,
> -		ade7754_read_16bit,
> -		ade7754_write_16bit,
> -		ADE7754_BIRMSOS);
> -static IIO_DEV_ATTR_CIRMSOS(0444,
> -		ade7754_read_16bit,
> -		ade7754_write_16bit,
> -		ADE7754_CIRMSOS);
> -static IIO_DEV_ATTR_AVRMSOS(0444,
> -		ade7754_read_16bit,
> -		ade7754_write_16bit,
> -		ADE7754_AVRMSOS);
> -static IIO_DEV_ATTR_BVRMSOS(0444,
> -		ade7754_read_16bit,
> -		ade7754_write_16bit,
> -		ADE7754_BVRMSOS);
> -static IIO_DEV_ATTR_CVRMSOS(0444,
> -		ade7754_read_16bit,
> -		ade7754_write_16bit,
> -		ADE7754_CVRMSOS);
> -
> -static int ade7754_set_irq(struct device *dev, bool enable)
> -{
> -	int ret;
> -	u16 irqen;
> -
> -	ret = ade7754_spi_read_reg_16(dev, ADE7754_IRQEN, &irqen);
> -	if (ret)
> -		return ret;
> -
> -	if (enable)
> -		irqen |= BIT(14); /* Enables an interrupt when a data is
> -				   * present in the waveform register
> -				   */
> -	else
> -		irqen &= ~BIT(14);
> -
> -	return ade7754_spi_write_reg_16(dev, ADE7754_IRQEN, irqen);
> -}
> -
> -/* Power down the device */
> -static int ade7754_stop_device(struct device *dev)
> -{
> -	int ret;
> -	u8 val;
> -
> -	ret = ade7754_spi_read_reg_8(dev, ADE7754_OPMODE, &val);
> -	if (ret < 0) {
> -		dev_err(dev, "unable to power down the device, error: %d",
> -			ret);
> -		return ret;
> -	}
> -
> -	val |= 7 << 3;  /* ADE7754 powered down */
> -	return ade7754_spi_write_reg_8(dev, ADE7754_OPMODE, val);
> -}
> -
> -static int ade7754_initial_setup(struct iio_dev *indio_dev)
> -{
> -	int ret;
> -	struct ade7754_state *st = iio_priv(indio_dev);
> -	struct device *dev = &indio_dev->dev;
> -
> -	/* use low spi speed for init */
> -	st->us->mode = SPI_MODE_3;
> -	spi_setup(st->us);
> -
> -	/* Disable IRQ */
> -	ret = ade7754_set_irq(dev, false);
> -	if (ret) {
> -		dev_err(dev, "disable irq failed");
> -		goto err_ret;
> -	}
> -
> -	ade7754_reset(dev);
> -	usleep_range(ADE7754_STARTUP_DELAY, ADE7754_STARTUP_DELAY + 100);
> -
> -err_ret:
> -	return ret;
> -}
> -
> -static ssize_t ade7754_read_frequency(struct device *dev,
> -				      struct device_attribute *attr,
> -				      char *buf)
> -{
> -	int ret;
> -	u8 t;
> -	int sps;
> -
> -	ret = ade7754_spi_read_reg_8(dev, ADE7754_WAVMODE, &t);
> -	if (ret)
> -		return ret;
> -
> -	t = (t >> 3) & 0x3;
> -	sps = 26000 / (1 + t);
> -
> -	return sprintf(buf, "%d\n", sps);
> -}
> -
> -static ssize_t ade7754_write_frequency(struct device *dev,
> -				       struct device_attribute *attr,
> -				       const char *buf,
> -				       size_t len)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7754_state *st = iio_priv(indio_dev);
> -	u16 val;
> -	int ret;
> -	u8 reg, t;
> -
> -	ret = kstrtou16(buf, 10, &val);
> -	if (ret)
> -		return ret;
> -	if (!val)
> -		return -EINVAL;
> -
> -	mutex_lock(&st->buf_lock);
> -
> -	t = 26000 / val;
> -	if (t > 0)
> -		t--;
> -
> -	if (t > 1)
> -		st->us->max_speed_hz = ADE7754_SPI_SLOW;
> -	else
> -		st->us->max_speed_hz = ADE7754_SPI_FAST;
> -
> -	ret = ade7754_spi_read_reg_8(dev, ADE7754_WAVMODE, &reg);
> -	if (ret)
> -		goto out;
> -
> -	reg &= ~(3 << 3);
> -	reg |= t << 3;
> -
> -	ret = __ade7754_spi_write_reg_8(dev, ADE7754_WAVMODE, reg);
> -
> -out:
> -	mutex_unlock(&st->buf_lock);
> -
> -	return ret ? ret : len;
> -}
> -static IIO_DEV_ATTR_TEMP_RAW(ade7754_read_8bit);
> -static IIO_CONST_ATTR(in_temp_offset, "129 C");
> -static IIO_CONST_ATTR(in_temp_scale, "4 C");
> -
> -static IIO_DEV_ATTR_SAMP_FREQ(0644,
> -		ade7754_read_frequency,
> -		ade7754_write_frequency);
> -
> -static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("26000 13000 65000 33000");
> -
> -static struct attribute *ade7754_attributes[] = {
> -	&iio_dev_attr_in_temp_raw.dev_attr.attr,
> -	&iio_const_attr_in_temp_offset.dev_attr.attr,
> -	&iio_const_attr_in_temp_scale.dev_attr.attr,
> -	&iio_dev_attr_sampling_frequency.dev_attr.attr,
> -	&iio_const_attr_sampling_frequency_available.dev_attr.attr,
> -	&iio_dev_attr_aenergy.dev_attr.attr,
> -	&iio_dev_attr_laenergy.dev_attr.attr,
> -	&iio_dev_attr_vaenergy.dev_attr.attr,
> -	&iio_dev_attr_lvaenergy.dev_attr.attr,
> -	&iio_dev_attr_vpeak.dev_attr.attr,
> -	&iio_dev_attr_ipeak.dev_attr.attr,
> -	&iio_dev_attr_aphcal.dev_attr.attr,
> -	&iio_dev_attr_bphcal.dev_attr.attr,
> -	&iio_dev_attr_cphcal.dev_attr.attr,
> -	&iio_dev_attr_aapos.dev_attr.attr,
> -	&iio_dev_attr_bapos.dev_attr.attr,
> -	&iio_dev_attr_capos.dev_attr.attr,
> -	&iio_dev_attr_wdiv.dev_attr.attr,
> -	&iio_dev_attr_vadiv.dev_attr.attr,
> -	&iio_dev_attr_cfnum.dev_attr.attr,
> -	&iio_dev_attr_cfden.dev_attr.attr,
> -	&iio_dev_attr_active_power_a_gain.dev_attr.attr,
> -	&iio_dev_attr_active_power_b_gain.dev_attr.attr,
> -	&iio_dev_attr_active_power_c_gain.dev_attr.attr,
> -	&iio_dev_attr_airms.dev_attr.attr,
> -	&iio_dev_attr_birms.dev_attr.attr,
> -	&iio_dev_attr_cirms.dev_attr.attr,
> -	&iio_dev_attr_avrms.dev_attr.attr,
> -	&iio_dev_attr_bvrms.dev_attr.attr,
> -	&iio_dev_attr_cvrms.dev_attr.attr,
> -	&iio_dev_attr_airmsos.dev_attr.attr,
> -	&iio_dev_attr_birmsos.dev_attr.attr,
> -	&iio_dev_attr_cirmsos.dev_attr.attr,
> -	&iio_dev_attr_avrmsos.dev_attr.attr,
> -	&iio_dev_attr_bvrmsos.dev_attr.attr,
> -	&iio_dev_attr_cvrmsos.dev_attr.attr,
> -	NULL,
> -};
> -
> -static const struct attribute_group ade7754_attribute_group = {
> -	.attrs = ade7754_attributes,
> -};
> -
> -static const struct iio_info ade7754_info = {
> -	.attrs = &ade7754_attribute_group,
> -};
> -
> -static int ade7754_probe(struct spi_device *spi)
> -{
> -	int ret;
> -	struct ade7754_state *st;
> -	struct iio_dev *indio_dev;
> -
> -	/* setup the industrialio driver allocated elements */
> -	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> -	if (!indio_dev)
> -		return -ENOMEM;
> -	/* this is only used for removal purposes */
> -	spi_set_drvdata(spi, indio_dev);
> -
> -	st = iio_priv(indio_dev);
> -	st->us = spi;
> -	mutex_init(&st->buf_lock);
> -
> -	indio_dev->name = spi->dev.driver->name;
> -	indio_dev->dev.parent = &spi->dev;
> -	indio_dev->info = &ade7754_info;
> -	indio_dev->modes = INDIO_DIRECT_MODE;
> -
> -	/* Get the device into a sane initial state */
> -	ret = ade7754_initial_setup(indio_dev);
> -	if (ret)
> -		goto powerdown_on_error;
> -	ret = iio_device_register(indio_dev);
> -	if (ret)
> -		goto powerdown_on_error;
> -	return ret;
> -
> -powerdown_on_error:
> -	ade7754_stop_device(&indio_dev->dev);
> -	return ret;
> -}
> -
> -static int ade7754_remove(struct spi_device *spi)
> -{
> -	struct iio_dev *indio_dev = spi_get_drvdata(spi);
> -
> -	iio_device_unregister(indio_dev);
> -	ade7754_stop_device(&indio_dev->dev);
> -
> -	return 0;
> -}
> -
> -static struct spi_driver ade7754_driver = {
> -	.driver = {
> -		.name = "ade7754",
> -	},
> -	.probe = ade7754_probe,
> -	.remove = ade7754_remove,
> -};
> -module_spi_driver(ade7754_driver);
> -
> -MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
> -MODULE_DESCRIPTION("Analog Devices ADE7754 Polyphase Multifunction Energy Metering IC Driver");
> -MODULE_LICENSE("GPL v2");
> -MODULE_ALIAS("spi:ad7754");


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/4] staging:iio:meter: Drop ADE7758 driver
  2018-05-12 17:51 ` [PATCH 3/4] staging:iio:meter: Drop ADE7758 driver Jonathan Cameron
@ 2018-05-20 11:22   ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2018-05-20 11:22 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Rodrigo Siqueira, John Syne, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Hartmut Knaack, Michael Hennerich

On Sat, 12 May 2018 18:51:03 +0100
Jonathan Cameron <Jonathan.Cameron@huawei.com> wrote:

> I announced the intent to drop some of these meter drivers
> on the IIO list last cycle. This device is obsolete and not easily
> obtained.  No one has come forward with suitable test hardware and
> the driver would need a lot of work to move out of staging.
> 
> As such I am dropping it.  We can always bring it back again
> if a user / tester emerges in the future.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Applied.
> ---
>  drivers/staging/iio/meter/Kconfig           |  12 -
>  drivers/staging/iio/meter/Makefile          |   4 -
>  drivers/staging/iio/meter/ade7758.h         | 183 ----
>  drivers/staging/iio/meter/ade7758_core.c    | 955 --------------------
>  drivers/staging/iio/meter/ade7758_ring.c    | 177 ----
>  drivers/staging/iio/meter/ade7758_trigger.c | 108 ---
>  6 files changed, 1439 deletions(-)
> 
> diff --git a/drivers/staging/iio/meter/Kconfig b/drivers/staging/iio/meter/Kconfig
> index d60f052415c8..451ac47bb0cc 100644
> --- a/drivers/staging/iio/meter/Kconfig
> +++ b/drivers/staging/iio/meter/Kconfig
> @@ -3,18 +3,6 @@
>  #
>  menu "Active energy metering IC"
>  
> -config ADE7758
> -	tristate "Analog Devices ADE7758 Poly Phase Multifunction Energy Metering IC Driver"
> -	depends on SPI
> -	select IIO_TRIGGER if IIO_BUFFER
> -	select IIO_KFIFO_BUF if IIO_BUFFER
> -	help
> -	  Say yes here to build support for Analog Devices ADE7758 Polyphase
> -	  Multifunction Energy Metering IC with Per Phase Information Driver.
> -
> -	  To compile this driver as a module, choose M here: the
> -	  module will be called ade7758.
> -
>  config ADE7759
>  	tristate "Analog Devices ADE7759 Active Energy Metering IC Driver"
>  	depends on SPI
> diff --git a/drivers/staging/iio/meter/Makefile b/drivers/staging/iio/meter/Makefile
> index 42f4157969de..a36ff1668275 100644
> --- a/drivers/staging/iio/meter/Makefile
> +++ b/drivers/staging/iio/meter/Makefile
> @@ -3,10 +3,6 @@
>  # Makefile for metering ic drivers
>  #
>  
> -ade7758-y             := ade7758_core.o
> -ade7758-$(CONFIG_IIO_BUFFER) += ade7758_ring.o ade7758_trigger.o
> -obj-$(CONFIG_ADE7758) += ade7758.o
> -
>  obj-$(CONFIG_ADE7759) += ade7759.o
>  obj-$(CONFIG_ADE7854) += ade7854.o
>  obj-$(CONFIG_ADE7854_I2C) += ade7854-i2c.o
> diff --git a/drivers/staging/iio/meter/ade7758.h b/drivers/staging/iio/meter/ade7758.h
> deleted file mode 100644
> index 2de81b53e786..000000000000
> --- a/drivers/staging/iio/meter/ade7758.h
> +++ /dev/null
> @@ -1,183 +0,0 @@
> -/*
> - * ADE7758 Poly Phase Multifunction Energy Metering IC driver
> - *
> - * Copyright 2010-2011 Analog Devices Inc.
> - *
> - * Licensed under the GPL-2.
> - */
> -
> -#ifndef _ADE7758_H
> -#define _ADE7758_H
> -
> -#define ADE7758_AWATTHR   0x01
> -#define ADE7758_BWATTHR   0x02
> -#define ADE7758_CWATTHR   0x03
> -#define ADE7758_AVARHR    0x04
> -#define ADE7758_BVARHR    0x05
> -#define ADE7758_CVARHR    0x06
> -#define ADE7758_AVAHR     0x07
> -#define ADE7758_BVAHR     0x08
> -#define ADE7758_CVAHR     0x09
> -#define ADE7758_AIRMS     0x0A
> -#define ADE7758_BIRMS     0x0B
> -#define ADE7758_CIRMS     0x0C
> -#define ADE7758_AVRMS     0x0D
> -#define ADE7758_BVRMS     0x0E
> -#define ADE7758_CVRMS     0x0F
> -#define ADE7758_FREQ      0x10
> -#define ADE7758_TEMP      0x11
> -#define ADE7758_WFORM     0x12
> -#define ADE7758_OPMODE    0x13
> -#define ADE7758_MMODE     0x14
> -#define ADE7758_WAVMODE   0x15
> -#define ADE7758_COMPMODE  0x16
> -#define ADE7758_LCYCMODE  0x17
> -#define ADE7758_MASK      0x18
> -#define ADE7758_STATUS    0x19
> -#define ADE7758_RSTATUS   0x1A
> -#define ADE7758_ZXTOUT    0x1B
> -#define ADE7758_LINECYC   0x1C
> -#define ADE7758_SAGCYC    0x1D
> -#define ADE7758_SAGLVL    0x1E
> -#define ADE7758_VPINTLVL  0x1F
> -#define ADE7758_IPINTLVL  0x20
> -#define ADE7758_VPEAK     0x21
> -#define ADE7758_IPEAK     0x22
> -#define ADE7758_GAIN      0x23
> -#define ADE7758_AVRMSGAIN 0x24
> -#define ADE7758_BVRMSGAIN 0x25
> -#define ADE7758_CVRMSGAIN 0x26
> -#define ADE7758_AIGAIN    0x27
> -#define ADE7758_BIGAIN    0x28
> -#define ADE7758_CIGAIN    0x29
> -#define ADE7758_AWG       0x2A
> -#define ADE7758_BWG       0x2B
> -#define ADE7758_CWG       0x2C
> -#define ADE7758_AVARG     0x2D
> -#define ADE7758_BVARG     0x2E
> -#define ADE7758_CVARG     0x2F
> -#define ADE7758_AVAG      0x30
> -#define ADE7758_BVAG      0x31
> -#define ADE7758_CVAG      0x32
> -#define ADE7758_AVRMSOS   0x33
> -#define ADE7758_BVRMSOS   0x34
> -#define ADE7758_CVRMSOS   0x35
> -#define ADE7758_AIRMSOS   0x36
> -#define ADE7758_BIRMSOS   0x37
> -#define ADE7758_CIRMSOS   0x38
> -#define ADE7758_AWAITOS   0x39
> -#define ADE7758_BWAITOS   0x3A
> -#define ADE7758_CWAITOS   0x3B
> -#define ADE7758_AVAROS    0x3C
> -#define ADE7758_BVAROS    0x3D
> -#define ADE7758_CVAROS    0x3E
> -#define ADE7758_APHCAL    0x3F
> -#define ADE7758_BPHCAL    0x40
> -#define ADE7758_CPHCAL    0x41
> -#define ADE7758_WDIV      0x42
> -#define ADE7758_VADIV     0x44
> -#define ADE7758_VARDIV    0x43
> -#define ADE7758_APCFNUM   0x45
> -#define ADE7758_APCFDEN   0x46
> -#define ADE7758_VARCFNUM  0x47
> -#define ADE7758_VARCFDEN  0x48
> -#define ADE7758_CHKSUM    0x7E
> -#define ADE7758_VERSION   0x7F
> -
> -#define ADE7758_READ_REG(a)    a
> -#define ADE7758_WRITE_REG(a) ((a) | 0x80)
> -
> -#define ADE7758_MAX_TX    8
> -#define ADE7758_MAX_RX    4
> -#define ADE7758_STARTUP_DELAY 1000
> -
> -#define AD7758_NUM_WAVSEL	5
> -#define AD7758_NUM_PHSEL	3
> -#define AD7758_NUM_WAVESRC	(AD7758_NUM_WAVSEL * AD7758_NUM_PHSEL)
> -
> -#define AD7758_PHASE_A		0
> -#define AD7758_PHASE_B		1
> -#define AD7758_PHASE_C		2
> -#define AD7758_CURRENT		0
> -#define AD7758_VOLTAGE		1
> -#define AD7758_ACT_PWR		2
> -#define AD7758_REACT_PWR	3
> -#define AD7758_APP_PWR		4
> -#define AD7758_WT(p, w)		(((w) << 2) | (p))
> -
> -/**
> - * struct ade7758_state - device instance specific data
> - * @us:			actual spi_device
> - * @trig:		data ready trigger registered with iio
> - * @tx:			transmit buffer
> - * @rx:			receive buffer
> - * @buf_lock:		mutex to protect tx, rx, read and write frequency
> - **/
> -struct ade7758_state {
> -	struct spi_device	*us;
> -	struct iio_trigger	*trig;
> -	u8			*tx;
> -	u8			*rx;
> -	struct mutex		buf_lock;
> -	struct spi_transfer	ring_xfer[4];
> -	struct spi_message	ring_msg;
> -	/*
> -	 * DMA (thus cache coherency maintenance) requires the
> -	 * transfer buffers to live in their own cache lines.
> -	 */
> -	unsigned char		rx_buf[8] ____cacheline_aligned;
> -	unsigned char		tx_buf[8];
> -
> -};
> -
> -#ifdef CONFIG_IIO_BUFFER
> -/* At the moment triggers are only used for ring buffer
> - * filling. This may change!
> - */
> -
> -void ade7758_remove_trigger(struct iio_dev *indio_dev);
> -int ade7758_probe_trigger(struct iio_dev *indio_dev);
> -
> -ssize_t ade7758_read_data_from_ring(struct device *dev,
> -				    struct device_attribute *attr, char *buf);
> -
> -int ade7758_configure_ring(struct iio_dev *indio_dev);
> -void ade7758_unconfigure_ring(struct iio_dev *indio_dev);
> -
> -int ade7758_set_irq(struct device *dev, bool enable);
> -
> -int ade7758_spi_write_reg_8(struct device *dev, u8 reg_address, u8 val);
> -int ade7758_spi_read_reg_8(struct device *dev, u8 reg_address, u8 *val);
> -
> -#else /* CONFIG_IIO_BUFFER */
> -
> -static inline void ade7758_remove_trigger(struct iio_dev *indio_dev)
> -{
> -}
> -
> -static inline int ade7758_probe_trigger(struct iio_dev *indio_dev)
> -{
> -	return 0;
> -}
> -
> -static int ade7758_configure_ring(struct iio_dev *indio_dev)
> -{
> -	return 0;
> -}
> -
> -static inline void ade7758_unconfigure_ring(struct iio_dev *indio_dev)
> -{
> -}
> -
> -static inline int ade7758_initialize_ring(struct iio_ring_buffer *ring)
> -{
> -	return 0;
> -}
> -
> -static inline void ade7758_uninitialize_ring(struct iio_dev *indio_dev)
> -{
> -}
> -
> -#endif /* CONFIG_IIO_BUFFER */
> -
> -#endif
> diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c
> deleted file mode 100644
> index 4e0dbf5c5705..000000000000
> --- a/drivers/staging/iio/meter/ade7758_core.c
> +++ /dev/null
> @@ -1,955 +0,0 @@
> -/*
> - * ADE7758 Poly Phase Multifunction Energy Metering IC driver
> - *
> - * Copyright 2010-2011 Analog Devices Inc.
> - *
> - * Licensed under the GPL-2.
> - */
> -
> -#include <linux/interrupt.h>
> -#include <linux/irq.h>
> -#include <linux/delay.h>
> -#include <linux/mutex.h>
> -#include <linux/device.h>
> -#include <linux/kernel.h>
> -#include <linux/spi/spi.h>
> -#include <linux/slab.h>
> -#include <linux/sysfs.h>
> -#include <linux/list.h>
> -#include <linux/module.h>
> -
> -#include <linux/iio/iio.h>
> -#include <linux/iio/sysfs.h>
> -#include <linux/iio/buffer.h>
> -#include "meter.h"
> -#include "ade7758.h"
> -
> -static int __ade7758_spi_write_reg_8(struct device *dev, u8 reg_address, u8 val)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7758_state *st = iio_priv(indio_dev);
> -
> -	st->tx[0] = ADE7758_WRITE_REG(reg_address);
> -	st->tx[1] = val;
> -
> -	return spi_write(st->us, st->tx, 2);
> -}
> -
> -int ade7758_spi_write_reg_8(struct device *dev, u8 reg_address, u8 val)
> -{
> -	int ret;
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7758_state *st = iio_priv(indio_dev);
> -
> -	mutex_lock(&st->buf_lock);
> -	ret = __ade7758_spi_write_reg_8(dev, reg_address, val);
> -	mutex_unlock(&st->buf_lock);
> -
> -	return ret;
> -}
> -
> -static int ade7758_spi_write_reg_16(struct device *dev, u8 reg_address,
> -				    u16 value)
> -{
> -	int ret;
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7758_state *st = iio_priv(indio_dev);
> -	struct spi_transfer xfers[] = {
> -		{
> -			.tx_buf = st->tx,
> -			.bits_per_word = 8,
> -			.len = 3,
> -		}
> -	};
> -
> -	mutex_lock(&st->buf_lock);
> -	st->tx[0] = ADE7758_WRITE_REG(reg_address);
> -	st->tx[1] = (value >> 8) & 0xFF;
> -	st->tx[2] = value & 0xFF;
> -
> -	ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
> -	mutex_unlock(&st->buf_lock);
> -
> -	return ret;
> -}
> -
> -static int ade7758_spi_write_reg_24(struct device *dev, u8 reg_address,
> -				    u32 value)
> -{
> -	int ret;
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7758_state *st = iio_priv(indio_dev);
> -	struct spi_transfer xfers[] = {
> -		{
> -			.tx_buf = st->tx,
> -			.bits_per_word = 8,
> -			.len = 4,
> -		}
> -	};
> -
> -	mutex_lock(&st->buf_lock);
> -	st->tx[0] = ADE7758_WRITE_REG(reg_address);
> -	st->tx[1] = (value >> 16) & 0xFF;
> -	st->tx[2] = (value >> 8) & 0xFF;
> -	st->tx[3] = value & 0xFF;
> -
> -	ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
> -	mutex_unlock(&st->buf_lock);
> -
> -	return ret;
> -}
> -
> -static int __ade7758_spi_read_reg_8(struct device *dev, u8 reg_address, u8 *val)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7758_state *st = iio_priv(indio_dev);
> -	int ret;
> -	struct spi_transfer xfers[] = {
> -		{
> -			.tx_buf = st->tx,
> -			.bits_per_word = 8,
> -			.len = 1,
> -			.delay_usecs = 4,
> -		},
> -		{
> -			.tx_buf = &st->tx[1],
> -			.rx_buf = st->rx,
> -			.bits_per_word = 8,
> -			.len = 1,
> -		},
> -	};
> -
> -	st->tx[0] = ADE7758_READ_REG(reg_address);
> -	st->tx[1] = 0;
> -
> -	ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
> -	if (ret) {
> -		dev_err(&st->us->dev, "problem when reading 8 bit register 0x%02X",
> -			reg_address);
> -		goto error_ret;
> -	}
> -	*val = st->rx[0];
> -
> -error_ret:
> -	return ret;
> -}
> -
> -int ade7758_spi_read_reg_8(struct device *dev, u8 reg_address, u8 *val)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7758_state *st = iio_priv(indio_dev);
> -	int ret;
> -
> -	mutex_lock(&st->buf_lock);
> -	ret = __ade7758_spi_read_reg_8(dev, reg_address, val);
> -	mutex_unlock(&st->buf_lock);
> -
> -	return ret;
> -}
> -
> -static int ade7758_spi_read_reg_16(struct device *dev, u8 reg_address,
> -				   u16 *val)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7758_state *st = iio_priv(indio_dev);
> -	int ret;
> -	struct spi_transfer xfers[] = {
> -		{
> -			.tx_buf = st->tx,
> -			.bits_per_word = 8,
> -			.len = 1,
> -			.delay_usecs = 4,
> -		},
> -		{
> -			.tx_buf = &st->tx[1],
> -			.rx_buf = st->rx,
> -			.bits_per_word = 8,
> -			.len = 2,
> -		},
> -	};
> -
> -	mutex_lock(&st->buf_lock);
> -	st->tx[0] = ADE7758_READ_REG(reg_address);
> -	st->tx[1] = 0;
> -	st->tx[2] = 0;
> -
> -	ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
> -	if (ret) {
> -		dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
> -			reg_address);
> -		goto error_ret;
> -	}
> -
> -	*val = (st->rx[0] << 8) | st->rx[1];
> -
> -error_ret:
> -	mutex_unlock(&st->buf_lock);
> -	return ret;
> -}
> -
> -static int ade7758_spi_read_reg_24(struct device *dev, u8 reg_address,
> -				   u32 *val)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7758_state *st = iio_priv(indio_dev);
> -	int ret;
> -	struct spi_transfer xfers[] = {
> -		{
> -			.tx_buf = st->tx,
> -			.bits_per_word = 8,
> -			.len = 1,
> -			.delay_usecs = 4,
> -		},
> -		{
> -			.tx_buf = &st->tx[1],
> -			.rx_buf = st->rx,
> -			.bits_per_word = 8,
> -			.len = 3,
> -		},
> -	};
> -
> -	mutex_lock(&st->buf_lock);
> -	st->tx[0] = ADE7758_READ_REG(reg_address);
> -	st->tx[1] = 0;
> -	st->tx[2] = 0;
> -	st->tx[3] = 0;
> -
> -	ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
> -	if (ret) {
> -		dev_err(&st->us->dev, "problem when reading 24 bit register 0x%02X",
> -			reg_address);
> -		goto error_ret;
> -	}
> -	*val = (st->rx[0] << 16) | (st->rx[1] << 8) | st->rx[2];
> -
> -error_ret:
> -	mutex_unlock(&st->buf_lock);
> -	return ret;
> -}
> -
> -static ssize_t ade7758_read_8bit(struct device *dev,
> -				 struct device_attribute *attr, char *buf)
> -{
> -	int ret;
> -	u8 val = 0;
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -
> -	ret = ade7758_spi_read_reg_8(dev, this_attr->address, &val);
> -	if (ret)
> -		return ret;
> -
> -	return sprintf(buf, "%u\n", val);
> -}
> -
> -static ssize_t ade7758_read_16bit(struct device *dev,
> -				  struct device_attribute *attr, char *buf)
> -{
> -	int ret;
> -	u16 val = 0;
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -
> -	ret = ade7758_spi_read_reg_16(dev, this_attr->address, &val);
> -	if (ret)
> -		return ret;
> -
> -	return sprintf(buf, "%u\n", val);
> -}
> -
> -static ssize_t ade7758_read_24bit(struct device *dev,
> -				  struct device_attribute *attr, char *buf)
> -{
> -	int ret;
> -	u32 val = 0;
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -
> -	ret = ade7758_spi_read_reg_24(dev, this_attr->address, &val);
> -	if (ret)
> -		return ret;
> -
> -	return sprintf(buf, "%u\n", val & 0xFFFFFF);
> -}
> -
> -static ssize_t ade7758_write_8bit(struct device *dev,
> -				  struct device_attribute *attr,
> -				  const char *buf, size_t len)
> -{
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -	int ret;
> -	u8 val;
> -
> -	ret = kstrtou8(buf, 10, &val);
> -	if (ret)
> -		goto error_ret;
> -	ret = ade7758_spi_write_reg_8(dev, this_attr->address, val);
> -
> -error_ret:
> -	return ret ? ret : len;
> -}
> -
> -static ssize_t ade7758_write_16bit(struct device *dev,
> -				   struct device_attribute *attr,
> -				   const char *buf, size_t len)
> -{
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -	int ret;
> -	u16 val;
> -
> -	ret = kstrtou16(buf, 10, &val);
> -	if (ret)
> -		goto error_ret;
> -	ret = ade7758_spi_write_reg_16(dev, this_attr->address, val);
> -
> -error_ret:
> -	return ret ? ret : len;
> -}
> -
> -static int ade7758_reset(struct device *dev)
> -{
> -	int ret;
> -	u8 val;
> -
> -	ret = ade7758_spi_read_reg_8(dev, ADE7758_OPMODE, &val);
> -	if (ret < 0) {
> -		dev_err(dev, "Failed to read opmode reg\n");
> -		return ret;
> -	}
> -	val |= BIT(6); /* Software Chip Reset */
> -	ret = ade7758_spi_write_reg_8(dev, ADE7758_OPMODE, val);
> -	if (ret < 0)
> -		dev_err(dev, "Failed to write opmode reg\n");
> -	return ret;
> -}
> -
> -static IIO_DEV_ATTR_VPEAK(0644,
> -		ade7758_read_8bit,
> -		ade7758_write_8bit,
> -		ADE7758_VPEAK);
> -static IIO_DEV_ATTR_IPEAK(0644,
> -		ade7758_read_8bit,
> -		ade7758_write_8bit,
> -		ADE7758_VPEAK);
> -static IIO_DEV_ATTR_APHCAL(0644,
> -		ade7758_read_8bit,
> -		ade7758_write_8bit,
> -		ADE7758_APHCAL);
> -static IIO_DEV_ATTR_BPHCAL(0644,
> -		ade7758_read_8bit,
> -		ade7758_write_8bit,
> -		ADE7758_BPHCAL);
> -static IIO_DEV_ATTR_CPHCAL(0644,
> -		ade7758_read_8bit,
> -		ade7758_write_8bit,
> -		ADE7758_CPHCAL);
> -static IIO_DEV_ATTR_WDIV(0644,
> -		ade7758_read_8bit,
> -		ade7758_write_8bit,
> -		ADE7758_WDIV);
> -static IIO_DEV_ATTR_VADIV(0644,
> -		ade7758_read_8bit,
> -		ade7758_write_8bit,
> -		ADE7758_VADIV);
> -static IIO_DEV_ATTR_AIRMS(0444,
> -		ade7758_read_24bit,
> -		NULL,
> -		ADE7758_AIRMS);
> -static IIO_DEV_ATTR_BIRMS(0444,
> -		ade7758_read_24bit,
> -		NULL,
> -		ADE7758_BIRMS);
> -static IIO_DEV_ATTR_CIRMS(0444,
> -		ade7758_read_24bit,
> -		NULL,
> -		ADE7758_CIRMS);
> -static IIO_DEV_ATTR_AVRMS(0444,
> -		ade7758_read_24bit,
> -		NULL,
> -		ADE7758_AVRMS);
> -static IIO_DEV_ATTR_BVRMS(0444,
> -		ade7758_read_24bit,
> -		NULL,
> -		ADE7758_BVRMS);
> -static IIO_DEV_ATTR_CVRMS(0444,
> -		ade7758_read_24bit,
> -		NULL,
> -		ADE7758_CVRMS);
> -static IIO_DEV_ATTR_AIRMSOS(0644,
> -		ade7758_read_16bit,
> -		ade7758_write_16bit,
> -		ADE7758_AIRMSOS);
> -static IIO_DEV_ATTR_BIRMSOS(0644,
> -		ade7758_read_16bit,
> -		ade7758_write_16bit,
> -		ADE7758_BIRMSOS);
> -static IIO_DEV_ATTR_CIRMSOS(0644,
> -		ade7758_read_16bit,
> -		ade7758_write_16bit,
> -		ADE7758_CIRMSOS);
> -static IIO_DEV_ATTR_AVRMSOS(0644,
> -		ade7758_read_16bit,
> -		ade7758_write_16bit,
> -		ADE7758_AVRMSOS);
> -static IIO_DEV_ATTR_BVRMSOS(0644,
> -		ade7758_read_16bit,
> -		ade7758_write_16bit,
> -		ADE7758_BVRMSOS);
> -static IIO_DEV_ATTR_CVRMSOS(0644,
> -		ade7758_read_16bit,
> -		ade7758_write_16bit,
> -		ADE7758_CVRMSOS);
> -static IIO_DEV_ATTR_AIGAIN(0644,
> -		ade7758_read_16bit,
> -		ade7758_write_16bit,
> -		ADE7758_AIGAIN);
> -static IIO_DEV_ATTR_BIGAIN(0644,
> -		ade7758_read_16bit,
> -		ade7758_write_16bit,
> -		ADE7758_BIGAIN);
> -static IIO_DEV_ATTR_CIGAIN(0644,
> -		ade7758_read_16bit,
> -		ade7758_write_16bit,
> -		ADE7758_CIGAIN);
> -static IIO_DEV_ATTR_AVRMSGAIN(0644,
> -		ade7758_read_16bit,
> -		ade7758_write_16bit,
> -		ADE7758_AVRMSGAIN);
> -static IIO_DEV_ATTR_BVRMSGAIN(0644,
> -		ade7758_read_16bit,
> -		ade7758_write_16bit,
> -		ADE7758_BVRMSGAIN);
> -static IIO_DEV_ATTR_CVRMSGAIN(0644,
> -		ade7758_read_16bit,
> -		ade7758_write_16bit,
> -		ADE7758_CVRMSGAIN);
> -
> -int ade7758_set_irq(struct device *dev, bool enable)
> -{
> -	int ret;
> -	u32 irqen;
> -
> -	ret = ade7758_spi_read_reg_24(dev, ADE7758_MASK, &irqen);
> -	if (ret)
> -		return ret;
> -
> -	if (enable)
> -		irqen |= BIT(16); /* Enables an interrupt when a data is
> -				   * present in the waveform register
> -				   */
> -	else
> -		irqen &= ~BIT(16);
> -
> -	ret = ade7758_spi_write_reg_24(dev, ADE7758_MASK, irqen);
> -
> -	return ret;
> -}
> -
> -/* Power down the device */
> -static int ade7758_stop_device(struct device *dev)
> -{
> -	int ret;
> -	u8 val;
> -
> -	ret = ade7758_spi_read_reg_8(dev, ADE7758_OPMODE, &val);
> -	if (ret < 0) {
> -		dev_err(dev, "Failed to read opmode reg\n");
> -		return ret;
> -	}
> -	val |= 7 << 3;  /* ADE7758 powered down */
> -	ret = ade7758_spi_write_reg_8(dev, ADE7758_OPMODE, val);
> -	if (ret < 0)
> -		dev_err(dev, "Failed to write opmode reg\n");
> -	return ret;
> -}
> -
> -static int ade7758_initial_setup(struct iio_dev *indio_dev)
> -{
> -	struct ade7758_state *st = iio_priv(indio_dev);
> -	struct device *dev = &indio_dev->dev;
> -	int ret;
> -
> -	/* use low spi speed for init */
> -	st->us->mode = SPI_MODE_1;
> -	spi_setup(st->us);
> -
> -	/* Disable IRQ */
> -	ret = ade7758_set_irq(dev, false);
> -	if (ret) {
> -		dev_err(dev, "disable irq failed");
> -		goto err_ret;
> -	}
> -
> -	ade7758_reset(dev);
> -	usleep_range(ADE7758_STARTUP_DELAY, ADE7758_STARTUP_DELAY + 100);
> -
> -err_ret:
> -	return ret;
> -}
> -
> -static int ade7758_read_samp_freq(struct device *dev, int *val)
> -{
> -	int ret;
> -	u8 t;
> -
> -	ret = ade7758_spi_read_reg_8(dev, ADE7758_WAVMODE, &t);
> -	if (ret)
> -		return ret;
> -
> -	t = (t >> 5) & 0x3;
> -	*val = 26040 / (1 << t);
> -
> -	return 0;
> -}
> -
> -static int ade7758_write_samp_freq(struct device *dev, int val)
> -{
> -	int ret;
> -	u8 reg, t;
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7758_state *st = iio_priv(indio_dev);
> -
> -	switch (val) {
> -	case 26040:
> -		t = 0;
> -		break;
> -	case 13020:
> -		t = 1;
> -		break;
> -	case 6510:
> -		t = 2;
> -		break;
> -	case 3255:
> -		t = 3;
> -		break;
> -	default:
> -		return -EINVAL;
> -	}
> -
> -	mutex_lock(&st->buf_lock);
> -
> -	ret = __ade7758_spi_read_reg_8(dev, ADE7758_WAVMODE, &reg);
> -	if (ret)
> -		goto out;
> -
> -	reg &= ~(5 << 3);
> -	reg |= t << 5;
> -
> -	ret = __ade7758_spi_write_reg_8(dev, ADE7758_WAVMODE, reg);
> -
> -out:
> -	mutex_unlock(&st->buf_lock);
> -
> -	return ret;
> -}
> -
> -static int ade7758_read_raw(struct iio_dev *indio_dev,
> -			    struct iio_chan_spec const *chan,
> -			    int *val,
> -			    int *val2,
> -			    long mask)
> -{
> -	int ret;
> -
> -	switch (mask) {
> -	case IIO_CHAN_INFO_SAMP_FREQ:
> -
> -		ret = ade7758_read_samp_freq(&indio_dev->dev, val);
> -
> -		return ret;
> -	default:
> -		return -EINVAL;
> -	}
> -
> -	return ret;
> -}
> -
> -static int ade7758_write_raw(struct iio_dev *indio_dev,
> -			     struct iio_chan_spec const *chan,
> -			     int val, int val2, long mask)
> -{
> -	int ret;
> -
> -	switch (mask) {
> -	case IIO_CHAN_INFO_SAMP_FREQ:
> -		if (val2)
> -			return -EINVAL;
> -
> -		ret = ade7758_write_samp_freq(&indio_dev->dev, val);
> -
> -		return ret;
> -	default:
> -		return -EINVAL;
> -	}
> -
> -	return ret;
> -}
> -
> -static IIO_DEV_ATTR_TEMP_RAW(ade7758_read_8bit);
> -static IIO_CONST_ATTR(in_temp_offset, "129 C");
> -static IIO_CONST_ATTR(in_temp_scale, "4 C");
> -
> -static IIO_DEV_ATTR_AWATTHR(ade7758_read_16bit,
> -		ADE7758_AWATTHR);
> -static IIO_DEV_ATTR_BWATTHR(ade7758_read_16bit,
> -		ADE7758_BWATTHR);
> -static IIO_DEV_ATTR_CWATTHR(ade7758_read_16bit,
> -		ADE7758_CWATTHR);
> -static IIO_DEV_ATTR_AVARHR(ade7758_read_16bit,
> -		ADE7758_AVARHR);
> -static IIO_DEV_ATTR_BVARHR(ade7758_read_16bit,
> -		ADE7758_BVARHR);
> -static IIO_DEV_ATTR_CVARHR(ade7758_read_16bit,
> -		ADE7758_CVARHR);
> -static IIO_DEV_ATTR_AVAHR(ade7758_read_16bit,
> -		ADE7758_AVAHR);
> -static IIO_DEV_ATTR_BVAHR(ade7758_read_16bit,
> -		ADE7758_BVAHR);
> -static IIO_DEV_ATTR_CVAHR(ade7758_read_16bit,
> -		ADE7758_CVAHR);
> -
> -static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("26040 13020 6510 3255");
> -
> -static struct attribute *ade7758_attributes[] = {
> -	&iio_dev_attr_in_temp_raw.dev_attr.attr,
> -	&iio_const_attr_in_temp_offset.dev_attr.attr,
> -	&iio_const_attr_in_temp_scale.dev_attr.attr,
> -	&iio_const_attr_sampling_frequency_available.dev_attr.attr,
> -	&iio_dev_attr_awatthr.dev_attr.attr,
> -	&iio_dev_attr_bwatthr.dev_attr.attr,
> -	&iio_dev_attr_cwatthr.dev_attr.attr,
> -	&iio_dev_attr_avarhr.dev_attr.attr,
> -	&iio_dev_attr_bvarhr.dev_attr.attr,
> -	&iio_dev_attr_cvarhr.dev_attr.attr,
> -	&iio_dev_attr_avahr.dev_attr.attr,
> -	&iio_dev_attr_bvahr.dev_attr.attr,
> -	&iio_dev_attr_cvahr.dev_attr.attr,
> -	&iio_dev_attr_vpeak.dev_attr.attr,
> -	&iio_dev_attr_ipeak.dev_attr.attr,
> -	&iio_dev_attr_aphcal.dev_attr.attr,
> -	&iio_dev_attr_bphcal.dev_attr.attr,
> -	&iio_dev_attr_cphcal.dev_attr.attr,
> -	&iio_dev_attr_wdiv.dev_attr.attr,
> -	&iio_dev_attr_vadiv.dev_attr.attr,
> -	&iio_dev_attr_airms.dev_attr.attr,
> -	&iio_dev_attr_birms.dev_attr.attr,
> -	&iio_dev_attr_cirms.dev_attr.attr,
> -	&iio_dev_attr_avrms.dev_attr.attr,
> -	&iio_dev_attr_bvrms.dev_attr.attr,
> -	&iio_dev_attr_cvrms.dev_attr.attr,
> -	&iio_dev_attr_aigain.dev_attr.attr,
> -	&iio_dev_attr_bigain.dev_attr.attr,
> -	&iio_dev_attr_cigain.dev_attr.attr,
> -	&iio_dev_attr_avrmsgain.dev_attr.attr,
> -	&iio_dev_attr_bvrmsgain.dev_attr.attr,
> -	&iio_dev_attr_cvrmsgain.dev_attr.attr,
> -	&iio_dev_attr_airmsos.dev_attr.attr,
> -	&iio_dev_attr_birmsos.dev_attr.attr,
> -	&iio_dev_attr_cirmsos.dev_attr.attr,
> -	&iio_dev_attr_avrmsos.dev_attr.attr,
> -	&iio_dev_attr_bvrmsos.dev_attr.attr,
> -	&iio_dev_attr_cvrmsos.dev_attr.attr,
> -	NULL,
> -};
> -
> -static const struct attribute_group ade7758_attribute_group = {
> -	.attrs = ade7758_attributes,
> -};
> -
> -static const struct iio_chan_spec ade7758_channels[] = {
> -	{
> -		.type = IIO_VOLTAGE,
> -		.indexed = 1,
> -		.channel = 0,
> -		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> -		.address = AD7758_WT(AD7758_PHASE_A, AD7758_VOLTAGE),
> -		.scan_index = 0,
> -		.scan_type = {
> -			.sign = 's',
> -			.realbits = 24,
> -			.storagebits = 32,
> -		},
> -	}, {
> -		.type = IIO_CURRENT,
> -		.indexed = 1,
> -		.channel = 0,
> -		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> -		.address = AD7758_WT(AD7758_PHASE_A, AD7758_CURRENT),
> -		.scan_index = 1,
> -		.scan_type = {
> -			.sign = 's',
> -			.realbits = 24,
> -			.storagebits = 32,
> -		},
> -	}, {
> -		.type = IIO_POWER,
> -		.indexed = 1,
> -		.channel = 0,
> -		.extend_name = "apparent",
> -		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> -		.address = AD7758_WT(AD7758_PHASE_A, AD7758_APP_PWR),
> -		.scan_index = 2,
> -		.scan_type = {
> -			.sign = 's',
> -			.realbits = 24,
> -			.storagebits = 32,
> -		},
> -	}, {
> -		.type = IIO_POWER,
> -		.indexed = 1,
> -		.channel = 0,
> -		.extend_name = "active",
> -		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> -		.address = AD7758_WT(AD7758_PHASE_A, AD7758_ACT_PWR),
> -		.scan_index = 3,
> -		.scan_type = {
> -			.sign = 's',
> -			.realbits = 24,
> -			.storagebits = 32,
> -		},
> -	}, {
> -		.type = IIO_POWER,
> -		.indexed = 1,
> -		.channel = 0,
> -		.extend_name = "reactive",
> -		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> -		.address = AD7758_WT(AD7758_PHASE_A, AD7758_REACT_PWR),
> -		.scan_index = 4,
> -		.scan_type = {
> -			.sign = 's',
> -			.realbits = 24,
> -			.storagebits = 32,
> -		},
> -	}, {
> -		.type = IIO_VOLTAGE,
> -		.indexed = 1,
> -		.channel = 1,
> -		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> -		.address = AD7758_WT(AD7758_PHASE_B, AD7758_VOLTAGE),
> -		.scan_index = 5,
> -		.scan_type = {
> -			.sign = 's',
> -			.realbits = 24,
> -			.storagebits = 32,
> -		},
> -	}, {
> -		.type = IIO_CURRENT,
> -		.indexed = 1,
> -		.channel = 1,
> -		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> -		.address = AD7758_WT(AD7758_PHASE_B, AD7758_CURRENT),
> -		.scan_index = 6,
> -		.scan_type = {
> -			.sign = 's',
> -			.realbits = 24,
> -			.storagebits = 32,
> -		},
> -	}, {
> -		.type = IIO_POWER,
> -		.indexed = 1,
> -		.channel = 1,
> -		.extend_name = "apparent",
> -		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> -		.address = AD7758_WT(AD7758_PHASE_B, AD7758_APP_PWR),
> -		.scan_index = 7,
> -		.scan_type = {
> -			.sign = 's',
> -			.realbits = 24,
> -			.storagebits = 32,
> -		},
> -	}, {
> -		.type = IIO_POWER,
> -		.indexed = 1,
> -		.channel = 1,
> -		.extend_name = "active",
> -		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> -		.address = AD7758_WT(AD7758_PHASE_B, AD7758_ACT_PWR),
> -		.scan_index = 8,
> -		.scan_type = {
> -			.sign = 's',
> -			.realbits = 24,
> -			.storagebits = 32,
> -		},
> -	}, {
> -		.type = IIO_POWER,
> -		.indexed = 1,
> -		.channel = 1,
> -		.extend_name = "reactive",
> -		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> -		.address = AD7758_WT(AD7758_PHASE_B, AD7758_REACT_PWR),
> -		.scan_index = 9,
> -		.scan_type = {
> -			.sign = 's',
> -			.realbits = 24,
> -			.storagebits = 32,
> -		},
> -	}, {
> -		.type = IIO_VOLTAGE,
> -		.indexed = 1,
> -		.channel = 2,
> -		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> -		.address = AD7758_WT(AD7758_PHASE_C, AD7758_VOLTAGE),
> -		.scan_index = 10,
> -		.scan_type = {
> -			.sign = 's',
> -			.realbits = 24,
> -			.storagebits = 32,
> -		},
> -	}, {
> -		.type = IIO_CURRENT,
> -		.indexed = 1,
> -		.channel = 2,
> -		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> -		.address = AD7758_WT(AD7758_PHASE_C, AD7758_CURRENT),
> -		.scan_index = 11,
> -		.scan_type = {
> -			.sign = 's',
> -			.realbits = 24,
> -			.storagebits = 32,
> -		},
> -	}, {
> -		.type = IIO_POWER,
> -		.indexed = 1,
> -		.channel = 2,
> -		.extend_name = "apparent",
> -		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> -		.address = AD7758_WT(AD7758_PHASE_C, AD7758_APP_PWR),
> -		.scan_index = 12,
> -		.scan_type = {
> -			.sign = 's',
> -			.realbits = 24,
> -			.storagebits = 32,
> -		},
> -	}, {
> -		.type = IIO_POWER,
> -		.indexed = 1,
> -		.channel = 2,
> -		.extend_name = "active",
> -		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> -		.address = AD7758_WT(AD7758_PHASE_C, AD7758_ACT_PWR),
> -		.scan_index = 13,
> -		.scan_type = {
> -			.sign = 's',
> -			.realbits = 24,
> -			.storagebits = 32,
> -		},
> -	}, {
> -		.type = IIO_POWER,
> -		.indexed = 1,
> -		.channel = 2,
> -		.extend_name = "reactive",
> -		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> -		.address = AD7758_WT(AD7758_PHASE_C, AD7758_REACT_PWR),
> -		.scan_index = 14,
> -		.scan_type = {
> -			.sign = 's',
> -			.realbits = 24,
> -			.storagebits = 32,
> -		},
> -	},
> -	IIO_CHAN_SOFT_TIMESTAMP(15),
> -};
> -
> -static const struct iio_info ade7758_info = {
> -	.attrs = &ade7758_attribute_group,
> -	.read_raw = &ade7758_read_raw,
> -	.write_raw = &ade7758_write_raw,
> -};
> -
> -static int ade7758_probe(struct spi_device *spi)
> -{
> -	int ret;
> -	struct ade7758_state *st;
> -	struct iio_dev *indio_dev;
> -
> -	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> -	if (!indio_dev)
> -		return -ENOMEM;
> -
> -	st = iio_priv(indio_dev);
> -	/* this is only used for removal purposes */
> -	spi_set_drvdata(spi, indio_dev);
> -
> -	/* Allocate the comms buffers */
> -	st->rx = kcalloc(ADE7758_MAX_RX, sizeof(*st->rx), GFP_KERNEL);
> -	if (!st->rx)
> -		return -ENOMEM;
> -	st->tx = kcalloc(ADE7758_MAX_TX, sizeof(*st->tx), GFP_KERNEL);
> -	if (!st->tx) {
> -		ret = -ENOMEM;
> -		goto error_free_rx;
> -	}
> -	st->us = spi;
> -	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;
> -
> -	/* Get the device into a sane initial state */
> -	ret = ade7758_initial_setup(indio_dev);
> -	if (ret)
> -		goto error_unreg_ring_funcs;
> -
> -	if (spi->irq) {
> -		ret = ade7758_probe_trigger(indio_dev);
> -		if (ret)
> -			goto error_unreg_ring_funcs;
> -	}
> -
> -	ret = iio_device_register(indio_dev);
> -	if (ret)
> -		goto error_remove_trigger;
> -
> -	return 0;
> -
> -error_remove_trigger:
> -	if (spi->irq)
> -		ade7758_remove_trigger(indio_dev);
> -error_unreg_ring_funcs:
> -	ade7758_unconfigure_ring(indio_dev);
> -error_free_tx:
> -	kfree(st->tx);
> -error_free_rx:
> -	kfree(st->rx);
> -	return ret;
> -}
> -
> -static int ade7758_remove(struct spi_device *spi)
> -{
> -	struct iio_dev *indio_dev = spi_get_drvdata(spi);
> -	struct ade7758_state *st = iio_priv(indio_dev);
> -
> -	iio_device_unregister(indio_dev);
> -	ade7758_stop_device(&indio_dev->dev);
> -	ade7758_remove_trigger(indio_dev);
> -	ade7758_unconfigure_ring(indio_dev);
> -	kfree(st->tx);
> -	kfree(st->rx);
> -
> -	return 0;
> -}
> -
> -static const struct spi_device_id ade7758_id[] = {
> -	{"ade7758", 0},
> -	{}
> -};
> -MODULE_DEVICE_TABLE(spi, ade7758_id);
> -
> -static struct spi_driver ade7758_driver = {
> -	.driver = {
> -		.name = "ade7758",
> -	},
> -	.probe = ade7758_probe,
> -	.remove = ade7758_remove,
> -	.id_table = ade7758_id,
> -};
> -module_spi_driver(ade7758_driver);
> -
> -MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
> -MODULE_DESCRIPTION("Analog Devices ADE7758 Polyphase Multifunction Energy Metering IC Driver");
> -MODULE_LICENSE("GPL v2");
> diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c
> deleted file mode 100644
> index 6d7444d6e880..000000000000
> --- a/drivers/staging/iio/meter/ade7758_ring.c
> +++ /dev/null
> @@ -1,177 +0,0 @@
> -/*
> - * ADE7758 Poly Phase Multifunction Energy Metering IC driver
> - *
> - * Copyright 2010-2011 Analog Devices Inc.
> - *
> - * Licensed under the GPL-2.
> - */
> -#include <linux/export.h>
> -#include <linux/interrupt.h>
> -#include <linux/kernel.h>
> -#include <linux/spi/spi.h>
> -#include <linux/slab.h>
> -#include <asm/unaligned.h>
> -
> -#include <linux/iio/iio.h>
> -#include <linux/iio/buffer.h>
> -#include <linux/iio/kfifo_buf.h>
> -#include <linux/iio/trigger_consumer.h>
> -#include "ade7758.h"
> -
> -/**
> - * ade7758_spi_read_burst() - read data registers
> - * @indio_dev: the IIO device
> - **/
> -static int ade7758_spi_read_burst(struct iio_dev *indio_dev)
> -{
> -	struct ade7758_state *st = iio_priv(indio_dev);
> -	int ret;
> -
> -	ret = spi_sync(st->us, &st->ring_msg);
> -	if (ret)
> -		dev_err(&st->us->dev, "problem when reading WFORM value\n");
> -
> -	return ret;
> -}
> -
> -static int ade7758_write_waveform_type(struct device *dev, unsigned int type)
> -{
> -	int ret;
> -	u8 reg;
> -
> -	ret = ade7758_spi_read_reg_8(dev, ADE7758_WAVMODE, &reg);
> -	if (ret)
> -		goto out;
> -
> -	reg &= ~0x1F;
> -	reg |= type & 0x1F;
> -
> -	ret = ade7758_spi_write_reg_8(dev, ADE7758_WAVMODE, reg);
> -out:
> -	return ret;
> -}
> -
> -/* Whilst this makes a lot of calls to iio_sw_ring functions - it is too device
> - * specific to be rolled into the core.
> - */
> -static irqreturn_t ade7758_trigger_handler(int irq, void *p)
> -{
> -	struct iio_poll_func *pf = p;
> -	struct iio_dev *indio_dev = pf->indio_dev;
> -	struct ade7758_state *st = iio_priv(indio_dev);
> -	s64 dat64[2];
> -	u32 *dat32 = (u32 *)dat64;
> -
> -	if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
> -		if (ade7758_spi_read_burst(indio_dev) >= 0)
> -			*dat32 = get_unaligned_be32(&st->rx_buf[5]) & 0xFFFFFF;
> -
> -	iio_push_to_buffers_with_timestamp(indio_dev, dat64, pf->timestamp);
> -
> -	iio_trigger_notify_done(indio_dev->trig);
> -
> -	return IRQ_HANDLED;
> -}
> -
> -/**
> - * ade7758_ring_preenable() setup the parameters of the ring before enabling
> - *
> - * The complex nature of the setting of the number of bytes per datum is due
> - * to this driver currently ensuring that the timestamp is stored at an 8
> - * byte boundary.
> - **/
> -static int ade7758_ring_preenable(struct iio_dev *indio_dev)
> -{
> -	unsigned int channel;
> -
> -	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,
> -				    indio_dev->channels[channel].address);
> -
> -	return 0;
> -}
> -
> -static const struct iio_buffer_setup_ops ade7758_ring_setup_ops = {
> -	.preenable = &ade7758_ring_preenable,
> -	.postenable = &iio_triggered_buffer_postenable,
> -	.predisable = &iio_triggered_buffer_predisable,
> -	.validate_scan_mask = &iio_validate_scan_mask_onehot,
> -};
> -
> -void ade7758_unconfigure_ring(struct iio_dev *indio_dev)
> -{
> -	iio_dealloc_pollfunc(indio_dev->pollfunc);
> -	iio_kfifo_free(indio_dev->buffer);
> -}
> -
> -int ade7758_configure_ring(struct iio_dev *indio_dev)
> -{
> -	struct ade7758_state *st = iio_priv(indio_dev);
> -	struct iio_buffer *buffer;
> -	int ret = 0;
> -
> -	buffer = iio_kfifo_allocate();
> -	if (!buffer)
> -		return -ENOMEM;
> -
> -	iio_device_attach_buffer(indio_dev, buffer);
> -
> -	indio_dev->setup_ops = &ade7758_ring_setup_ops;
> -
> -	indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
> -						 &ade7758_trigger_handler,
> -						 0,
> -						 indio_dev,
> -						 "ade7759_consumer%d",
> -						 indio_dev->id);
> -	if (!indio_dev->pollfunc) {
> -		ret = -ENOMEM;
> -		goto error_iio_kfifo_free;
> -	}
> -
> -	indio_dev->modes |= INDIO_BUFFER_TRIGGERED;
> -
> -	st->tx_buf[0] = ADE7758_READ_REG(ADE7758_RSTATUS);
> -	st->tx_buf[1] = 0;
> -	st->tx_buf[2] = 0;
> -	st->tx_buf[3] = 0;
> -	st->tx_buf[4] = ADE7758_READ_REG(ADE7758_WFORM);
> -	st->tx_buf[5] = 0;
> -	st->tx_buf[6] = 0;
> -	st->tx_buf[7] = 0;
> -
> -	/* build spi ring message */
> -	st->ring_xfer[0].tx_buf = &st->tx_buf[0];
> -	st->ring_xfer[0].len = 1;
> -	st->ring_xfer[0].bits_per_word = 8;
> -	st->ring_xfer[0].delay_usecs = 4;
> -	st->ring_xfer[1].rx_buf = &st->rx_buf[1];
> -	st->ring_xfer[1].len = 3;
> -	st->ring_xfer[1].bits_per_word = 8;
> -	st->ring_xfer[1].cs_change = 1;
> -
> -	st->ring_xfer[2].tx_buf = &st->tx_buf[4];
> -	st->ring_xfer[2].len = 1;
> -	st->ring_xfer[2].bits_per_word = 8;
> -	st->ring_xfer[2].delay_usecs = 1;
> -	st->ring_xfer[3].rx_buf = &st->rx_buf[5];
> -	st->ring_xfer[3].len = 3;
> -	st->ring_xfer[3].bits_per_word = 8;
> -
> -	spi_message_init(&st->ring_msg);
> -	spi_message_add_tail(&st->ring_xfer[0], &st->ring_msg);
> -	spi_message_add_tail(&st->ring_xfer[1], &st->ring_msg);
> -	spi_message_add_tail(&st->ring_xfer[2], &st->ring_msg);
> -	spi_message_add_tail(&st->ring_xfer[3], &st->ring_msg);
> -
> -	return 0;
> -
> -error_iio_kfifo_free:
> -	iio_kfifo_free(indio_dev->buffer);
> -	return ret;
> -}
> diff --git a/drivers/staging/iio/meter/ade7758_trigger.c b/drivers/staging/iio/meter/ade7758_trigger.c
> deleted file mode 100644
> index 4f6b338cffeb..000000000000
> --- a/drivers/staging/iio/meter/ade7758_trigger.c
> +++ /dev/null
> @@ -1,108 +0,0 @@
> -/*
> - * ADE7758 Poly Phase Multifunction Energy Metering IC driver
> - *
> - * Copyright 2010-2011 Analog Devices Inc.
> - *
> - * Licensed under the GPL-2.
> - */
> -
> -#include <linux/interrupt.h>
> -#include <linux/kernel.h>
> -#include <linux/spi/spi.h>
> -#include <linux/export.h>
> -
> -#include <linux/iio/iio.h>
> -#include <linux/iio/trigger.h>
> -#include "ade7758.h"
> -
> -/**
> - * ade7758_data_rdy_trig_poll() the event handler for the data rdy trig
> - **/
> -static irqreturn_t ade7758_data_rdy_trig_poll(int irq, void *private)
> -{
> -	disable_irq_nosync(irq);
> -	iio_trigger_poll(private);
> -
> -	return IRQ_HANDLED;
> -}
> -
> -/**
> - * ade7758_data_rdy_trigger_set_state() set datardy interrupt state
> - **/
> -static int ade7758_data_rdy_trigger_set_state(struct iio_trigger *trig,
> -					      bool state)
> -{
> -	struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
> -
> -	dev_dbg(&indio_dev->dev, "(%d)\n", state);
> -	return ade7758_set_irq(&indio_dev->dev, state);
> -}
> -
> -/**
> - * ade7758_trig_try_reen() try renabling irq for data rdy trigger
> - * @trig:	the datardy trigger
> - **/
> -static int ade7758_trig_try_reen(struct iio_trigger *trig)
> -{
> -	struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
> -	struct ade7758_state *st = iio_priv(indio_dev);
> -
> -	enable_irq(st->us->irq);
> -	/* irq reenabled so success! */
> -	return 0;
> -}
> -
> -static const struct iio_trigger_ops ade7758_trigger_ops = {
> -	.set_trigger_state = &ade7758_data_rdy_trigger_set_state,
> -	.try_reenable = &ade7758_trig_try_reen,
> -};
> -
> -int ade7758_probe_trigger(struct iio_dev *indio_dev)
> -{
> -	struct ade7758_state *st = iio_priv(indio_dev);
> -	int ret;
> -
> -	st->trig = iio_trigger_alloc("%s-dev%d",
> -				     spi_get_device_id(st->us)->name,
> -				     indio_dev->id);
> -	if (!st->trig) {
> -		ret = -ENOMEM;
> -		goto error_ret;
> -	}
> -
> -	ret = request_irq(st->us->irq,
> -			  ade7758_data_rdy_trig_poll,
> -			  IRQF_TRIGGER_LOW,
> -			  spi_get_device_id(st->us)->name,
> -			  st->trig);
> -	if (ret)
> -		goto error_free_trig;
> -
> -	st->trig->dev.parent = &st->us->dev;
> -	st->trig->ops = &ade7758_trigger_ops;
> -	iio_trigger_set_drvdata(st->trig, indio_dev);
> -	ret = iio_trigger_register(st->trig);
> -
> -	/* select default trigger */
> -	indio_dev->trig = iio_trigger_get(st->trig);
> -	if (ret)
> -		goto error_free_irq;
> -
> -	return 0;
> -
> -error_free_irq:
> -	free_irq(st->us->irq, st->trig);
> -error_free_trig:
> -	iio_trigger_free(st->trig);
> -error_ret:
> -	return ret;
> -}
> -
> -void ade7758_remove_trigger(struct iio_dev *indio_dev)
> -{
> -	struct ade7758_state *st = iio_priv(indio_dev);
> -
> -	iio_trigger_unregister(st->trig);
> -	free_irq(st->us->irq, st->trig);
> -	iio_trigger_free(st->trig);
> -}


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/4] staging:iio:meter: Drop ADE7759 driver
  2018-05-12 17:51 ` [PATCH 4/4] staging:iio:meter: Drop ADE7759 driver Jonathan Cameron
@ 2018-05-20 11:22   ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2018-05-20 11:22 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Rodrigo Siqueira, John Syne, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Hartmut Knaack, Michael Hennerich

On Sat, 12 May 2018 18:51:04 +0100
Jonathan Cameron <Jonathan.Cameron@huawei.com> wrote:

> I announced the intent to drop some of these meter drivers
> on the IIO list last cycle. This device is obsolete and not easily
> obtained.  No one has come forward with suitable test hardware and
> the driver would need a lot of work to move out of staging.
> 
> As such I am dropping it.  We can always bring it back again
> if a user / tester emerges in the future.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Applied.

> ---
>  drivers/staging/iio/meter/Kconfig   |  10 -
>  drivers/staging/iio/meter/Makefile  |   1 -
>  drivers/staging/iio/meter/ade7759.c | 558 ----------------------------
>  3 files changed, 569 deletions(-)
> 
> diff --git a/drivers/staging/iio/meter/Kconfig b/drivers/staging/iio/meter/Kconfig
> index 451ac47bb0cc..e01eb8abcdce 100644
> --- a/drivers/staging/iio/meter/Kconfig
> +++ b/drivers/staging/iio/meter/Kconfig
> @@ -3,16 +3,6 @@
>  #
>  menu "Active energy metering IC"
>  
> -config ADE7759
> -	tristate "Analog Devices ADE7759 Active Energy Metering IC Driver"
> -	depends on SPI
> -	help
> -	  Say yes here to build support for Analog Devices ADE7758 Active Energy
> -	  Metering IC with di/dt Sensor Interface.
> -
> -	  To compile this driver as a module, choose M here: the
> -	  module will be called ade7759.
> -
>  config ADE7854
>  	tristate "Analog Devices ADE7854/58/68/78 Polyphase Multifunction Energy Metering IC Driver"
>  	depends on SPI || I2C
> diff --git a/drivers/staging/iio/meter/Makefile b/drivers/staging/iio/meter/Makefile
> index a36ff1668275..ed4547e38f3a 100644
> --- a/drivers/staging/iio/meter/Makefile
> +++ b/drivers/staging/iio/meter/Makefile
> @@ -3,7 +3,6 @@
>  # Makefile for metering ic drivers
>  #
>  
> -obj-$(CONFIG_ADE7759) += ade7759.o
>  obj-$(CONFIG_ADE7854) += ade7854.o
>  obj-$(CONFIG_ADE7854_I2C) += ade7854-i2c.o
>  obj-$(CONFIG_ADE7854_SPI) += ade7854-spi.o
> diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c
> deleted file mode 100644
> index c078b770fa53..000000000000
> --- a/drivers/staging/iio/meter/ade7759.c
> +++ /dev/null
> @@ -1,558 +0,0 @@
> -/*
> - * ADE7759 Active Energy Metering IC with di/dt Sensor Interface Driver
> - *
> - * Copyright 2010 Analog Devices Inc.
> - *
> - * Licensed under the GPL-2 or later.
> - */
> -
> -#include <linux/interrupt.h>
> -#include <linux/irq.h>
> -#include <linux/delay.h>
> -#include <linux/mutex.h>
> -#include <linux/device.h>
> -#include <linux/kernel.h>
> -#include <linux/spi/spi.h>
> -#include <linux/slab.h>
> -#include <linux/sysfs.h>
> -#include <linux/list.h>
> -#include <linux/module.h>
> -
> -#include <linux/iio/iio.h>
> -#include <linux/iio/sysfs.h>
> -#include "meter.h"
> -
> -#define ADE7759_WAVEFORM  0x01
> -#define ADE7759_AENERGY   0x02
> -#define ADE7759_RSTENERGY 0x03
> -#define ADE7759_STATUS    0x04
> -#define ADE7759_RSTSTATUS 0x05
> -#define ADE7759_MODE      0x06
> -#define ADE7759_CFDEN     0x07
> -#define ADE7759_CH1OS     0x08
> -#define ADE7759_CH2OS     0x09
> -#define ADE7759_GAIN      0x0A
> -#define ADE7759_APGAIN    0x0B
> -#define ADE7759_PHCAL     0x0C
> -#define ADE7759_APOS      0x0D
> -#define ADE7759_ZXTOUT    0x0E
> -#define ADE7759_SAGCYC    0x0F
> -#define ADE7759_IRQEN     0x10
> -#define ADE7759_SAGLVL    0x11
> -#define ADE7759_TEMP      0x12
> -#define ADE7759_LINECYC   0x13
> -#define ADE7759_LENERGY   0x14
> -#define ADE7759_CFNUM     0x15
> -#define ADE7759_CHKSUM    0x1E
> -#define ADE7759_DIEREV    0x1F
> -
> -#define ADE7759_READ_REG(a)    a
> -#define ADE7759_WRITE_REG(a) ((a) | 0x80)
> -
> -#define ADE7759_MAX_TX    6
> -#define ADE7759_MAX_RX    6
> -#define ADE7759_STARTUP_DELAY 1000
> -
> -#define ADE7759_SPI_SLOW	(u32)(300 * 1000)
> -#define ADE7759_SPI_BURST	(u32)(1000 * 1000)
> -#define ADE7759_SPI_FAST	(u32)(2000 * 1000)
> -
> -/**
> - * struct ade7759_state - device instance specific data
> - * @us:			actual spi_device
> - * @buf_lock:		mutex to protect tx and rx and write frequency
> - * @tx:			transmit buffer
> - * @rx:			receive buffer
> - **/
> -struct ade7759_state {
> -	struct spi_device	*us;
> -	struct mutex		buf_lock;
> -	u8			tx[ADE7759_MAX_TX] ____cacheline_aligned;
> -	u8			rx[ADE7759_MAX_RX];
> -};
> -
> -static int ade7759_spi_write_reg_8(struct device *dev,
> -				   u8 reg_address,
> -				   u8 val)
> -{
> -	int ret;
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7759_state *st = iio_priv(indio_dev);
> -
> -	mutex_lock(&st->buf_lock);
> -	st->tx[0] = ADE7759_WRITE_REG(reg_address);
> -	st->tx[1] = val;
> -
> -	ret = spi_write(st->us, st->tx, 2);
> -	mutex_unlock(&st->buf_lock);
> -
> -	return ret;
> -}
> -
> -/*Unlocked version of ade7759_spi_write_reg_16 function */
> -static int __ade7759_spi_write_reg_16(struct device *dev,
> -				      u8 reg_address,
> -				      u16 value)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7759_state *st = iio_priv(indio_dev);
> -
> -	st->tx[0] = ADE7759_WRITE_REG(reg_address);
> -	st->tx[1] = (value >> 8) & 0xFF;
> -	st->tx[2] = value & 0xFF;
> -	return spi_write(st->us, st->tx, 3);
> -}
> -
> -static int ade7759_spi_write_reg_16(struct device *dev,
> -				    u8 reg_address,
> -				    u16 value)
> -{
> -	int ret;
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7759_state *st = iio_priv(indio_dev);
> -
> -	mutex_lock(&st->buf_lock);
> -	ret = __ade7759_spi_write_reg_16(dev, reg_address, value);
> -	mutex_unlock(&st->buf_lock);
> -
> -	return ret;
> -}
> -
> -static int ade7759_spi_read_reg_8(struct device *dev,
> -				  u8 reg_address,
> -				  u8 *val)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7759_state *st = iio_priv(indio_dev);
> -	int ret;
> -
> -	ret = spi_w8r8(st->us, ADE7759_READ_REG(reg_address));
> -	if (ret < 0) {
> -		dev_err(&st->us->dev,
> -			"problem when reading 8 bit register 0x%02X",
> -			reg_address);
> -		return ret;
> -	}
> -	*val = ret;
> -
> -	return 0;
> -}
> -
> -static int ade7759_spi_read_reg_16(struct device *dev,
> -				   u8 reg_address,
> -				   u16 *val)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7759_state *st = iio_priv(indio_dev);
> -	int ret;
> -
> -	ret = spi_w8r16be(st->us, ADE7759_READ_REG(reg_address));
> -	if (ret < 0) {
> -		dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
> -			reg_address);
> -		return ret;
> -	}
> -
> -	*val = ret;
> -
> -	return 0;
> -}
> -
> -static int ade7759_spi_read_reg_40(struct device *dev,
> -				   u8 reg_address,
> -				   u64 *val)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7759_state *st = iio_priv(indio_dev);
> -	int ret;
> -	struct spi_transfer xfers[] = {
> -		{
> -			.tx_buf = st->tx,
> -			.rx_buf = st->rx,
> -			.bits_per_word = 8,
> -			.len = 6,
> -		},
> -	};
> -
> -	mutex_lock(&st->buf_lock);
> -	st->tx[0] = ADE7759_READ_REG(reg_address);
> -	memset(&st->tx[1], 0, 5);
> -
> -	ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
> -	if (ret) {
> -		dev_err(&st->us->dev,
> -			"problem when reading 40 bit register 0x%02X",
> -			reg_address);
> -		goto error_ret;
> -	}
> -	*val = ((u64)st->rx[1] << 32) | ((u64)st->rx[2] << 24) |
> -		(st->rx[3] << 16) | (st->rx[4] << 8) | st->rx[5];
> -
> -error_ret:
> -	mutex_unlock(&st->buf_lock);
> -	return ret;
> -}
> -
> -static ssize_t ade7759_read_8bit(struct device *dev,
> -				 struct device_attribute *attr,
> -				 char *buf)
> -{
> -	int ret;
> -	u8 val = 0;
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -
> -	ret = ade7759_spi_read_reg_8(dev, this_attr->address, &val);
> -	if (ret)
> -		return ret;
> -
> -	return sprintf(buf, "%u\n", val);
> -}
> -
> -static ssize_t ade7759_read_16bit(struct device *dev,
> -				  struct device_attribute *attr,
> -				  char *buf)
> -{
> -	int ret;
> -	u16 val = 0;
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -
> -	ret = ade7759_spi_read_reg_16(dev, this_attr->address, &val);
> -	if (ret)
> -		return ret;
> -
> -	return sprintf(buf, "%u\n", val);
> -}
> -
> -static ssize_t ade7759_read_40bit(struct device *dev,
> -				  struct device_attribute *attr,
> -				  char *buf)
> -{
> -	int ret;
> -	u64 val = 0;
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -
> -	ret = ade7759_spi_read_reg_40(dev, this_attr->address, &val);
> -	if (ret)
> -		return ret;
> -
> -	return sprintf(buf, "%llu\n", val);
> -}
> -
> -static ssize_t ade7759_write_8bit(struct device *dev,
> -				  struct device_attribute *attr,
> -				  const char *buf,
> -				  size_t len)
> -{
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -	int ret;
> -	u8 val;
> -
> -	ret = kstrtou8(buf, 10, &val);
> -	if (ret)
> -		goto error_ret;
> -	ret = ade7759_spi_write_reg_8(dev, this_attr->address, val);
> -
> -error_ret:
> -	return ret ? ret : len;
> -}
> -
> -static ssize_t ade7759_write_16bit(struct device *dev,
> -				   struct device_attribute *attr,
> -				   const char *buf,
> -				   size_t len)
> -{
> -	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -	int ret;
> -	u16 val;
> -
> -	ret = kstrtou16(buf, 10, &val);
> -	if (ret)
> -		goto error_ret;
> -	ret = ade7759_spi_write_reg_16(dev, this_attr->address, val);
> -
> -error_ret:
> -	return ret ? ret : len;
> -}
> -
> -static int ade7759_reset(struct device *dev)
> -{
> -	int ret;
> -	u16 val;
> -
> -	ret = ade7759_spi_read_reg_16(dev, ADE7759_MODE, &val);
> -	if (ret < 0)
> -		return ret;
> -
> -	val |= BIT(6); /* Software Chip Reset */
> -	return ade7759_spi_write_reg_16(dev,
> -			ADE7759_MODE,
> -			val);
> -}
> -
> -static IIO_DEV_ATTR_AENERGY(ade7759_read_40bit, ADE7759_AENERGY);
> -static IIO_DEV_ATTR_CFDEN(0644,
> -		ade7759_read_16bit,
> -		ade7759_write_16bit,
> -		ADE7759_CFDEN);
> -static IIO_DEV_ATTR_CFNUM(0644,
> -		ade7759_read_8bit,
> -		ade7759_write_8bit,
> -		ADE7759_CFNUM);
> -static IIO_DEV_ATTR_CHKSUM(ade7759_read_8bit, ADE7759_CHKSUM);
> -static IIO_DEV_ATTR_PHCAL(0644,
> -		ade7759_read_16bit,
> -		ade7759_write_16bit,
> -		ADE7759_PHCAL);
> -static IIO_DEV_ATTR_APOS(0644,
> -		ade7759_read_16bit,
> -		ade7759_write_16bit,
> -		ADE7759_APOS);
> -static IIO_DEV_ATTR_SAGCYC(0644,
> -		ade7759_read_8bit,
> -		ade7759_write_8bit,
> -		ADE7759_SAGCYC);
> -static IIO_DEV_ATTR_SAGLVL(0644,
> -		ade7759_read_8bit,
> -		ade7759_write_8bit,
> -		ADE7759_SAGLVL);
> -static IIO_DEV_ATTR_LINECYC(0644,
> -		ade7759_read_8bit,
> -		ade7759_write_8bit,
> -		ADE7759_LINECYC);
> -static IIO_DEV_ATTR_LENERGY(ade7759_read_40bit, ADE7759_LENERGY);
> -static IIO_DEV_ATTR_PGA_GAIN(0644,
> -		ade7759_read_8bit,
> -		ade7759_write_8bit,
> -		ADE7759_GAIN);
> -static IIO_DEV_ATTR_ACTIVE_POWER_GAIN(0644,
> -		ade7759_read_16bit,
> -		ade7759_write_16bit,
> -		ADE7759_APGAIN);
> -
> -static IIO_DEVICE_ATTR(choff_1, 0644,
> -			ade7759_read_8bit,
> -			ade7759_write_8bit,
> -			ADE7759_CH1OS);
> -
> -static IIO_DEVICE_ATTR(choff_2, 0644,
> -			ade7759_read_8bit,
> -			ade7759_write_8bit,
> -			ADE7759_CH2OS);
> -
> -static int ade7759_set_irq(struct device *dev, bool enable)
> -{
> -	int ret;
> -	u8 irqen;
> -
> -	ret = ade7759_spi_read_reg_8(dev, ADE7759_IRQEN, &irqen);
> -	if (ret)
> -		goto error_ret;
> -
> -	if (enable)
> -		irqen |= BIT(3); /* Enables an interrupt when a data is
> -				  * present in the waveform register
> -				  */
> -	else
> -		irqen &= ~BIT(3);
> -
> -	ret = ade7759_spi_write_reg_8(dev, ADE7759_IRQEN, irqen);
> -
> -error_ret:
> -	return ret;
> -}
> -
> -/* Power down the device */
> -static int ade7759_stop_device(struct device *dev)
> -{
> -	int ret;
> -	u16 val;
> -
> -	ret = ade7759_spi_read_reg_16(dev, ADE7759_MODE, &val);
> -	if (ret < 0) {
> -		dev_err(dev, "unable to power down the device, error: %d\n",
> -			ret);
> -		return ret;
> -	}
> -
> -	val |= BIT(4);  /* AD converters can be turned off */
> -
> -	return ade7759_spi_write_reg_16(dev, ADE7759_MODE, val);
> -}
> -
> -static int ade7759_initial_setup(struct iio_dev *indio_dev)
> -{
> -	int ret;
> -	struct ade7759_state *st = iio_priv(indio_dev);
> -	struct device *dev = &indio_dev->dev;
> -
> -	/* use low spi speed for init */
> -	st->us->mode = SPI_MODE_3;
> -	spi_setup(st->us);
> -
> -	/* Disable IRQ */
> -	ret = ade7759_set_irq(dev, false);
> -	if (ret) {
> -		dev_err(dev, "disable irq failed");
> -		goto err_ret;
> -	}
> -
> -	ade7759_reset(dev);
> -	usleep_range(ADE7759_STARTUP_DELAY, ADE7759_STARTUP_DELAY + 100);
> -
> -err_ret:
> -	return ret;
> -}
> -
> -static ssize_t ade7759_read_frequency(struct device *dev,
> -				      struct device_attribute *attr,
> -				      char *buf)
> -{
> -	int ret;
> -	u16 t;
> -	int sps;
> -
> -	ret = ade7759_spi_read_reg_16(dev, ADE7759_MODE, &t);
> -	if (ret)
> -		return ret;
> -
> -	t = (t >> 3) & 0x3;
> -	sps = 27900 / (1 + t);
> -
> -	return sprintf(buf, "%d\n", sps);
> -}
> -
> -static ssize_t ade7759_write_frequency(struct device *dev,
> -				       struct device_attribute *attr,
> -				       const char *buf,
> -				       size_t len)
> -{
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	struct ade7759_state *st = iio_priv(indio_dev);
> -	u16 val;
> -	int ret;
> -	u16 reg, t;
> -
> -	ret = kstrtou16(buf, 10, &val);
> -	if (ret)
> -		return ret;
> -	if (!val)
> -		return -EINVAL;
> -
> -	mutex_lock(&st->buf_lock);
> -
> -	t = 27900 / val;
> -	if (t > 0)
> -		t--;
> -
> -	if (t > 1)
> -		st->us->max_speed_hz = ADE7759_SPI_SLOW;
> -	else
> -		st->us->max_speed_hz = ADE7759_SPI_FAST;
> -
> -	ret = ade7759_spi_read_reg_16(dev, ADE7759_MODE, &reg);
> -	if (ret)
> -		goto out;
> -
> -	reg &= ~(3 << 13);
> -	reg |= t << 13;
> -
> -	ret = __ade7759_spi_write_reg_16(dev, ADE7759_MODE, reg);
> -
> -out:
> -	mutex_unlock(&st->buf_lock);
> -
> -	return ret ? ret : len;
> -}
> -static IIO_DEV_ATTR_TEMP_RAW(ade7759_read_8bit);
> -static IIO_CONST_ATTR(in_temp_offset, "70 C");
> -static IIO_CONST_ATTR(in_temp_scale, "1 C");
> -
> -static IIO_DEV_ATTR_SAMP_FREQ(0644,
> -		ade7759_read_frequency,
> -		ade7759_write_frequency);
> -
> -static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("27900 14000 7000 3500");
> -
> -static struct attribute *ade7759_attributes[] = {
> -	&iio_dev_attr_in_temp_raw.dev_attr.attr,
> -	&iio_const_attr_in_temp_offset.dev_attr.attr,
> -	&iio_const_attr_in_temp_scale.dev_attr.attr,
> -	&iio_dev_attr_sampling_frequency.dev_attr.attr,
> -	&iio_const_attr_sampling_frequency_available.dev_attr.attr,
> -	&iio_dev_attr_phcal.dev_attr.attr,
> -	&iio_dev_attr_cfden.dev_attr.attr,
> -	&iio_dev_attr_aenergy.dev_attr.attr,
> -	&iio_dev_attr_cfnum.dev_attr.attr,
> -	&iio_dev_attr_apos.dev_attr.attr,
> -	&iio_dev_attr_sagcyc.dev_attr.attr,
> -	&iio_dev_attr_saglvl.dev_attr.attr,
> -	&iio_dev_attr_linecyc.dev_attr.attr,
> -	&iio_dev_attr_lenergy.dev_attr.attr,
> -	&iio_dev_attr_chksum.dev_attr.attr,
> -	&iio_dev_attr_pga_gain.dev_attr.attr,
> -	&iio_dev_attr_active_power_gain.dev_attr.attr,
> -	&iio_dev_attr_choff_1.dev_attr.attr,
> -	&iio_dev_attr_choff_2.dev_attr.attr,
> -	NULL,
> -};
> -
> -static const struct attribute_group ade7759_attribute_group = {
> -	.attrs = ade7759_attributes,
> -};
> -
> -static const struct iio_info ade7759_info = {
> -	.attrs = &ade7759_attribute_group,
> -};
> -
> -static int ade7759_probe(struct spi_device *spi)
> -{
> -	int ret;
> -	struct ade7759_state *st;
> -	struct iio_dev *indio_dev;
> -
> -	/* setup the industrialio driver allocated elements */
> -	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> -	if (!indio_dev)
> -		return -ENOMEM;
> -	/* this is only used for removal purposes */
> -	spi_set_drvdata(spi, indio_dev);
> -
> -	st = iio_priv(indio_dev);
> -	st->us = spi;
> -	mutex_init(&st->buf_lock);
> -	indio_dev->name = spi->dev.driver->name;
> -	indio_dev->dev.parent = &spi->dev;
> -	indio_dev->info = &ade7759_info;
> -	indio_dev->modes = INDIO_DIRECT_MODE;
> -
> -	/* Get the device into a sane initial state */
> -	ret = ade7759_initial_setup(indio_dev);
> -	if (ret)
> -		return ret;
> -
> -	return iio_device_register(indio_dev);
> -}
> -
> -static int ade7759_remove(struct spi_device *spi)
> -{
> -	struct iio_dev *indio_dev = spi_get_drvdata(spi);
> -
> -	iio_device_unregister(indio_dev);
> -	ade7759_stop_device(&indio_dev->dev);
> -
> -	return 0;
> -}
> -
> -static struct spi_driver ade7759_driver = {
> -	.driver = {
> -		.name = "ade7759",
> -	},
> -	.probe = ade7759_probe,
> -	.remove = ade7759_remove,
> -};
> -module_spi_driver(ade7759_driver);
> -
> -MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
> -MODULE_DESCRIPTION("Analog Devices ADE7759 Active Energy Metering IC Driver");
> -MODULE_LICENSE("GPL v2");
> -MODULE_ALIAS("spi:ad7759");


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-05-20 11:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-12 17:51 [PATCH 0/4] staging:iio: Drop 4 meter drivers Jonathan Cameron
2018-05-12 17:51 ` [PATCH 1/4] staging:iio:meter: Drop ADE7753 driver Jonathan Cameron
2018-05-20 11:21   ` Jonathan Cameron
2018-05-12 17:51 ` [PATCH 2/4] staging:iio:meter: Drop ADE7754 driver Jonathan Cameron
2018-05-20 11:22   ` Jonathan Cameron
2018-05-12 17:51 ` [PATCH 3/4] staging:iio:meter: Drop ADE7758 driver Jonathan Cameron
2018-05-20 11:22   ` Jonathan Cameron
2018-05-12 17:51 ` [PATCH 4/4] staging:iio:meter: Drop ADE7759 driver Jonathan Cameron
2018-05-20 11:22   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).