Re: [PATCH 4/4] staging: iio: accel: Move adis16201 driver out of staging

2018-02-17 Thread Jonathan Cameron
On Mon, 12 Feb 2018 17:45:42 +0300
Dan Carpenter  wrote:

> On Mon, Feb 12, 2018 at 08:11:57PM +0530, Himanshu Jha wrote:
> > On Mon, Feb 12, 2018 at 04:18:26PM +0300, Dan Carpenter wrote:  
> > > I think -M is prefered for these types of diffs?  Not sure.  
> > 
> > I wrote about that in the cover letter if you missed. :)
> >   
> 
> Yeah.  I seldom read cover letters.

For anyone else (like me) who also doesn't often read them...

This was a specific request from me to not use move detection.

The reason is that it presents an opportunity for staging graduation patches
for people to have the whole code in front of them allowing them to do a full
review as if it were a new driver.

I personally find this very helpful in this one case. For any other
code move I'm as in favour of short emails as the next person ;)

Jonathan
> 
> > > > +   ret = adis_init(st, indio_dev, spi, _data);
> > > > +   if (ret)
> > > > +   return ret;
> > > > +
> > > > +   ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL);
> > > > +   if (ret)
> > > > +   return ret;  
> > > 
> > > We should clean up the IRQ which we enabled in adis_init() instead of
> > > returning directly.  
> > 
> > I'm not sure about how to do that.
> >   
> 
> I believe in you that you can figure it out.  :)
> 
> regards,
> dan carpenter
> 
> 



Re: [PATCH 4/4] staging: iio: accel: Move adis16201 driver out of staging

2018-02-17 Thread Jonathan Cameron
On Mon, 12 Feb 2018 17:45:42 +0300
Dan Carpenter  wrote:

> On Mon, Feb 12, 2018 at 08:11:57PM +0530, Himanshu Jha wrote:
> > On Mon, Feb 12, 2018 at 04:18:26PM +0300, Dan Carpenter wrote:  
> > > I think -M is prefered for these types of diffs?  Not sure.  
> > 
> > I wrote about that in the cover letter if you missed. :)
> >   
> 
> Yeah.  I seldom read cover letters.

For anyone else (like me) who also doesn't often read them...

This was a specific request from me to not use move detection.

The reason is that it presents an opportunity for staging graduation patches
for people to have the whole code in front of them allowing them to do a full
review as if it were a new driver.

I personally find this very helpful in this one case. For any other
code move I'm as in favour of short emails as the next person ;)

Jonathan
> 
> > > > +   ret = adis_init(st, indio_dev, spi, _data);
> > > > +   if (ret)
> > > > +   return ret;
> > > > +
> > > > +   ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL);
> > > > +   if (ret)
> > > > +   return ret;  
> > > 
> > > We should clean up the IRQ which we enabled in adis_init() instead of
> > > returning directly.  
> > 
> > I'm not sure about how to do that.
> >   
> 
> I believe in you that you can figure it out.  :)
> 
> regards,
> dan carpenter
> 
> 



Re: [PATCH 4/4] staging: iio: accel: Move adis16201 driver out of staging

2018-02-12 Thread Philippe Ombredanne
On Mon, Feb 12, 2018 at 3:37 PM, Himanshu Jha
 wrote:
> On Mon, Feb 12, 2018 at 03:10:56PM +0100, Philippe Ombredanne wrote:
>> On Mon, Feb 12, 2018 at 12:54 PM, Himanshu Jha
>>  wrote:
>> > Move the adis16201 driver out of staging directory and merge to the
>> > mainline IIO directory.
>> >
>> > Signed-off-by: Himanshu Jha 
>>
>> 
>> > --- /dev/null
>> > +++ b/drivers/iio/accel/adis16201.c
>> > @@ -0,0 +1,315 @@
>> > +// SPDX-License-Identifier: GPL-2.0+
>>
>> 
>>
>> > +MODULE_AUTHOR("Barry Song <21cn...@gmail.com>");
>> > +MODULE_DESCRIPTION("Analog Devices ADIS16201 Dual-Axis Digital 
>> > Inclinometer and Accelerometer");
>> > +MODULE_LICENSE("GPL v2");
>> > +MODULE_ALIAS("spi:adis16201");
>>
>> Your MODULE_LICENSE does not match your SPDX license id.
>> MODULE_LICENSE("GPL v2"); means SPDX GPL-2.0
>> MODULE_LICENSE("GPL"); means SPDX GPL-2.0+
>>
>
> I didn't knew about that! Thanks for pointing.

Sure thing. I reckon this can be a tad surprising.
FWIW, the reference for the SPDX tag is in
Documentation/process/license-rules.rst and for the MODULE_LICENSE
macro this is in module.h
It is unlikely module.h will ever evolve there as this would break all
third-party module loaders/tools that rely on the documented data
values and conventions

-- 
Cordially
Philippe Ombredanne


Re: [PATCH 4/4] staging: iio: accel: Move adis16201 driver out of staging

2018-02-12 Thread Philippe Ombredanne
On Mon, Feb 12, 2018 at 3:37 PM, Himanshu Jha
 wrote:
> On Mon, Feb 12, 2018 at 03:10:56PM +0100, Philippe Ombredanne wrote:
>> On Mon, Feb 12, 2018 at 12:54 PM, Himanshu Jha
>>  wrote:
>> > Move the adis16201 driver out of staging directory and merge to the
>> > mainline IIO directory.
>> >
>> > Signed-off-by: Himanshu Jha 
>>
>> 
>> > --- /dev/null
>> > +++ b/drivers/iio/accel/adis16201.c
>> > @@ -0,0 +1,315 @@
>> > +// SPDX-License-Identifier: GPL-2.0+
>>
>> 
>>
>> > +MODULE_AUTHOR("Barry Song <21cn...@gmail.com>");
>> > +MODULE_DESCRIPTION("Analog Devices ADIS16201 Dual-Axis Digital 
>> > Inclinometer and Accelerometer");
>> > +MODULE_LICENSE("GPL v2");
>> > +MODULE_ALIAS("spi:adis16201");
>>
>> Your MODULE_LICENSE does not match your SPDX license id.
>> MODULE_LICENSE("GPL v2"); means SPDX GPL-2.0
>> MODULE_LICENSE("GPL"); means SPDX GPL-2.0+
>>
>
> I didn't knew about that! Thanks for pointing.

Sure thing. I reckon this can be a tad surprising.
FWIW, the reference for the SPDX tag is in
Documentation/process/license-rules.rst and for the MODULE_LICENSE
macro this is in module.h
It is unlikely module.h will ever evolve there as this would break all
third-party module loaders/tools that rely on the documented data
values and conventions

-- 
Cordially
Philippe Ombredanne


Re: [PATCH 4/4] staging: iio: accel: Move adis16201 driver out of staging

2018-02-12 Thread Dan Carpenter
On Mon, Feb 12, 2018 at 08:11:57PM +0530, Himanshu Jha wrote:
> On Mon, Feb 12, 2018 at 04:18:26PM +0300, Dan Carpenter wrote:
> > I think -M is prefered for these types of diffs?  Not sure.
> 
> I wrote about that in the cover letter if you missed. :)
> 

Yeah.  I seldom read cover letters.

> > > + ret = adis_init(st, indio_dev, spi, _data);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL);
> > > + if (ret)
> > > + return ret;
> > 
> > We should clean up the IRQ which we enabled in adis_init() instead of
> > returning directly.
> 
> I'm not sure about how to do that.
> 

I believe in you that you can figure it out.  :)

regards,
dan carpenter




Re: [PATCH 4/4] staging: iio: accel: Move adis16201 driver out of staging

2018-02-12 Thread Dan Carpenter
On Mon, Feb 12, 2018 at 08:11:57PM +0530, Himanshu Jha wrote:
> On Mon, Feb 12, 2018 at 04:18:26PM +0300, Dan Carpenter wrote:
> > I think -M is prefered for these types of diffs?  Not sure.
> 
> I wrote about that in the cover letter if you missed. :)
> 

Yeah.  I seldom read cover letters.

> > > + ret = adis_init(st, indio_dev, spi, _data);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL);
> > > + if (ret)
> > > + return ret;
> > 
> > We should clean up the IRQ which we enabled in adis_init() instead of
> > returning directly.
> 
> I'm not sure about how to do that.
> 

I believe in you that you can figure it out.  :)

regards,
dan carpenter




Re: [PATCH 4/4] staging: iio: accel: Move adis16201 driver out of staging

2018-02-12 Thread Himanshu Jha
On Mon, Feb 12, 2018 at 04:18:26PM +0300, Dan Carpenter wrote:
> I think -M is prefered for these types of diffs?  Not sure.

I wrote about that in the cover letter if you missed. :)

> On Mon, Feb 12, 2018 at 05:24:59PM +0530, Himanshu Jha wrote:
> > +static int adis16201_probe(struct spi_device *spi)
> > +{
> > +   struct iio_dev *indio_dev;
> > +   struct adis *st;
> > +   int ret;
> > +
> > +   indio_dev = devm_iio_device_alloc(>dev, sizeof(*st));
> > +   if (!indio_dev)
> > +   return -ENOMEM;
> > +
> > +   st = iio_priv(indio_dev);
> > +   spi_set_drvdata(spi, indio_dev);
> > +
> > +   indio_dev->name = spi->dev.driver->name;
> > +   indio_dev->dev.parent = >dev;
> > +   indio_dev->info = _info;
> > +
> > +   indio_dev->channels = adis16201_channels;
> > +   indio_dev->num_channels = ARRAY_SIZE(adis16201_channels);
> > +   indio_dev->modes = INDIO_DIRECT_MODE;
> > +
> > +   ret = adis_init(st, indio_dev, spi, _data);
> > +   if (ret)
> > +   return ret;
> > +
> > +   ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL);
> > +   if (ret)
> > +   return ret;
> 
> We should clean up the IRQ which we enabled in adis_init() instead of
> returning directly.

I'm not sure about how to do that.

-- 
Thanks
Himanshu Jha


Re: [PATCH 4/4] staging: iio: accel: Move adis16201 driver out of staging

2018-02-12 Thread Himanshu Jha
On Mon, Feb 12, 2018 at 04:18:26PM +0300, Dan Carpenter wrote:
> I think -M is prefered for these types of diffs?  Not sure.

I wrote about that in the cover letter if you missed. :)

> On Mon, Feb 12, 2018 at 05:24:59PM +0530, Himanshu Jha wrote:
> > +static int adis16201_probe(struct spi_device *spi)
> > +{
> > +   struct iio_dev *indio_dev;
> > +   struct adis *st;
> > +   int ret;
> > +
> > +   indio_dev = devm_iio_device_alloc(>dev, sizeof(*st));
> > +   if (!indio_dev)
> > +   return -ENOMEM;
> > +
> > +   st = iio_priv(indio_dev);
> > +   spi_set_drvdata(spi, indio_dev);
> > +
> > +   indio_dev->name = spi->dev.driver->name;
> > +   indio_dev->dev.parent = >dev;
> > +   indio_dev->info = _info;
> > +
> > +   indio_dev->channels = adis16201_channels;
> > +   indio_dev->num_channels = ARRAY_SIZE(adis16201_channels);
> > +   indio_dev->modes = INDIO_DIRECT_MODE;
> > +
> > +   ret = adis_init(st, indio_dev, spi, _data);
> > +   if (ret)
> > +   return ret;
> > +
> > +   ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL);
> > +   if (ret)
> > +   return ret;
> 
> We should clean up the IRQ which we enabled in adis_init() instead of
> returning directly.

I'm not sure about how to do that.

-- 
Thanks
Himanshu Jha


Re: [PATCH 4/4] staging: iio: accel: Move adis16201 driver out of staging

2018-02-12 Thread Himanshu Jha
On Mon, Feb 12, 2018 at 03:10:56PM +0100, Philippe Ombredanne wrote:
> On Mon, Feb 12, 2018 at 12:54 PM, Himanshu Jha
>  wrote:
> > Move the adis16201 driver out of staging directory and merge to the
> > mainline IIO directory.
> >
> > Signed-off-by: Himanshu Jha 
> 
> 
> > --- /dev/null
> > +++ b/drivers/iio/accel/adis16201.c
> > @@ -0,0 +1,315 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> 
> 
> 
> > +MODULE_AUTHOR("Barry Song <21cn...@gmail.com>");
> > +MODULE_DESCRIPTION("Analog Devices ADIS16201 Dual-Axis Digital 
> > Inclinometer and Accelerometer");
> > +MODULE_LICENSE("GPL v2");
> > +MODULE_ALIAS("spi:adis16201");
> 
> Your MODULE_LICENSE does not match your SPDX license id.
> MODULE_LICENSE("GPL v2"); means SPDX GPL-2.0
> MODULE_LICENSE("GPL"); means SPDX GPL-2.0+
> 

I didn't knew about that! Thanks for pointing.

-- 
Thanks
Himanshu Jha


Re: [PATCH 4/4] staging: iio: accel: Move adis16201 driver out of staging

2018-02-12 Thread Himanshu Jha
On Mon, Feb 12, 2018 at 03:10:56PM +0100, Philippe Ombredanne wrote:
> On Mon, Feb 12, 2018 at 12:54 PM, Himanshu Jha
>  wrote:
> > Move the adis16201 driver out of staging directory and merge to the
> > mainline IIO directory.
> >
> > Signed-off-by: Himanshu Jha 
> 
> 
> > --- /dev/null
> > +++ b/drivers/iio/accel/adis16201.c
> > @@ -0,0 +1,315 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> 
> 
> 
> > +MODULE_AUTHOR("Barry Song <21cn...@gmail.com>");
> > +MODULE_DESCRIPTION("Analog Devices ADIS16201 Dual-Axis Digital 
> > Inclinometer and Accelerometer");
> > +MODULE_LICENSE("GPL v2");
> > +MODULE_ALIAS("spi:adis16201");
> 
> Your MODULE_LICENSE does not match your SPDX license id.
> MODULE_LICENSE("GPL v2"); means SPDX GPL-2.0
> MODULE_LICENSE("GPL"); means SPDX GPL-2.0+
> 

I didn't knew about that! Thanks for pointing.

-- 
Thanks
Himanshu Jha


Re: [PATCH 4/4] staging: iio: accel: Move adis16201 driver out of staging

2018-02-12 Thread Philippe Ombredanne
On Mon, Feb 12, 2018 at 12:54 PM, Himanshu Jha
 wrote:
> Move the adis16201 driver out of staging directory and merge to the
> mainline IIO directory.
>
> Signed-off-by: Himanshu Jha 


> --- /dev/null
> +++ b/drivers/iio/accel/adis16201.c
> @@ -0,0 +1,315 @@
> +// SPDX-License-Identifier: GPL-2.0+



> +MODULE_AUTHOR("Barry Song <21cn...@gmail.com>");
> +MODULE_DESCRIPTION("Analog Devices ADIS16201 Dual-Axis Digital Inclinometer 
> and Accelerometer");
> +MODULE_LICENSE("GPL v2");
> +MODULE_ALIAS("spi:adis16201");

Your MODULE_LICENSE does not match your SPDX license id.
MODULE_LICENSE("GPL v2"); means SPDX GPL-2.0
MODULE_LICENSE("GPL"); means SPDX GPL-2.0+


-- 
Cordially
Philippe Ombredanne


Re: [PATCH 4/4] staging: iio: accel: Move adis16201 driver out of staging

2018-02-12 Thread Philippe Ombredanne
On Mon, Feb 12, 2018 at 12:54 PM, Himanshu Jha
 wrote:
> Move the adis16201 driver out of staging directory and merge to the
> mainline IIO directory.
>
> Signed-off-by: Himanshu Jha 


> --- /dev/null
> +++ b/drivers/iio/accel/adis16201.c
> @@ -0,0 +1,315 @@
> +// SPDX-License-Identifier: GPL-2.0+



> +MODULE_AUTHOR("Barry Song <21cn...@gmail.com>");
> +MODULE_DESCRIPTION("Analog Devices ADIS16201 Dual-Axis Digital Inclinometer 
> and Accelerometer");
> +MODULE_LICENSE("GPL v2");
> +MODULE_ALIAS("spi:adis16201");

Your MODULE_LICENSE does not match your SPDX license id.
MODULE_LICENSE("GPL v2"); means SPDX GPL-2.0
MODULE_LICENSE("GPL"); means SPDX GPL-2.0+


-- 
Cordially
Philippe Ombredanne


Re: [PATCH 4/4] staging: iio: accel: Move adis16201 driver out of staging

2018-02-12 Thread Dan Carpenter
I think -M is prefered for these types of diffs?  Not sure.

On Mon, Feb 12, 2018 at 05:24:59PM +0530, Himanshu Jha wrote:
> +static int adis16201_probe(struct spi_device *spi)
> +{
> + struct iio_dev *indio_dev;
> + struct adis *st;
> + int ret;
> +
> + indio_dev = devm_iio_device_alloc(>dev, sizeof(*st));
> + if (!indio_dev)
> + return -ENOMEM;
> +
> + st = iio_priv(indio_dev);
> + spi_set_drvdata(spi, indio_dev);
> +
> + indio_dev->name = spi->dev.driver->name;
> + indio_dev->dev.parent = >dev;
> + indio_dev->info = _info;
> +
> + indio_dev->channels = adis16201_channels;
> + indio_dev->num_channels = ARRAY_SIZE(adis16201_channels);
> + indio_dev->modes = INDIO_DIRECT_MODE;
> +
> + ret = adis_init(st, indio_dev, spi, _data);
> + if (ret)
> + return ret;
> +
> + ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL);
> + if (ret)
> + return ret;

We should clean up the IRQ which we enabled in adis_init() instead of
returning directly.

> +
> + /* Get the device into a sane initial state */
> + ret = adis_initial_startup(st);
> + if (ret)
> + goto error_cleanup_buffer_trigger;
> +
> + ret = iio_device_register(indio_dev);
> + if (ret < 0)
> + goto error_cleanup_buffer_trigger;
> +
> + return 0;
> +
> +error_cleanup_buffer_trigger:
> + adis_cleanup_buffer_and_trigger(st, indio_dev);
> +
> + return ret;
> +}

Otherwise it looks fine to my not-an-iio-expert eye.

regards,
dan carpenter



Re: [PATCH 4/4] staging: iio: accel: Move adis16201 driver out of staging

2018-02-12 Thread Dan Carpenter
I think -M is prefered for these types of diffs?  Not sure.

On Mon, Feb 12, 2018 at 05:24:59PM +0530, Himanshu Jha wrote:
> +static int adis16201_probe(struct spi_device *spi)
> +{
> + struct iio_dev *indio_dev;
> + struct adis *st;
> + int ret;
> +
> + indio_dev = devm_iio_device_alloc(>dev, sizeof(*st));
> + if (!indio_dev)
> + return -ENOMEM;
> +
> + st = iio_priv(indio_dev);
> + spi_set_drvdata(spi, indio_dev);
> +
> + indio_dev->name = spi->dev.driver->name;
> + indio_dev->dev.parent = >dev;
> + indio_dev->info = _info;
> +
> + indio_dev->channels = adis16201_channels;
> + indio_dev->num_channels = ARRAY_SIZE(adis16201_channels);
> + indio_dev->modes = INDIO_DIRECT_MODE;
> +
> + ret = adis_init(st, indio_dev, spi, _data);
> + if (ret)
> + return ret;
> +
> + ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL);
> + if (ret)
> + return ret;

We should clean up the IRQ which we enabled in adis_init() instead of
returning directly.

> +
> + /* Get the device into a sane initial state */
> + ret = adis_initial_startup(st);
> + if (ret)
> + goto error_cleanup_buffer_trigger;
> +
> + ret = iio_device_register(indio_dev);
> + if (ret < 0)
> + goto error_cleanup_buffer_trigger;
> +
> + return 0;
> +
> +error_cleanup_buffer_trigger:
> + adis_cleanup_buffer_and_trigger(st, indio_dev);
> +
> + return ret;
> +}

Otherwise it looks fine to my not-an-iio-expert eye.

regards,
dan carpenter



[PATCH 4/4] staging: iio: accel: Move adis16201 driver out of staging

2018-02-12 Thread Himanshu Jha
Move the adis16201 driver out of staging directory and merge to the
mainline IIO directory.

Signed-off-by: Himanshu Jha 
---
 drivers/iio/accel/Kconfig |  12 ++
 drivers/iio/accel/Makefile|   1 +
 drivers/iio/accel/adis16201.c | 315 ++
 drivers/staging/iio/accel/Kconfig |  12 --
 drivers/staging/iio/accel/Makefile|   1 -
 drivers/staging/iio/accel/adis16201.c | 315 --
 6 files changed, 328 insertions(+), 328 deletions(-)
 create mode 100644 drivers/iio/accel/adis16201.c
 delete mode 100644 drivers/staging/iio/accel/adis16201.c

diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig
index c6d9517..9416c6f 100644
--- a/drivers/iio/accel/Kconfig
+++ b/drivers/iio/accel/Kconfig
@@ -5,6 +5,18 @@
 
 menu "Accelerometers"
 
+config ADIS16201
+tristate "Analog Devices ADIS16201 Dual-Axis Digital Inclinometer and 
Accelerometer"
+depends on SPI
+select IIO_ADIS_LIB
+select IIO_ADIS_LIB_BUFFER if IIO_BUFFER
+help
+  Say Y here to build support for Analog Devices adis16201 dual-axis
+  digital inclinometer and accelerometer.
+
+  To compile this driver as a module, say M here: the module will
+  be called adis16201.
+
 config ADXL345
tristate
 
diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile
index 368aedb..7832ec9 100644
--- a/drivers/iio/accel/Makefile
+++ b/drivers/iio/accel/Makefile
@@ -4,6 +4,7 @@
 #
 
 # When adding new entries keep the list in alphabetical order
+obj-$(CONFIG_ADIS16201) += adis16201.o
 obj-$(CONFIG_ADXL345) += adxl345_core.o
 obj-$(CONFIG_ADXL345_I2C) += adxl345_i2c.o
 obj-$(CONFIG_ADXL345_SPI) += adxl345_spi.o
diff --git a/drivers/iio/accel/adis16201.c b/drivers/iio/accel/adis16201.c
new file mode 100644
index 000..6800347
--- /dev/null
+++ b/drivers/iio/accel/adis16201.c
@@ -0,0 +1,315 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * ADIS16201 Dual-Axis Digital Inclinometer and Accelerometer
+ *
+ * Copyright 2010 Analog Devices Inc.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#define ADIS16201_STARTUP_DELAY_MS 220
+#define ADIS16201_FLASH_CNT_REG0x00
+
+/* Data Output Register Definitions */
+#define ADIS16201_SUPPLY_OUT_REG   0x02
+#define ADIS16201_XACCL_OUT_REG0x04
+#define ADIS16201_YACCL_OUT_REG0x06
+#define ADIS16201_AUX_ADC_REG  0x08
+#define ADIS16201_TEMP_OUT_REG 0x0A
+#define ADIS16201_XINCL_OUT_REG0x0C
+#define ADIS16201_YINCL_OUT_REG0x0E
+
+/* Calibration Register Definitions */
+#define ADIS16201_XACCL_OFFS_REG   0x10
+#define ADIS16201_YACCL_OFFS_REG   0x12
+#define ADIS16201_XACCL_SCALE_REG  0x14
+#define ADIS16201_YACCL_SCALE_REG  0x16
+#define ADIS16201_XINCL_OFFS_REG   0x18
+#define ADIS16201_YINCL_OFFS_REG   0x1A
+#define ADIS16201_XINCL_SCALE_REG  0x1C
+#define ADIS16201_YINCL_SCALE_REG  0x1E
+
+/* Alarm Register Definitions */
+#define ADIS16201_ALM_MAG1_REG 0x20
+#define ADIS16201_ALM_MAG2_REG 0x22
+#define ADIS16201_ALM_SMPL1_REG0x24
+#define ADIS16201_ALM_SMPL2_REG0x26
+#define ADIS16201_ALM_CTRL_REG 0x28
+
+#define ADIS16201_AUX_DAC_REG  0x30
+#define ADIS16201_GPIO_CTRL_REG0x32
+#define ADIS16201_SMPL_PRD_REG 0x36
+#define ADIS16201_AVG_CNT_REG  0x38
+#define ADIS16201_SLP_CNT_REG  0x3A
+
+/* MSC_CTRL */
+#define ADIS16201_MSC_CTRL_REG 0x34
+#define ADIS16201_MSC_CTRL_SELF_TEST_ENBIT(8)
+#define ADIS16201_MSC_CTRL_DATA_RDY_EN BIT(2)
+#define ADIS16201_MSC_CTRL_ACTIVE_HIGH BIT(1)
+#define ADIS16201_MSC_CTRL_DATA_RDY_DIO1   BIT(0)
+
+/* DIAG_STAT */
+#define ADIS16201_DIAG_STAT_REG0x3C
+#define ADIS16201_DIAG_STAT_ALARM2 BIT(9)
+#define ADIS16201_DIAG_STAT_ALARM1 BIT(8)
+#define ADIS16201_DIAG_STAT_SPI_FAIL_BIT   3
+#define ADIS16201_DIAG_STAT_FLASH_UPT_BIT  2
+#define ADIS16201_DIAG_STAT_POWER_HIGH_BIT 1
+#define ADIS16201_DIAG_STAT_POWER_LOW_BIT  0
+
+/* GLOB_CMD */
+#define ADIS16201_GLOB_CMD_REG 0x3E
+#define ADIS16201_GLOB_CMD_SW_RESETBIT(7)
+#define ADIS16201_GLOB_CMD_FACTORY_CAL BIT(1)
+
+#define ADIS16201_ERROR_ACTIVE BIT(14)
+
+enum adis16201_scan {
+   ADIS16201_SCAN_ACC_X,
+   ADIS16201_SCAN_ACC_Y,
+   ADIS16201_SCAN_INCLI_X,
+   ADIS16201_SCAN_INCLI_Y,
+   ADIS16201_SCAN_SUPPLY,

[PATCH 4/4] staging: iio: accel: Move adis16201 driver out of staging

2018-02-12 Thread Himanshu Jha
Move the adis16201 driver out of staging directory and merge to the
mainline IIO directory.

Signed-off-by: Himanshu Jha 
---
 drivers/iio/accel/Kconfig |  12 ++
 drivers/iio/accel/Makefile|   1 +
 drivers/iio/accel/adis16201.c | 315 ++
 drivers/staging/iio/accel/Kconfig |  12 --
 drivers/staging/iio/accel/Makefile|   1 -
 drivers/staging/iio/accel/adis16201.c | 315 --
 6 files changed, 328 insertions(+), 328 deletions(-)
 create mode 100644 drivers/iio/accel/adis16201.c
 delete mode 100644 drivers/staging/iio/accel/adis16201.c

diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig
index c6d9517..9416c6f 100644
--- a/drivers/iio/accel/Kconfig
+++ b/drivers/iio/accel/Kconfig
@@ -5,6 +5,18 @@
 
 menu "Accelerometers"
 
+config ADIS16201
+tristate "Analog Devices ADIS16201 Dual-Axis Digital Inclinometer and 
Accelerometer"
+depends on SPI
+select IIO_ADIS_LIB
+select IIO_ADIS_LIB_BUFFER if IIO_BUFFER
+help
+  Say Y here to build support for Analog Devices adis16201 dual-axis
+  digital inclinometer and accelerometer.
+
+  To compile this driver as a module, say M here: the module will
+  be called adis16201.
+
 config ADXL345
tristate
 
diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile
index 368aedb..7832ec9 100644
--- a/drivers/iio/accel/Makefile
+++ b/drivers/iio/accel/Makefile
@@ -4,6 +4,7 @@
 #
 
 # When adding new entries keep the list in alphabetical order
+obj-$(CONFIG_ADIS16201) += adis16201.o
 obj-$(CONFIG_ADXL345) += adxl345_core.o
 obj-$(CONFIG_ADXL345_I2C) += adxl345_i2c.o
 obj-$(CONFIG_ADXL345_SPI) += adxl345_spi.o
diff --git a/drivers/iio/accel/adis16201.c b/drivers/iio/accel/adis16201.c
new file mode 100644
index 000..6800347
--- /dev/null
+++ b/drivers/iio/accel/adis16201.c
@@ -0,0 +1,315 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * ADIS16201 Dual-Axis Digital Inclinometer and Accelerometer
+ *
+ * Copyright 2010 Analog Devices Inc.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#define ADIS16201_STARTUP_DELAY_MS 220
+#define ADIS16201_FLASH_CNT_REG0x00
+
+/* Data Output Register Definitions */
+#define ADIS16201_SUPPLY_OUT_REG   0x02
+#define ADIS16201_XACCL_OUT_REG0x04
+#define ADIS16201_YACCL_OUT_REG0x06
+#define ADIS16201_AUX_ADC_REG  0x08
+#define ADIS16201_TEMP_OUT_REG 0x0A
+#define ADIS16201_XINCL_OUT_REG0x0C
+#define ADIS16201_YINCL_OUT_REG0x0E
+
+/* Calibration Register Definitions */
+#define ADIS16201_XACCL_OFFS_REG   0x10
+#define ADIS16201_YACCL_OFFS_REG   0x12
+#define ADIS16201_XACCL_SCALE_REG  0x14
+#define ADIS16201_YACCL_SCALE_REG  0x16
+#define ADIS16201_XINCL_OFFS_REG   0x18
+#define ADIS16201_YINCL_OFFS_REG   0x1A
+#define ADIS16201_XINCL_SCALE_REG  0x1C
+#define ADIS16201_YINCL_SCALE_REG  0x1E
+
+/* Alarm Register Definitions */
+#define ADIS16201_ALM_MAG1_REG 0x20
+#define ADIS16201_ALM_MAG2_REG 0x22
+#define ADIS16201_ALM_SMPL1_REG0x24
+#define ADIS16201_ALM_SMPL2_REG0x26
+#define ADIS16201_ALM_CTRL_REG 0x28
+
+#define ADIS16201_AUX_DAC_REG  0x30
+#define ADIS16201_GPIO_CTRL_REG0x32
+#define ADIS16201_SMPL_PRD_REG 0x36
+#define ADIS16201_AVG_CNT_REG  0x38
+#define ADIS16201_SLP_CNT_REG  0x3A
+
+/* MSC_CTRL */
+#define ADIS16201_MSC_CTRL_REG 0x34
+#define ADIS16201_MSC_CTRL_SELF_TEST_ENBIT(8)
+#define ADIS16201_MSC_CTRL_DATA_RDY_EN BIT(2)
+#define ADIS16201_MSC_CTRL_ACTIVE_HIGH BIT(1)
+#define ADIS16201_MSC_CTRL_DATA_RDY_DIO1   BIT(0)
+
+/* DIAG_STAT */
+#define ADIS16201_DIAG_STAT_REG0x3C
+#define ADIS16201_DIAG_STAT_ALARM2 BIT(9)
+#define ADIS16201_DIAG_STAT_ALARM1 BIT(8)
+#define ADIS16201_DIAG_STAT_SPI_FAIL_BIT   3
+#define ADIS16201_DIAG_STAT_FLASH_UPT_BIT  2
+#define ADIS16201_DIAG_STAT_POWER_HIGH_BIT 1
+#define ADIS16201_DIAG_STAT_POWER_LOW_BIT  0
+
+/* GLOB_CMD */
+#define ADIS16201_GLOB_CMD_REG 0x3E
+#define ADIS16201_GLOB_CMD_SW_RESETBIT(7)
+#define ADIS16201_GLOB_CMD_FACTORY_CAL BIT(1)
+
+#define ADIS16201_ERROR_ACTIVE BIT(14)
+
+enum adis16201_scan {
+   ADIS16201_SCAN_ACC_X,
+   ADIS16201_SCAN_ACC_Y,
+   ADIS16201_SCAN_INCLI_X,
+   ADIS16201_SCAN_INCLI_Y,
+   ADIS16201_SCAN_SUPPLY,
+