linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/7] staging:iio:ad2s90: Add dt support and move out of staging
@ 2018-11-24  0:23 Matheus Tavares
  2018-11-24  0:23 ` [PATCH v3 1/7] staging:iio:ad2s90: Add device tree support Matheus Tavares
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: Matheus Tavares @ 2018-11-24  0:23 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	Rob Herring, Mark Rutland
  Cc: linux-iio, devel, devicetree, linux-kernel, Alexandru Ardelean,
	kernel-usp, victorcolombo

This series adds device tree support to ad2s90, adds the respective dt-binding
documentation, solves all remaining codestyle problems for ad2s90 and move it
out of staging.

This patch set completes all the remaining itens listed to be done before moving
the driver out of staging, enumerated in this mail thread:
https://marc.info/?l=linux-iio&m=154028966111330&w=2.

Alexandru Ardelean (1):
  staging:iio:ad2s90: Add max frequency check at probe

Matheus Tavares (5):
  staging:iio:ad2s90: Add device tree support
  staging:iio:ad2s90: Remove spi setup that should be done via dt
  dt-bindings:iio:resolver: Add docs for ad2s90
  staging:iio:ad2s90: Replace license text w/ SPDX identifier
  staging:iio:ad2s90: Move out of staging

Victor Colombo (1):
  staging:iio:ad2s90: Add comment to device state mutex

 .../bindings/iio/resolver/ad2s90.txt          |  31 +++++
 drivers/iio/resolver/Kconfig                  |  10 ++
 drivers/iio/resolver/Makefile                 |   1 +
 drivers/iio/resolver/ad2s90.c                 | 131 ++++++++++++++++++
 drivers/staging/iio/resolver/Kconfig          |  10 --
 drivers/staging/iio/resolver/Makefile         |   1 -
 drivers/staging/iio/resolver/ad2s90.c         | 127 -----------------
 7 files changed, 173 insertions(+), 138 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iio/resolver/ad2s90.txt
 create mode 100644 drivers/iio/resolver/ad2s90.c
 delete mode 100644 drivers/staging/iio/resolver/ad2s90.c

-- 
2.18.0


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

* [PATCH v3 1/7] staging:iio:ad2s90: Add device tree support
  2018-11-24  0:23 [PATCH v3 0/7] staging:iio:ad2s90: Add dt support and move out of staging Matheus Tavares
@ 2018-11-24  0:23 ` Matheus Tavares
  2018-12-01 15:34   ` Jonathan Cameron
  2018-11-24  0:23 ` [PATCH v3 2/7] staging:iio:ad2s90: Remove spi setup that should be done via dt Matheus Tavares
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Matheus Tavares @ 2018-11-24  0:23 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	Rob Herring, Mark Rutland
  Cc: linux-iio, devel, devicetree, linux-kernel, Alexandru Ardelean,
	kernel-usp, victorcolombo

This patch adds device tree support to ad2s90 with standard
device tree id table.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
---
Changes in v3:
 - Removed of_patch_ptr from of_match_table assignment

Changes in v2:
 - none

 drivers/staging/iio/resolver/ad2s90.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c
index 3e257ac46f7a..fdae067ed866 100644
--- a/drivers/staging/iio/resolver/ad2s90.c
+++ b/drivers/staging/iio/resolver/ad2s90.c
@@ -107,6 +107,12 @@ static int ad2s90_probe(struct spi_device *spi)
 	return devm_iio_device_register(indio_dev->dev.parent, indio_dev);
 }
 
+static const struct of_device_id ad2s90_of_match[] = {
+	{ .compatible = "adi,ad2s90", },
+	{}
+};
+MODULE_DEVICE_TABLE(of, ad2s90_of_match);
+
 static const struct spi_device_id ad2s90_id[] = {
 	{ "ad2s90" },
 	{}
@@ -116,6 +122,7 @@ MODULE_DEVICE_TABLE(spi, ad2s90_id);
 static struct spi_driver ad2s90_driver = {
 	.driver = {
 		.name = "ad2s90",
+		.of_match_table = ad2s90_of_match,
 	},
 	.probe = ad2s90_probe,
 	.id_table = ad2s90_id,
-- 
2.18.0


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

* [PATCH v3 2/7] staging:iio:ad2s90: Remove spi setup that should be done via dt
  2018-11-24  0:23 [PATCH v3 0/7] staging:iio:ad2s90: Add dt support and move out of staging Matheus Tavares
  2018-11-24  0:23 ` [PATCH v3 1/7] staging:iio:ad2s90: Add device tree support Matheus Tavares
@ 2018-11-24  0:23 ` Matheus Tavares
  2018-12-01 15:34   ` Jonathan Cameron
  2018-11-24  0:23 ` [PATCH v3 3/7] staging:iio:ad2s90: Add max frequency check at probe Matheus Tavares
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Matheus Tavares @ 2018-11-24  0:23 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	Rob Herring, Mark Rutland
  Cc: linux-iio, devel, devicetree, linux-kernel, Alexandru Ardelean,
	kernel-usp, victorcolombo

The ad2s90 driver currently sets some spi settings (max_speed_hz and
mode) at ad2s90_probe. Since the maximum frequency is a required element
in DT binding for spi slave devices and because the spi mode for the
device can be either (0,0) or (1,1), these settings should be handled
via device tree, not in the driver's code. This patch removes them from
the probe function.

Note: The way in which the mentioned spi settings need to be specified
on the ad2s90's node of a device tree will be documented in the future
patch "dt-bindings:iio:resolver: Add docs for ad2s90".

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
---
Changes in v3:
 - none

Changes in v2:
 - Rewritten patch message to better explain why the code snippet in
 question should be removed.

 drivers/staging/iio/resolver/ad2s90.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c
index fdae067ed866..abb9b9147ee6 100644
--- a/drivers/staging/iio/resolver/ad2s90.c
+++ b/drivers/staging/iio/resolver/ad2s90.c
@@ -77,7 +77,6 @@ static int ad2s90_probe(struct spi_device *spi)
 {
 	struct iio_dev *indio_dev;
 	struct ad2s90_state *st;
-	int ret;
 
 	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
 	if (!indio_dev)
@@ -94,16 +93,6 @@ static int ad2s90_probe(struct spi_device *spi)
 	indio_dev->num_channels = 1;
 	indio_dev->name = spi_get_device_id(spi)->name;
 
-	/* need 600ns between CS and the first falling edge of SCLK */
-	spi->max_speed_hz = 830000;
-	spi->mode = SPI_MODE_3;
-	ret = spi_setup(spi);
-
-	if (ret < 0) {
-		dev_err(&spi->dev, "spi_setup failed!\n");
-		return ret;
-	}
-
 	return devm_iio_device_register(indio_dev->dev.parent, indio_dev);
 }
 
-- 
2.18.0


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

* [PATCH v3 3/7] staging:iio:ad2s90: Add max frequency check at probe
  2018-11-24  0:23 [PATCH v3 0/7] staging:iio:ad2s90: Add dt support and move out of staging Matheus Tavares
  2018-11-24  0:23 ` [PATCH v3 1/7] staging:iio:ad2s90: Add device tree support Matheus Tavares
  2018-11-24  0:23 ` [PATCH v3 2/7] staging:iio:ad2s90: Remove spi setup that should be done via dt Matheus Tavares
@ 2018-11-24  0:23 ` Matheus Tavares
  2018-12-01 15:37   ` Jonathan Cameron
  2018-11-24  0:23 ` [PATCH v3 4/7] dt-bindings:iio:resolver: Add docs for ad2s90 Matheus Tavares
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Matheus Tavares @ 2018-11-24  0:23 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	Rob Herring, Mark Rutland
  Cc: linux-iio, devel, devicetree, linux-kernel, Alexandru Ardelean,
	kernel-usp, victorcolombo

From: Alexandru Ardelean <alexandru.ardelean@analog.com>

This patch adds a max frequency check at the beginning of ad2s90_probe
function so that when it is set to a value above 0.83Mhz, dev_err is
called with an appropriate message and -EINVAL is returned.

The defined limit is 0.83Mhz instead of 2Mhz, which is the chip's max
frequency as specified in the datasheet, because, as also specified in
the datasheet, a 600ns delay is expected between the application of a
logic LO to CS and the application of SCLK. Since the delay is not
implemented in the spi code, to satisfy it, SCLK's period should be at
most 2 * 600ns, so the max frequency should be 1 / (2 * 6e-7), which
gives roughly 830000Hz.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
---
Changes in v3:
 - none

Changes in v2:
 - Correctly credit Alexandru as the patch's author

 drivers/staging/iio/resolver/ad2s90.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c
index abb9b9147ee6..4721e9bbb8b0 100644
--- a/drivers/staging/iio/resolver/ad2s90.c
+++ b/drivers/staging/iio/resolver/ad2s90.c
@@ -19,6 +19,12 @@
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 
+/*
+ * Although chip's max frequency is 2Mhz, it needs 600ns between CS and the
+ * first falling edge of SCLK, so frequency should be at most 1 / (2 * 6e-7)
+ */
+#define AD2S90_MAX_SPI_FREQ_HZ  830000
+
 struct ad2s90_state {
 	struct mutex lock;
 	struct spi_device *sdev;
@@ -78,6 +84,12 @@ static int ad2s90_probe(struct spi_device *spi)
 	struct iio_dev *indio_dev;
 	struct ad2s90_state *st;
 
+	if (spi->max_speed_hz > AD2S90_MAX_SPI_FREQ_HZ) {
+		dev_err(&spi->dev, "SPI CLK, %d Hz exceeds %d Hz\n",
+			spi->max_speed_hz, AD2S90_MAX_SPI_FREQ_HZ);
+		return -EINVAL;
+	}
+
 	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
 	if (!indio_dev)
 		return -ENOMEM;
-- 
2.18.0


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

* [PATCH v3 4/7] dt-bindings:iio:resolver: Add docs for ad2s90
  2018-11-24  0:23 [PATCH v3 0/7] staging:iio:ad2s90: Add dt support and move out of staging Matheus Tavares
                   ` (2 preceding siblings ...)
  2018-11-24  0:23 ` [PATCH v3 3/7] staging:iio:ad2s90: Add max frequency check at probe Matheus Tavares
@ 2018-11-24  0:23 ` Matheus Tavares
  2018-11-27  1:52   ` Rob Herring
  2018-11-24  0:23 ` [PATCH v3 5/7] staging:iio:ad2s90: Replace license text w/ SPDX identifier Matheus Tavares
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Matheus Tavares @ 2018-11-24  0:23 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	Rob Herring, Mark Rutland
  Cc: linux-iio, devel, devicetree, linux-kernel, Alexandru Ardelean,
	kernel-usp, victorcolombo

This patch adds the device tree binding documentation for the ad2s90
resolver-to-digital converter.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
---
Changes in v3:
 - Added reference to spi-bus documentation after spi properties, as
 suggested by Alexandru Ardelean.

Changes in v2:
 - Rewritten 'spi-cpol and spi-cpha' item to say that the device can
 work in either mode (0,0) or (1,1) and explain how they should be
 specified in DT.

 .../bindings/iio/resolver/ad2s90.txt          | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/resolver/ad2s90.txt

diff --git a/Documentation/devicetree/bindings/iio/resolver/ad2s90.txt b/Documentation/devicetree/bindings/iio/resolver/ad2s90.txt
new file mode 100644
index 000000000000..477d41fa6467
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/resolver/ad2s90.txt
@@ -0,0 +1,31 @@
+Analog Devices AD2S90 Resolver-to-Digital Converter
+
+https://www.analog.com/en/products/ad2s90.html
+
+Required properties:
+  - compatible: should be "adi,ad2s90"
+  - reg: SPI chip select number for the device
+  - spi-max-frequency: set maximum clock frequency, must be 830000
+  - spi-cpol and spi-cpha:
+        Either SPI mode (0,0) or (1,1) must be used, so specify none or both of
+        spi-cpha, spi-cpol.
+
+See for more details:
+    Documentation/devicetree/bindings/spi/spi-bus.txt
+
+Note about max frequency:
+    Chip's max frequency, as specified in its datasheet, is 2Mhz. But a 600ns
+    delay is expected between the application of a logic LO to CS and the
+    application of SCLK, as also specified. And since the delay is not
+    implemented in the spi code, to satisfy it, SCLK's period should be at most
+    2 * 600ns, so the max frequency should be 1 / (2 * 6e-7), which gives
+    roughly 830000Hz.
+
+Example:
+resolver@0 {
+	compatible = "adi,ad2s90";
+	reg = <0>;
+	spi-max-frequency = <830000>;
+	spi-cpol;
+	spi-cpha;
+};
-- 
2.18.0


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

* [PATCH v3 5/7] staging:iio:ad2s90: Replace license text w/ SPDX identifier
  2018-11-24  0:23 [PATCH v3 0/7] staging:iio:ad2s90: Add dt support and move out of staging Matheus Tavares
                   ` (3 preceding siblings ...)
  2018-11-24  0:23 ` [PATCH v3 4/7] dt-bindings:iio:resolver: Add docs for ad2s90 Matheus Tavares
@ 2018-11-24  0:23 ` Matheus Tavares
  2018-12-01 15:38   ` Jonathan Cameron
  2018-11-24  0:23 ` [PATCH v3 6/7] staging:iio:ad2s90: Add comment to device state mutex Matheus Tavares
  2018-11-24  0:23 ` [PATCH v3 7/7] staging:iio:ad2s90: Move out of staging Matheus Tavares
  6 siblings, 1 reply; 18+ messages in thread
From: Matheus Tavares @ 2018-11-24  0:23 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	Rob Herring, Mark Rutland
  Cc: linux-iio, devel, devicetree, linux-kernel, Alexandru Ardelean,
	kernel-usp, victorcolombo

This patch removes the license boilerplate text at the top of ad2s90.c
and, instead, adds the SPDX GPL-2.0 license identifier, which solves the
checkpatch.pl warning:
"WARNING: Missing or malformed SPDX-License-Identifier tag in line 1".

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
---
Changes in v3:
 - none

Changes in v2:
 - Changed GPL-2.0-only identifier to GPL-2.0
 - Removed license boilerplate text
 - Rewritten patch message to reflect these modifications

 drivers/staging/iio/resolver/ad2s90.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c
index 4721e9bbb8b0..678351dabe6b 100644
--- a/drivers/staging/iio/resolver/ad2s90.c
+++ b/drivers/staging/iio/resolver/ad2s90.c
@@ -1,12 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * ad2s90.c simple support for the ADI Resolver to Digital Converters: AD2S90
  *
  * Copyright (c) 2010-2010 Analog Devices Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
  */
 #include <linux/types.h>
 #include <linux/mutex.h>
-- 
2.18.0


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

* [PATCH v3 6/7] staging:iio:ad2s90: Add comment to device state mutex
  2018-11-24  0:23 [PATCH v3 0/7] staging:iio:ad2s90: Add dt support and move out of staging Matheus Tavares
                   ` (4 preceding siblings ...)
  2018-11-24  0:23 ` [PATCH v3 5/7] staging:iio:ad2s90: Replace license text w/ SPDX identifier Matheus Tavares
@ 2018-11-24  0:23 ` Matheus Tavares
  2018-12-01 15:39   ` Jonathan Cameron
  2018-11-24  0:23 ` [PATCH v3 7/7] staging:iio:ad2s90: Move out of staging Matheus Tavares
  6 siblings, 1 reply; 18+ messages in thread
From: Matheus Tavares @ 2018-11-24  0:23 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	Rob Herring, Mark Rutland
  Cc: linux-iio, devel, devicetree, linux-kernel, Alexandru Ardelean,
	kernel-usp, victorcolombo

From: Victor Colombo <victorcolombo@gmail.com>

Fix the checkpatch.pl issue:
"CHECK: struct mutex definition without comment".

Signed-off-by: Victor Colombo <victorcolombo@gmail.com>
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
---
Changes in v3:
 - none

Changes in v2:
 - Patch added in v2

 drivers/staging/iio/resolver/ad2s90.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c
index 678351dabe6b..a41f5cb10da5 100644
--- a/drivers/staging/iio/resolver/ad2s90.c
+++ b/drivers/staging/iio/resolver/ad2s90.c
@@ -22,7 +22,7 @@
 #define AD2S90_MAX_SPI_FREQ_HZ  830000
 
 struct ad2s90_state {
-	struct mutex lock;
+	struct mutex lock; /* lock to protect rx buffer */
 	struct spi_device *sdev;
 	u8 rx[2] ____cacheline_aligned;
 };
-- 
2.18.0


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

* [PATCH v3 7/7] staging:iio:ad2s90: Move out of staging
  2018-11-24  0:23 [PATCH v3 0/7] staging:iio:ad2s90: Add dt support and move out of staging Matheus Tavares
                   ` (5 preceding siblings ...)
  2018-11-24  0:23 ` [PATCH v3 6/7] staging:iio:ad2s90: Add comment to device state mutex Matheus Tavares
@ 2018-11-24  0:23 ` Matheus Tavares
  2018-11-25  9:56   ` Jonathan Cameron
  2018-11-26  7:34   ` Ardelean, Alexandru
  6 siblings, 2 replies; 18+ messages in thread
From: Matheus Tavares @ 2018-11-24  0:23 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	Rob Herring, Mark Rutland
  Cc: linux-iio, devel, devicetree, linux-kernel, Alexandru Ardelean,
	kernel-usp, victorcolombo

Move ad2s90 resolver driver out of staging to the main tree.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Victor Colombo <victorcolombo@gmail.com>
---
Changes in v3:
 - none

Changes in v2:
 - Disabled git move detection, to see the whole code, as Jonathan
 suggested

 drivers/iio/resolver/Kconfig          |  10 ++
 drivers/iio/resolver/Makefile         |   1 +
 drivers/iio/resolver/ad2s90.c         | 131 ++++++++++++++++++++++++++
 drivers/staging/iio/resolver/Kconfig  |  10 --
 drivers/staging/iio/resolver/Makefile |   1 -
 drivers/staging/iio/resolver/ad2s90.c | 131 --------------------------
 6 files changed, 142 insertions(+), 142 deletions(-)
 create mode 100644 drivers/iio/resolver/ad2s90.c
 delete mode 100644 drivers/staging/iio/resolver/ad2s90.c

diff --git a/drivers/iio/resolver/Kconfig b/drivers/iio/resolver/Kconfig
index 2ced9f22aa70..786801be54f6 100644
--- a/drivers/iio/resolver/Kconfig
+++ b/drivers/iio/resolver/Kconfig
@@ -3,6 +3,16 @@
 #
 menu "Resolver to digital converters"
 
+config AD2S90
+	tristate "Analog Devices ad2s90 driver"
+	depends on SPI
+	help
+	  Say yes here to build support for Analog Devices spi resolver
+	  to digital converters, ad2s90, provides direct access via sysfs.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called ad2s90.
+
 config AD2S1200
 	tristate "Analog Devices ad2s1200/ad2s1205 driver"
 	depends on SPI
diff --git a/drivers/iio/resolver/Makefile b/drivers/iio/resolver/Makefile
index 4e1dccae07e7..398d82d50028 100644
--- a/drivers/iio/resolver/Makefile
+++ b/drivers/iio/resolver/Makefile
@@ -2,4 +2,5 @@
 # Makefile for Resolver/Synchro drivers
 #
 
+obj-$(CONFIG_AD2S90) += ad2s90.o
 obj-$(CONFIG_AD2S1200) += ad2s1200.o
diff --git a/drivers/iio/resolver/ad2s90.c b/drivers/iio/resolver/ad2s90.c
new file mode 100644
index 000000000000..a41f5cb10da5
--- /dev/null
+++ b/drivers/iio/resolver/ad2s90.c
@@ -0,0 +1,131 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ad2s90.c simple support for the ADI Resolver to Digital Converters: AD2S90
+ *
+ * Copyright (c) 2010-2010 Analog Devices Inc.
+ */
+#include <linux/types.h>
+#include <linux/mutex.h>
+#include <linux/device.h>
+#include <linux/spi/spi.h>
+#include <linux/slab.h>
+#include <linux/sysfs.h>
+#include <linux/module.h>
+
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+
+/*
+ * Although chip's max frequency is 2Mhz, it needs 600ns between CS and the
+ * first falling edge of SCLK, so frequency should be at most 1 / (2 * 6e-7)
+ */
+#define AD2S90_MAX_SPI_FREQ_HZ  830000
+
+struct ad2s90_state {
+	struct mutex lock; /* lock to protect rx buffer */
+	struct spi_device *sdev;
+	u8 rx[2] ____cacheline_aligned;
+};
+
+static int ad2s90_read_raw(struct iio_dev *indio_dev,
+			   struct iio_chan_spec const *chan,
+			   int *val,
+			   int *val2,
+			   long m)
+{
+	int ret;
+	struct ad2s90_state *st = iio_priv(indio_dev);
+
+	if (chan->type != IIO_ANGL)
+		return -EINVAL;
+
+	switch (m) {
+	case IIO_CHAN_INFO_SCALE:
+		/* 2 * Pi / 2^12 */
+		*val = 6283; /* mV */
+		*val2 = 12;
+		return IIO_VAL_FRACTIONAL_LOG2;
+	case IIO_CHAN_INFO_RAW:
+		mutex_lock(&st->lock);
+		ret = spi_read(st->sdev, st->rx, 2);
+		if (ret < 0) {
+			mutex_unlock(&st->lock);
+			return ret;
+		}
+		*val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4);
+
+		mutex_unlock(&st->lock);
+
+		return IIO_VAL_INT;
+	default:
+		break;
+	}
+
+	return -EINVAL;
+}
+
+static const struct iio_info ad2s90_info = {
+	.read_raw = ad2s90_read_raw,
+};
+
+static const struct iio_chan_spec ad2s90_chan = {
+	.type = IIO_ANGL,
+	.indexed = 1,
+	.channel = 0,
+	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
+};
+
+static int ad2s90_probe(struct spi_device *spi)
+{
+	struct iio_dev *indio_dev;
+	struct ad2s90_state *st;
+
+	if (spi->max_speed_hz > AD2S90_MAX_SPI_FREQ_HZ) {
+		dev_err(&spi->dev, "SPI CLK, %d Hz exceeds %d Hz\n",
+			spi->max_speed_hz, AD2S90_MAX_SPI_FREQ_HZ);
+		return -EINVAL;
+	}
+
+	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+	if (!indio_dev)
+		return -ENOMEM;
+	st = iio_priv(indio_dev);
+	spi_set_drvdata(spi, indio_dev);
+
+	mutex_init(&st->lock);
+	st->sdev = spi;
+	indio_dev->dev.parent = &spi->dev;
+	indio_dev->info = &ad2s90_info;
+	indio_dev->modes = INDIO_DIRECT_MODE;
+	indio_dev->channels = &ad2s90_chan;
+	indio_dev->num_channels = 1;
+	indio_dev->name = spi_get_device_id(spi)->name;
+
+	return devm_iio_device_register(indio_dev->dev.parent, indio_dev);
+}
+
+static const struct of_device_id ad2s90_of_match[] = {
+	{ .compatible = "adi,ad2s90", },
+	{}
+};
+MODULE_DEVICE_TABLE(of, ad2s90_of_match);
+
+static const struct spi_device_id ad2s90_id[] = {
+	{ "ad2s90" },
+	{}
+};
+MODULE_DEVICE_TABLE(spi, ad2s90_id);
+
+static struct spi_driver ad2s90_driver = {
+	.driver = {
+		.name = "ad2s90",
+		.of_match_table = ad2s90_of_match,
+	},
+	.probe = ad2s90_probe,
+	.id_table = ad2s90_id,
+};
+module_spi_driver(ad2s90_driver);
+
+MODULE_AUTHOR("Graff Yang <graff.yang@gmail.com>");
+MODULE_DESCRIPTION("Analog Devices AD2S90 Resolver to Digital SPI driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/iio/resolver/Kconfig b/drivers/staging/iio/resolver/Kconfig
index 6a469ee6101f..4a727c17bb8f 100644
--- a/drivers/staging/iio/resolver/Kconfig
+++ b/drivers/staging/iio/resolver/Kconfig
@@ -3,16 +3,6 @@
 #
 menu "Resolver to digital converters"
 
-config AD2S90
-	tristate "Analog Devices ad2s90 driver"
-	depends on SPI
-	help
-	  Say yes here to build support for Analog Devices spi resolver
-	  to digital converters, ad2s90, provides direct access via sysfs.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called ad2s90.
-
 config AD2S1210
 	tristate "Analog Devices ad2s1210 driver"
 	depends on SPI
diff --git a/drivers/staging/iio/resolver/Makefile b/drivers/staging/iio/resolver/Makefile
index 8d901dc7500b..b2049f2ce36e 100644
--- a/drivers/staging/iio/resolver/Makefile
+++ b/drivers/staging/iio/resolver/Makefile
@@ -2,5 +2,4 @@
 # Makefile for Resolver/Synchro drivers
 #
 
-obj-$(CONFIG_AD2S90) += ad2s90.o
 obj-$(CONFIG_AD2S1210) += ad2s1210.o
diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c
deleted file mode 100644
index a41f5cb10da5..000000000000
--- a/drivers/staging/iio/resolver/ad2s90.c
+++ /dev/null
@@ -1,131 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * ad2s90.c simple support for the ADI Resolver to Digital Converters: AD2S90
- *
- * Copyright (c) 2010-2010 Analog Devices Inc.
- */
-#include <linux/types.h>
-#include <linux/mutex.h>
-#include <linux/device.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/module.h>
-
-#include <linux/iio/iio.h>
-#include <linux/iio/sysfs.h>
-
-/*
- * Although chip's max frequency is 2Mhz, it needs 600ns between CS and the
- * first falling edge of SCLK, so frequency should be at most 1 / (2 * 6e-7)
- */
-#define AD2S90_MAX_SPI_FREQ_HZ  830000
-
-struct ad2s90_state {
-	struct mutex lock; /* lock to protect rx buffer */
-	struct spi_device *sdev;
-	u8 rx[2] ____cacheline_aligned;
-};
-
-static int ad2s90_read_raw(struct iio_dev *indio_dev,
-			   struct iio_chan_spec const *chan,
-			   int *val,
-			   int *val2,
-			   long m)
-{
-	int ret;
-	struct ad2s90_state *st = iio_priv(indio_dev);
-
-	if (chan->type != IIO_ANGL)
-		return -EINVAL;
-
-	switch (m) {
-	case IIO_CHAN_INFO_SCALE:
-		/* 2 * Pi / 2^12 */
-		*val = 6283; /* mV */
-		*val2 = 12;
-		return IIO_VAL_FRACTIONAL_LOG2;
-	case IIO_CHAN_INFO_RAW:
-		mutex_lock(&st->lock);
-		ret = spi_read(st->sdev, st->rx, 2);
-		if (ret < 0) {
-			mutex_unlock(&st->lock);
-			return ret;
-		}
-		*val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4);
-
-		mutex_unlock(&st->lock);
-
-		return IIO_VAL_INT;
-	default:
-		break;
-	}
-
-	return -EINVAL;
-}
-
-static const struct iio_info ad2s90_info = {
-	.read_raw = ad2s90_read_raw,
-};
-
-static const struct iio_chan_spec ad2s90_chan = {
-	.type = IIO_ANGL,
-	.indexed = 1,
-	.channel = 0,
-	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
-};
-
-static int ad2s90_probe(struct spi_device *spi)
-{
-	struct iio_dev *indio_dev;
-	struct ad2s90_state *st;
-
-	if (spi->max_speed_hz > AD2S90_MAX_SPI_FREQ_HZ) {
-		dev_err(&spi->dev, "SPI CLK, %d Hz exceeds %d Hz\n",
-			spi->max_speed_hz, AD2S90_MAX_SPI_FREQ_HZ);
-		return -EINVAL;
-	}
-
-	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
-	if (!indio_dev)
-		return -ENOMEM;
-	st = iio_priv(indio_dev);
-	spi_set_drvdata(spi, indio_dev);
-
-	mutex_init(&st->lock);
-	st->sdev = spi;
-	indio_dev->dev.parent = &spi->dev;
-	indio_dev->info = &ad2s90_info;
-	indio_dev->modes = INDIO_DIRECT_MODE;
-	indio_dev->channels = &ad2s90_chan;
-	indio_dev->num_channels = 1;
-	indio_dev->name = spi_get_device_id(spi)->name;
-
-	return devm_iio_device_register(indio_dev->dev.parent, indio_dev);
-}
-
-static const struct of_device_id ad2s90_of_match[] = {
-	{ .compatible = "adi,ad2s90", },
-	{}
-};
-MODULE_DEVICE_TABLE(of, ad2s90_of_match);
-
-static const struct spi_device_id ad2s90_id[] = {
-	{ "ad2s90" },
-	{}
-};
-MODULE_DEVICE_TABLE(spi, ad2s90_id);
-
-static struct spi_driver ad2s90_driver = {
-	.driver = {
-		.name = "ad2s90",
-		.of_match_table = ad2s90_of_match,
-	},
-	.probe = ad2s90_probe,
-	.id_table = ad2s90_id,
-};
-module_spi_driver(ad2s90_driver);
-
-MODULE_AUTHOR("Graff Yang <graff.yang@gmail.com>");
-MODULE_DESCRIPTION("Analog Devices AD2S90 Resolver to Digital SPI driver");
-MODULE_LICENSE("GPL v2");
-- 
2.18.0


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

* Re: [PATCH v3 7/7] staging:iio:ad2s90: Move out of staging
  2018-11-24  0:23 ` [PATCH v3 7/7] staging:iio:ad2s90: Move out of staging Matheus Tavares
@ 2018-11-25  9:56   ` Jonathan Cameron
  2018-11-26  7:34   ` Ardelean, Alexandru
  1 sibling, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2018-11-25  9:56 UTC (permalink / raw)
  To: Matheus Tavares
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, Rob Herring,
	Mark Rutland, linux-iio, devel, devicetree, linux-kernel,
	Alexandru Ardelean, kernel-usp, victorcolombo

On Fri, 23 Nov 2018 22:23:12 -0200
Matheus Tavares <matheus.bernardino@usp.br> wrote:

> Move ad2s90 resolver driver out of staging to the main tree.
> 
> Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
> Signed-off-by: Victor Colombo <victorcolombo@gmail.com>
Hi.

One totally trivial comment inline, but if you want to clean
that up, do it after we have moved this out of staging
(unless respinning for some other reason).

However, I would like to let this sit on the mailing list for
a little longer to let others comment and perhaps to pick up
a review of the DT binding doc (which looks fine to me, but
I am forever missing issues in those!)

Good work and I'll probably pick this up later in the week.

Thanks,

Jonathan
> ---
> Changes in v3:
>  - none
> 
> Changes in v2:
>  - Disabled git move detection, to see the whole code, as Jonathan
>  suggested
> 
>  drivers/iio/resolver/Kconfig          |  10 ++
>  drivers/iio/resolver/Makefile         |   1 +
>  drivers/iio/resolver/ad2s90.c         | 131 ++++++++++++++++++++++++++
>  drivers/staging/iio/resolver/Kconfig  |  10 --
>  drivers/staging/iio/resolver/Makefile |   1 -
>  drivers/staging/iio/resolver/ad2s90.c | 131 --------------------------
>  6 files changed, 142 insertions(+), 142 deletions(-)
>  create mode 100644 drivers/iio/resolver/ad2s90.c
>  delete mode 100644 drivers/staging/iio/resolver/ad2s90.c
> 
> diff --git a/drivers/iio/resolver/Kconfig b/drivers/iio/resolver/Kconfig
> index 2ced9f22aa70..786801be54f6 100644
> --- a/drivers/iio/resolver/Kconfig
> +++ b/drivers/iio/resolver/Kconfig
> @@ -3,6 +3,16 @@
>  #
>  menu "Resolver to digital converters"
>  
> +config AD2S90
> +	tristate "Analog Devices ad2s90 driver"
> +	depends on SPI
> +	help
> +	  Say yes here to build support for Analog Devices spi resolver
> +	  to digital converters, ad2s90, provides direct access via sysfs.
> +
> +	  To compile this driver as a module, choose M here: the
> +	  module will be called ad2s90.
> +
>  config AD2S1200
>  	tristate "Analog Devices ad2s1200/ad2s1205 driver"
>  	depends on SPI
> diff --git a/drivers/iio/resolver/Makefile b/drivers/iio/resolver/Makefile
> index 4e1dccae07e7..398d82d50028 100644
> --- a/drivers/iio/resolver/Makefile
> +++ b/drivers/iio/resolver/Makefile
> @@ -2,4 +2,5 @@
>  # Makefile for Resolver/Synchro drivers
>  #
>  
> +obj-$(CONFIG_AD2S90) += ad2s90.o
>  obj-$(CONFIG_AD2S1200) += ad2s1200.o
> diff --git a/drivers/iio/resolver/ad2s90.c b/drivers/iio/resolver/ad2s90.c
> new file mode 100644
> index 000000000000..a41f5cb10da5
> --- /dev/null
> +++ b/drivers/iio/resolver/ad2s90.c
> @@ -0,0 +1,131 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * ad2s90.c simple support for the ADI Resolver to Digital Converters: AD2S90
> + *
> + * Copyright (c) 2010-2010 Analog Devices Inc.
> + */
> +#include <linux/types.h>
> +#include <linux/mutex.h>
> +#include <linux/device.h>
> +#include <linux/spi/spi.h>
> +#include <linux/slab.h>
> +#include <linux/sysfs.h>
> +#include <linux/module.h>

We are into the truely trivial realms now - alphabetical order preferred
for includes.

> +
> +#include <linux/iio/iio.h>
> +#include <linux/iio/sysfs.h>
> +
> +/*
> + * Although chip's max frequency is 2Mhz, it needs 600ns between CS and the
> + * first falling edge of SCLK, so frequency should be at most 1 / (2 * 6e-7)
> + */
> +#define AD2S90_MAX_SPI_FREQ_HZ  830000
> +
> +struct ad2s90_state {
> +	struct mutex lock; /* lock to protect rx buffer */
> +	struct spi_device *sdev;
> +	u8 rx[2] ____cacheline_aligned;
> +};
> +
> +static int ad2s90_read_raw(struct iio_dev *indio_dev,
> +			   struct iio_chan_spec const *chan,
> +			   int *val,
> +			   int *val2,
> +			   long m)
> +{
> +	int ret;
> +	struct ad2s90_state *st = iio_priv(indio_dev);
> +
> +	if (chan->type != IIO_ANGL)
> +		return -EINVAL;
> +
> +	switch (m) {
> +	case IIO_CHAN_INFO_SCALE:
> +		/* 2 * Pi / 2^12 */
> +		*val = 6283; /* mV */
> +		*val2 = 12;
> +		return IIO_VAL_FRACTIONAL_LOG2;
> +	case IIO_CHAN_INFO_RAW:
> +		mutex_lock(&st->lock);
> +		ret = spi_read(st->sdev, st->rx, 2);
> +		if (ret < 0) {
> +			mutex_unlock(&st->lock);
> +			return ret;
> +		}
> +		*val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4);
> +
> +		mutex_unlock(&st->lock);
> +
> +		return IIO_VAL_INT;
> +	default:
> +		break;
> +	}
> +
> +	return -EINVAL;
> +}
> +
> +static const struct iio_info ad2s90_info = {
> +	.read_raw = ad2s90_read_raw,
> +};
> +
> +static const struct iio_chan_spec ad2s90_chan = {
> +	.type = IIO_ANGL,
> +	.indexed = 1,
> +	.channel = 0,
> +	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> +};
> +
> +static int ad2s90_probe(struct spi_device *spi)
> +{
> +	struct iio_dev *indio_dev;
> +	struct ad2s90_state *st;
> +
> +	if (spi->max_speed_hz > AD2S90_MAX_SPI_FREQ_HZ) {
> +		dev_err(&spi->dev, "SPI CLK, %d Hz exceeds %d Hz\n",
> +			spi->max_speed_hz, AD2S90_MAX_SPI_FREQ_HZ);
> +		return -EINVAL;
> +	}
> +
> +	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> +	if (!indio_dev)
> +		return -ENOMEM;
> +	st = iio_priv(indio_dev);
> +	spi_set_drvdata(spi, indio_dev);
> +
> +	mutex_init(&st->lock);
> +	st->sdev = spi;
> +	indio_dev->dev.parent = &spi->dev;
> +	indio_dev->info = &ad2s90_info;
> +	indio_dev->modes = INDIO_DIRECT_MODE;
> +	indio_dev->channels = &ad2s90_chan;
> +	indio_dev->num_channels = 1;
> +	indio_dev->name = spi_get_device_id(spi)->name;
> +
> +	return devm_iio_device_register(indio_dev->dev.parent, indio_dev);
> +}
> +
> +static const struct of_device_id ad2s90_of_match[] = {
> +	{ .compatible = "adi,ad2s90", },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, ad2s90_of_match);
> +
> +static const struct spi_device_id ad2s90_id[] = {
> +	{ "ad2s90" },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(spi, ad2s90_id);
> +
> +static struct spi_driver ad2s90_driver = {
> +	.driver = {
> +		.name = "ad2s90",
> +		.of_match_table = ad2s90_of_match,
> +	},
> +	.probe = ad2s90_probe,
> +	.id_table = ad2s90_id,
> +};
> +module_spi_driver(ad2s90_driver);
> +
> +MODULE_AUTHOR("Graff Yang <graff.yang@gmail.com>");
> +MODULE_DESCRIPTION("Analog Devices AD2S90 Resolver to Digital SPI driver");
> +MODULE_LICENSE("GPL v2");
...


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

* Re: [PATCH v3 7/7] staging:iio:ad2s90: Move out of staging
  2018-11-24  0:23 ` [PATCH v3 7/7] staging:iio:ad2s90: Move out of staging Matheus Tavares
  2018-11-25  9:56   ` Jonathan Cameron
@ 2018-11-26  7:34   ` Ardelean, Alexandru
  2018-12-01 15:41     ` Jonathan Cameron
  1 sibling, 1 reply; 18+ messages in thread
From: Ardelean, Alexandru @ 2018-11-26  7:34 UTC (permalink / raw)
  To: lars, robh+dt, knaack.h, jic23, Hennerich, Michael, mark.rutland,
	matheus.bernardino, pmeerw, gregkh
  Cc: victorcolombo, linux-kernel, linux-iio, devel, kernel-usp, devicetree

On Fri, 2018-11-23 at 22:23 -0200, Matheus Tavares wrote:
> Move ad2s90 resolver driver out of staging to the main tree.
> 

Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>

> Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
> Signed-off-by: Victor Colombo <victorcolombo@gmail.com>
> ---
> Changes in v3:
>  - none
> 
> Changes in v2:
>  - Disabled git move detection, to see the whole code, as Jonathan
>  suggested
> 
>  drivers/iio/resolver/Kconfig          |  10 ++
>  drivers/iio/resolver/Makefile         |   1 +
>  drivers/iio/resolver/ad2s90.c         | 131 ++++++++++++++++++++++++++
>  drivers/staging/iio/resolver/Kconfig  |  10 --
>  drivers/staging/iio/resolver/Makefile |   1 -
>  drivers/staging/iio/resolver/ad2s90.c | 131 --------------------------
>  6 files changed, 142 insertions(+), 142 deletions(-)
>  create mode 100644 drivers/iio/resolver/ad2s90.c
>  delete mode 100644 drivers/staging/iio/resolver/ad2s90.c
> 
> diff --git a/drivers/iio/resolver/Kconfig b/drivers/iio/resolver/Kconfig
> index 2ced9f22aa70..786801be54f6 100644
> --- a/drivers/iio/resolver/Kconfig
> +++ b/drivers/iio/resolver/Kconfig
> @@ -3,6 +3,16 @@
>  #
>  menu "Resolver to digital converters"
>  
> +config AD2S90
> +	tristate "Analog Devices ad2s90 driver"
> +	depends on SPI
> +	help
> +	  Say yes here to build support for Analog Devices spi resolver
> +	  to digital converters, ad2s90, provides direct access via sysfs.
> +
> +	  To compile this driver as a module, choose M here: the
> +	  module will be called ad2s90.
> +
>  config AD2S1200
>  	tristate "Analog Devices ad2s1200/ad2s1205 driver"
>  	depends on SPI
> diff --git a/drivers/iio/resolver/Makefile
> b/drivers/iio/resolver/Makefile
> index 4e1dccae07e7..398d82d50028 100644
> --- a/drivers/iio/resolver/Makefile
> +++ b/drivers/iio/resolver/Makefile
> @@ -2,4 +2,5 @@
>  # Makefile for Resolver/Synchro drivers
>  #
>  
> +obj-$(CONFIG_AD2S90) += ad2s90.o
>  obj-$(CONFIG_AD2S1200) += ad2s1200.o
> diff --git a/drivers/iio/resolver/ad2s90.c
> b/drivers/iio/resolver/ad2s90.c
> new file mode 100644
> index 000000000000..a41f5cb10da5
> --- /dev/null
> +++ b/drivers/iio/resolver/ad2s90.c
> @@ -0,0 +1,131 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * ad2s90.c simple support for the ADI Resolver to Digital Converters:
> AD2S90
> + *
> + * Copyright (c) 2010-2010 Analog Devices Inc.
> + */
> +#include <linux/types.h>
> +#include <linux/mutex.h>
> +#include <linux/device.h>
> +#include <linux/spi/spi.h>
> +#include <linux/slab.h>
> +#include <linux/sysfs.h>
> +#include <linux/module.h>
> +
> +#include <linux/iio/iio.h>
> +#include <linux/iio/sysfs.h>
> +
> +/*
> + * Although chip's max frequency is 2Mhz, it needs 600ns between CS and
> the
> + * first falling edge of SCLK, so frequency should be at most 1 / (2 *
> 6e-7)
> + */
> +#define AD2S90_MAX_SPI_FREQ_HZ  830000
> +
> +struct ad2s90_state {
> +	struct mutex lock; /* lock to protect rx buffer */
> +	struct spi_device *sdev;
> +	u8 rx[2] ____cacheline_aligned;
> +};
> +
> +static int ad2s90_read_raw(struct iio_dev *indio_dev,
> +			   struct iio_chan_spec const *chan,
> +			   int *val,
> +			   int *val2,
> +			   long m)
> +{
> +	int ret;
> +	struct ad2s90_state *st = iio_priv(indio_dev);
> +
> +	if (chan->type != IIO_ANGL)
> +		return -EINVAL;
> +
> +	switch (m) {
> +	case IIO_CHAN_INFO_SCALE:
> +		/* 2 * Pi / 2^12 */
> +		*val = 6283; /* mV */
> +		*val2 = 12;
> +		return IIO_VAL_FRACTIONAL_LOG2;
> +	case IIO_CHAN_INFO_RAW:
> +		mutex_lock(&st->lock);
> +		ret = spi_read(st->sdev, st->rx, 2);
> +		if (ret < 0) {
> +			mutex_unlock(&st->lock);
> +			return ret;
> +		}
> +		*val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >>
> 4);
> +
> +		mutex_unlock(&st->lock);
> +
> +		return IIO_VAL_INT;
> +	default:
> +		break;
> +	}
> +
> +	return -EINVAL;
> +}
> +
> +static const struct iio_info ad2s90_info = {
> +	.read_raw = ad2s90_read_raw,
> +};
> +
> +static const struct iio_chan_spec ad2s90_chan = {
> +	.type = IIO_ANGL,
> +	.indexed = 1,
> +	.channel = 0,
> +	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> BIT(IIO_CHAN_INFO_SCALE),
> +};
> +
> +static int ad2s90_probe(struct spi_device *spi)
> +{
> +	struct iio_dev *indio_dev;
> +	struct ad2s90_state *st;
> +
> +	if (spi->max_speed_hz > AD2S90_MAX_SPI_FREQ_HZ) {
> +		dev_err(&spi->dev, "SPI CLK, %d Hz exceeds %d Hz\n",
> +			spi->max_speed_hz, AD2S90_MAX_SPI_FREQ_HZ);
> +		return -EINVAL;
> +	}
> +
> +	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> +	if (!indio_dev)
> +		return -ENOMEM;
> +	st = iio_priv(indio_dev);
> +	spi_set_drvdata(spi, indio_dev);
> +
> +	mutex_init(&st->lock);
> +	st->sdev = spi;
> +	indio_dev->dev.parent = &spi->dev;
> +	indio_dev->info = &ad2s90_info;
> +	indio_dev->modes = INDIO_DIRECT_MODE;
> +	indio_dev->channels = &ad2s90_chan;
> +	indio_dev->num_channels = 1;
> +	indio_dev->name = spi_get_device_id(spi)->name;
> +
> +	return devm_iio_device_register(indio_dev->dev.parent, indio_dev);
> +}
> +
> +static const struct of_device_id ad2s90_of_match[] = {
> +	{ .compatible = "adi,ad2s90", },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, ad2s90_of_match);
> +
> +static const struct spi_device_id ad2s90_id[] = {
> +	{ "ad2s90" },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(spi, ad2s90_id);
> +
> +static struct spi_driver ad2s90_driver = {
> +	.driver = {
> +		.name = "ad2s90",
> +		.of_match_table = ad2s90_of_match,
> +	},
> +	.probe = ad2s90_probe,
> +	.id_table = ad2s90_id,
> +};
> +module_spi_driver(ad2s90_driver);
> +
> +MODULE_AUTHOR("Graff Yang <graff.yang@gmail.com>");
> +MODULE_DESCRIPTION("Analog Devices AD2S90 Resolver to Digital SPI
> driver");
> +MODULE_LICENSE("GPL v2");
> diff --git a/drivers/staging/iio/resolver/Kconfig
> b/drivers/staging/iio/resolver/Kconfig
> index 6a469ee6101f..4a727c17bb8f 100644
> --- a/drivers/staging/iio/resolver/Kconfig
> +++ b/drivers/staging/iio/resolver/Kconfig
> @@ -3,16 +3,6 @@
>  #
>  menu "Resolver to digital converters"
>  
> -config AD2S90
> -	tristate "Analog Devices ad2s90 driver"
> -	depends on SPI
> -	help
> -	  Say yes here to build support for Analog Devices spi resolver
> -	  to digital converters, ad2s90, provides direct access via sysfs.
> -
> -	  To compile this driver as a module, choose M here: the
> -	  module will be called ad2s90.
> -
>  config AD2S1210
>  	tristate "Analog Devices ad2s1210 driver"
>  	depends on SPI
> diff --git a/drivers/staging/iio/resolver/Makefile
> b/drivers/staging/iio/resolver/Makefile
> index 8d901dc7500b..b2049f2ce36e 100644
> --- a/drivers/staging/iio/resolver/Makefile
> +++ b/drivers/staging/iio/resolver/Makefile
> @@ -2,5 +2,4 @@
>  # Makefile for Resolver/Synchro drivers
>  #
>  
> -obj-$(CONFIG_AD2S90) += ad2s90.o
>  obj-$(CONFIG_AD2S1210) += ad2s1210.o
> diff --git a/drivers/staging/iio/resolver/ad2s90.c
> b/drivers/staging/iio/resolver/ad2s90.c
> deleted file mode 100644
> index a41f5cb10da5..000000000000
> --- a/drivers/staging/iio/resolver/ad2s90.c
> +++ /dev/null
> @@ -1,131 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -/*
> - * ad2s90.c simple support for the ADI Resolver to Digital Converters:
> AD2S90
> - *
> - * Copyright (c) 2010-2010 Analog Devices Inc.
> - */
> -#include <linux/types.h>
> -#include <linux/mutex.h>
> -#include <linux/device.h>
> -#include <linux/spi/spi.h>
> -#include <linux/slab.h>
> -#include <linux/sysfs.h>
> -#include <linux/module.h>
> -
> -#include <linux/iio/iio.h>
> -#include <linux/iio/sysfs.h>
> -
> -/*
> - * Although chip's max frequency is 2Mhz, it needs 600ns between CS and
> the
> - * first falling edge of SCLK, so frequency should be at most 1 / (2 *
> 6e-7)
> - */
> -#define AD2S90_MAX_SPI_FREQ_HZ  830000
> -
> -struct ad2s90_state {
> -	struct mutex lock; /* lock to protect rx buffer */
> -	struct spi_device *sdev;
> -	u8 rx[2] ____cacheline_aligned;
> -};
> -
> -static int ad2s90_read_raw(struct iio_dev *indio_dev,
> -			   struct iio_chan_spec const *chan,
> -			   int *val,
> -			   int *val2,
> -			   long m)
> -{
> -	int ret;
> -	struct ad2s90_state *st = iio_priv(indio_dev);
> -
> -	if (chan->type != IIO_ANGL)
> -		return -EINVAL;
> -
> -	switch (m) {
> -	case IIO_CHAN_INFO_SCALE:
> -		/* 2 * Pi / 2^12 */
> -		*val = 6283; /* mV */
> -		*val2 = 12;
> -		return IIO_VAL_FRACTIONAL_LOG2;
> -	case IIO_CHAN_INFO_RAW:
> -		mutex_lock(&st->lock);
> -		ret = spi_read(st->sdev, st->rx, 2);
> -		if (ret < 0) {
> -			mutex_unlock(&st->lock);
> -			return ret;
> -		}
> -		*val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >>
> 4);
> -
> -		mutex_unlock(&st->lock);
> -
> -		return IIO_VAL_INT;
> -	default:
> -		break;
> -	}
> -
> -	return -EINVAL;
> -}
> -
> -static const struct iio_info ad2s90_info = {
> -	.read_raw = ad2s90_read_raw,
> -};
> -
> -static const struct iio_chan_spec ad2s90_chan = {
> -	.type = IIO_ANGL,
> -	.indexed = 1,
> -	.channel = 0,
> -	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> BIT(IIO_CHAN_INFO_SCALE),
> -};
> -
> -static int ad2s90_probe(struct spi_device *spi)
> -{
> -	struct iio_dev *indio_dev;
> -	struct ad2s90_state *st;
> -
> -	if (spi->max_speed_hz > AD2S90_MAX_SPI_FREQ_HZ) {
> -		dev_err(&spi->dev, "SPI CLK, %d Hz exceeds %d Hz\n",
> -			spi->max_speed_hz, AD2S90_MAX_SPI_FREQ_HZ);
> -		return -EINVAL;
> -	}
> -
> -	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> -	if (!indio_dev)
> -		return -ENOMEM;
> -	st = iio_priv(indio_dev);
> -	spi_set_drvdata(spi, indio_dev);
> -
> -	mutex_init(&st->lock);
> -	st->sdev = spi;
> -	indio_dev->dev.parent = &spi->dev;
> -	indio_dev->info = &ad2s90_info;
> -	indio_dev->modes = INDIO_DIRECT_MODE;
> -	indio_dev->channels = &ad2s90_chan;
> -	indio_dev->num_channels = 1;
> -	indio_dev->name = spi_get_device_id(spi)->name;
> -
> -	return devm_iio_device_register(indio_dev->dev.parent, indio_dev);
> -}
> -
> -static const struct of_device_id ad2s90_of_match[] = {
> -	{ .compatible = "adi,ad2s90", },
> -	{}
> -};
> -MODULE_DEVICE_TABLE(of, ad2s90_of_match);
> -
> -static const struct spi_device_id ad2s90_id[] = {
> -	{ "ad2s90" },
> -	{}
> -};
> -MODULE_DEVICE_TABLE(spi, ad2s90_id);
> -
> -static struct spi_driver ad2s90_driver = {
> -	.driver = {
> -		.name = "ad2s90",
> -		.of_match_table = ad2s90_of_match,
> -	},
> -	.probe = ad2s90_probe,
> -	.id_table = ad2s90_id,
> -};
> -module_spi_driver(ad2s90_driver);
> -
> -MODULE_AUTHOR("Graff Yang <graff.yang@gmail.com>");
> -MODULE_DESCRIPTION("Analog Devices AD2S90 Resolver to Digital SPI
> driver");
> -MODULE_LICENSE("GPL v2");

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

* Re: [PATCH v3 4/7] dt-bindings:iio:resolver: Add docs for ad2s90
  2018-11-24  0:23 ` [PATCH v3 4/7] dt-bindings:iio:resolver: Add docs for ad2s90 Matheus Tavares
@ 2018-11-27  1:52   ` Rob Herring
  2018-12-01 15:37     ` Jonathan Cameron
  0 siblings, 1 reply; 18+ messages in thread
From: Rob Herring @ 2018-11-27  1:52 UTC (permalink / raw)
  To: Matheus Tavares
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	Mark Rutland, linux-iio, devel, devicetree, linux-kernel,
	Alexandru Ardelean, kernel-usp, victorcolombo

On Fri, 23 Nov 2018 22:23:09 -0200, Matheus Tavares wrote:
> This patch adds the device tree binding documentation for the ad2s90
> resolver-to-digital converter.
> 
> Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
> ---
> Changes in v3:
>  - Added reference to spi-bus documentation after spi properties, as
>  suggested by Alexandru Ardelean.
> 
> Changes in v2:
>  - Rewritten 'spi-cpol and spi-cpha' item to say that the device can
>  work in either mode (0,0) or (1,1) and explain how they should be
>  specified in DT.
> 
>  .../bindings/iio/resolver/ad2s90.txt          | 31 +++++++++++++++++++
>  1 file changed, 31 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/resolver/ad2s90.txt
> 

Reviewed-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v3 1/7] staging:iio:ad2s90: Add device tree support
  2018-11-24  0:23 ` [PATCH v3 1/7] staging:iio:ad2s90: Add device tree support Matheus Tavares
@ 2018-12-01 15:34   ` Jonathan Cameron
  0 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2018-12-01 15:34 UTC (permalink / raw)
  To: Matheus Tavares
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, Rob Herring,
	Mark Rutland, linux-iio, devel, devicetree, linux-kernel,
	Alexandru Ardelean, kernel-usp, victorcolombo

On Fri, 23 Nov 2018 22:23:06 -0200
Matheus Tavares <matheus.bernardino@usp.br> wrote:

> This patch adds device tree support to ad2s90 with standard
> device tree id table.
> 
> Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Joanthan

> ---
> Changes in v3:
>  - Removed of_patch_ptr from of_match_table assignment
> 
> Changes in v2:
>  - none
> 
>  drivers/staging/iio/resolver/ad2s90.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c
> index 3e257ac46f7a..fdae067ed866 100644
> --- a/drivers/staging/iio/resolver/ad2s90.c
> +++ b/drivers/staging/iio/resolver/ad2s90.c
> @@ -107,6 +107,12 @@ static int ad2s90_probe(struct spi_device *spi)
>  	return devm_iio_device_register(indio_dev->dev.parent, indio_dev);
>  }
>  
> +static const struct of_device_id ad2s90_of_match[] = {
> +	{ .compatible = "adi,ad2s90", },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, ad2s90_of_match);
> +
>  static const struct spi_device_id ad2s90_id[] = {
>  	{ "ad2s90" },
>  	{}
> @@ -116,6 +122,7 @@ MODULE_DEVICE_TABLE(spi, ad2s90_id);
>  static struct spi_driver ad2s90_driver = {
>  	.driver = {
>  		.name = "ad2s90",
> +		.of_match_table = ad2s90_of_match,
>  	},
>  	.probe = ad2s90_probe,
>  	.id_table = ad2s90_id,


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

* Re: [PATCH v3 2/7] staging:iio:ad2s90: Remove spi setup that should be done via dt
  2018-11-24  0:23 ` [PATCH v3 2/7] staging:iio:ad2s90: Remove spi setup that should be done via dt Matheus Tavares
@ 2018-12-01 15:34   ` Jonathan Cameron
  0 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2018-12-01 15:34 UTC (permalink / raw)
  To: Matheus Tavares
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, Rob Herring,
	Mark Rutland, linux-iio, devel, devicetree, linux-kernel,
	Alexandru Ardelean, kernel-usp, victorcolombo

On Fri, 23 Nov 2018 22:23:07 -0200
Matheus Tavares <matheus.bernardino@usp.br> wrote:

> The ad2s90 driver currently sets some spi settings (max_speed_hz and
> mode) at ad2s90_probe. Since the maximum frequency is a required element
> in DT binding for spi slave devices and because the spi mode for the
> device can be either (0,0) or (1,1), these settings should be handled
> via device tree, not in the driver's code. This patch removes them from
> the probe function.
> 
> Note: The way in which the mentioned spi settings need to be specified
> on the ad2s90's node of a device tree will be documented in the future
> patch "dt-bindings:iio:resolver: Add docs for ad2s90".
> 
> Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>

Applied,

Thanks,

Jonathan

> ---
> Changes in v3:
>  - none
> 
> Changes in v2:
>  - Rewritten patch message to better explain why the code snippet in
>  question should be removed.
> 
>  drivers/staging/iio/resolver/ad2s90.c | 11 -----------
>  1 file changed, 11 deletions(-)
> 
> diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c
> index fdae067ed866..abb9b9147ee6 100644
> --- a/drivers/staging/iio/resolver/ad2s90.c
> +++ b/drivers/staging/iio/resolver/ad2s90.c
> @@ -77,7 +77,6 @@ static int ad2s90_probe(struct spi_device *spi)
>  {
>  	struct iio_dev *indio_dev;
>  	struct ad2s90_state *st;
> -	int ret;
>  
>  	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
>  	if (!indio_dev)
> @@ -94,16 +93,6 @@ static int ad2s90_probe(struct spi_device *spi)
>  	indio_dev->num_channels = 1;
>  	indio_dev->name = spi_get_device_id(spi)->name;
>  
> -	/* need 600ns between CS and the first falling edge of SCLK */
> -	spi->max_speed_hz = 830000;
> -	spi->mode = SPI_MODE_3;
> -	ret = spi_setup(spi);
> -
> -	if (ret < 0) {
> -		dev_err(&spi->dev, "spi_setup failed!\n");
> -		return ret;
> -	}
> -
>  	return devm_iio_device_register(indio_dev->dev.parent, indio_dev);
>  }
>  


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

* Re: [PATCH v3 4/7] dt-bindings:iio:resolver: Add docs for ad2s90
  2018-11-27  1:52   ` Rob Herring
@ 2018-12-01 15:37     ` Jonathan Cameron
  0 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2018-12-01 15:37 UTC (permalink / raw)
  To: Rob Herring
  Cc: Matheus Tavares, Lars-Peter Clausen, Michael Hennerich,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	Mark Rutland, linux-iio, devel, devicetree, linux-kernel,
	Alexandru Ardelean, kernel-usp, victorcolombo

On Mon, 26 Nov 2018 19:52:27 -0600
Rob Herring <robh@kernel.org> wrote:

> On Fri, 23 Nov 2018 22:23:09 -0200, Matheus Tavares wrote:
> > This patch adds the device tree binding documentation for the ad2s90
> > resolver-to-digital converter.
> > 
> > Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
> > ---
> > Changes in v3:
> >  - Added reference to spi-bus documentation after spi properties, as
> >  suggested by Alexandru Ardelean.
> > 
> > Changes in v2:
> >  - Rewritten 'spi-cpol and spi-cpha' item to say that the device can
> >  work in either mode (0,0) or (1,1) and explain how they should be
> >  specified in DT.
> > 
> >  .../bindings/iio/resolver/ad2s90.txt          | 31 +++++++++++++++++++
> >  1 file changed, 31 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/iio/resolver/ad2s90.txt
> >   
> 
> Reviewed-by: Rob Herring <robh@kernel.org>

Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders
to play with it.

Thanks,

Jonathan

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

* Re: [PATCH v3 3/7] staging:iio:ad2s90: Add max frequency check at probe
  2018-11-24  0:23 ` [PATCH v3 3/7] staging:iio:ad2s90: Add max frequency check at probe Matheus Tavares
@ 2018-12-01 15:37   ` Jonathan Cameron
  0 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2018-12-01 15:37 UTC (permalink / raw)
  To: Matheus Tavares
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, Rob Herring,
	Mark Rutland, linux-iio, devel, devicetree, linux-kernel,
	Alexandru Ardelean, kernel-usp, victorcolombo

On Fri, 23 Nov 2018 22:23:08 -0200
Matheus Tavares <matheus.bernardino@usp.br> wrote:

> From: Alexandru Ardelean <alexandru.ardelean@analog.com>
> 
> This patch adds a max frequency check at the beginning of ad2s90_probe
> function so that when it is set to a value above 0.83Mhz, dev_err is
> called with an appropriate message and -EINVAL is returned.
> 
> The defined limit is 0.83Mhz instead of 2Mhz, which is the chip's max
> frequency as specified in the datasheet, because, as also specified in
> the datasheet, a 600ns delay is expected between the application of a
> logic LO to CS and the application of SCLK. Since the delay is not
> implemented in the spi code, to satisfy it, SCLK's period should be at
> most 2 * 600ns, so the max frequency should be 1 / (2 * 6e-7), which
> gives roughly 830000Hz.
> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Applied,

Thanks,
> ---
> Changes in v3:
>  - none
> 
> Changes in v2:
>  - Correctly credit Alexandru as the patch's author
> 
>  drivers/staging/iio/resolver/ad2s90.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c
> index abb9b9147ee6..4721e9bbb8b0 100644
> --- a/drivers/staging/iio/resolver/ad2s90.c
> +++ b/drivers/staging/iio/resolver/ad2s90.c
> @@ -19,6 +19,12 @@
>  #include <linux/iio/iio.h>
>  #include <linux/iio/sysfs.h>
>  
> +/*
> + * Although chip's max frequency is 2Mhz, it needs 600ns between CS and the
> + * first falling edge of SCLK, so frequency should be at most 1 / (2 * 6e-7)
> + */
> +#define AD2S90_MAX_SPI_FREQ_HZ  830000
> +
>  struct ad2s90_state {
>  	struct mutex lock;
>  	struct spi_device *sdev;
> @@ -78,6 +84,12 @@ static int ad2s90_probe(struct spi_device *spi)
>  	struct iio_dev *indio_dev;
>  	struct ad2s90_state *st;
>  
> +	if (spi->max_speed_hz > AD2S90_MAX_SPI_FREQ_HZ) {
> +		dev_err(&spi->dev, "SPI CLK, %d Hz exceeds %d Hz\n",
> +			spi->max_speed_hz, AD2S90_MAX_SPI_FREQ_HZ);
> +		return -EINVAL;
> +	}
> +
>  	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
>  	if (!indio_dev)
>  		return -ENOMEM;


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

* Re: [PATCH v3 5/7] staging:iio:ad2s90: Replace license text w/ SPDX identifier
  2018-11-24  0:23 ` [PATCH v3 5/7] staging:iio:ad2s90: Replace license text w/ SPDX identifier Matheus Tavares
@ 2018-12-01 15:38   ` Jonathan Cameron
  0 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2018-12-01 15:38 UTC (permalink / raw)
  To: Matheus Tavares
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, Rob Herring,
	Mark Rutland, linux-iio, devel, devicetree, linux-kernel,
	Alexandru Ardelean, kernel-usp, victorcolombo

On Fri, 23 Nov 2018 22:23:10 -0200
Matheus Tavares <matheus.bernardino@usp.br> wrote:

> This patch removes the license boilerplate text at the top of ad2s90.c
> and, instead, adds the SPDX GPL-2.0 license identifier, which solves the
> checkpatch.pl warning:
> "WARNING: Missing or malformed SPDX-License-Identifier tag in line 1".
> 
> Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Applied,

Thanks,

Jonathan

> ---
> Changes in v3:
>  - none
> 
> Changes in v2:
>  - Changed GPL-2.0-only identifier to GPL-2.0
>  - Removed license boilerplate text
>  - Rewritten patch message to reflect these modifications
> 
>  drivers/staging/iio/resolver/ad2s90.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c
> index 4721e9bbb8b0..678351dabe6b 100644
> --- a/drivers/staging/iio/resolver/ad2s90.c
> +++ b/drivers/staging/iio/resolver/ad2s90.c
> @@ -1,12 +1,8 @@
> +// SPDX-License-Identifier: GPL-2.0
>  /*
>   * ad2s90.c simple support for the ADI Resolver to Digital Converters: AD2S90
>   *
>   * Copyright (c) 2010-2010 Analog Devices Inc.
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License version 2 as
> - * published by the Free Software Foundation.
> - *
>   */
>  #include <linux/types.h>
>  #include <linux/mutex.h>


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

* Re: [PATCH v3 6/7] staging:iio:ad2s90: Add comment to device state mutex
  2018-11-24  0:23 ` [PATCH v3 6/7] staging:iio:ad2s90: Add comment to device state mutex Matheus Tavares
@ 2018-12-01 15:39   ` Jonathan Cameron
  0 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2018-12-01 15:39 UTC (permalink / raw)
  To: Matheus Tavares
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, Rob Herring,
	Mark Rutland, linux-iio, devel, devicetree, linux-kernel,
	Alexandru Ardelean, kernel-usp, victorcolombo

On Fri, 23 Nov 2018 22:23:11 -0200
Matheus Tavares <matheus.bernardino@usp.br> wrote:

> From: Victor Colombo <victorcolombo@gmail.com>
> 
> Fix the checkpatch.pl issue:
> "CHECK: struct mutex definition without comment".
> 
> Signed-off-by: Victor Colombo <victorcolombo@gmail.com>
> Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Applied, thanks

Jonathan
> ---
> Changes in v3:
>  - none
> 
> Changes in v2:
>  - Patch added in v2
> 
>  drivers/staging/iio/resolver/ad2s90.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c
> index 678351dabe6b..a41f5cb10da5 100644
> --- a/drivers/staging/iio/resolver/ad2s90.c
> +++ b/drivers/staging/iio/resolver/ad2s90.c
> @@ -22,7 +22,7 @@
>  #define AD2S90_MAX_SPI_FREQ_HZ  830000
>  
>  struct ad2s90_state {
> -	struct mutex lock;
> +	struct mutex lock; /* lock to protect rx buffer */
>  	struct spi_device *sdev;
>  	u8 rx[2] ____cacheline_aligned;
>  };


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

* Re: [PATCH v3 7/7] staging:iio:ad2s90: Move out of staging
  2018-11-26  7:34   ` Ardelean, Alexandru
@ 2018-12-01 15:41     ` Jonathan Cameron
  0 siblings, 0 replies; 18+ messages in thread
From: Jonathan Cameron @ 2018-12-01 15:41 UTC (permalink / raw)
  To: Ardelean, Alexandru
  Cc: lars, robh+dt, knaack.h, Hennerich, Michael, mark.rutland,
	matheus.bernardino, pmeerw, gregkh, victorcolombo, linux-kernel,
	linux-iio, devel, kernel-usp, devicetree

On Mon, 26 Nov 2018 07:34:35 +0000
"Ardelean, Alexandru" <alexandru.Ardelean@analog.com> wrote:

> On Fri, 2018-11-23 at 22:23 -0200, Matheus Tavares wrote:
> > Move ad2s90 resolver driver out of staging to the main tree.
> >   
> 
> Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Hi Alexandru,

I took that to apply to the whole series, hope you don't mind.

Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan

> 
> > Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
> > Signed-off-by: Victor Colombo <victorcolombo@gmail.com>
> > ---
> > Changes in v3:
> >  - none
> > 
> > Changes in v2:
> >  - Disabled git move detection, to see the whole code, as Jonathan
> >  suggested
> > 
> >  drivers/iio/resolver/Kconfig          |  10 ++
> >  drivers/iio/resolver/Makefile         |   1 +
> >  drivers/iio/resolver/ad2s90.c         | 131 ++++++++++++++++++++++++++
> >  drivers/staging/iio/resolver/Kconfig  |  10 --
> >  drivers/staging/iio/resolver/Makefile |   1 -
> >  drivers/staging/iio/resolver/ad2s90.c | 131 --------------------------
> >  6 files changed, 142 insertions(+), 142 deletions(-)
> >  create mode 100644 drivers/iio/resolver/ad2s90.c
> >  delete mode 100644 drivers/staging/iio/resolver/ad2s90.c
> > 
> > diff --git a/drivers/iio/resolver/Kconfig b/drivers/iio/resolver/Kconfig
> > index 2ced9f22aa70..786801be54f6 100644
> > --- a/drivers/iio/resolver/Kconfig
> > +++ b/drivers/iio/resolver/Kconfig
> > @@ -3,6 +3,16 @@
> >  #
> >  menu "Resolver to digital converters"
> >  
> > +config AD2S90
> > +	tristate "Analog Devices ad2s90 driver"
> > +	depends on SPI
> > +	help
> > +	  Say yes here to build support for Analog Devices spi resolver
> > +	  to digital converters, ad2s90, provides direct access via sysfs.
> > +
> > +	  To compile this driver as a module, choose M here: the
> > +	  module will be called ad2s90.
> > +
> >  config AD2S1200
> >  	tristate "Analog Devices ad2s1200/ad2s1205 driver"
> >  	depends on SPI
> > diff --git a/drivers/iio/resolver/Makefile
> > b/drivers/iio/resolver/Makefile
> > index 4e1dccae07e7..398d82d50028 100644
> > --- a/drivers/iio/resolver/Makefile
> > +++ b/drivers/iio/resolver/Makefile
> > @@ -2,4 +2,5 @@
> >  # Makefile for Resolver/Synchro drivers
> >  #
> >  
> > +obj-$(CONFIG_AD2S90) += ad2s90.o
> >  obj-$(CONFIG_AD2S1200) += ad2s1200.o
> > diff --git a/drivers/iio/resolver/ad2s90.c
> > b/drivers/iio/resolver/ad2s90.c
> > new file mode 100644
> > index 000000000000..a41f5cb10da5
> > --- /dev/null
> > +++ b/drivers/iio/resolver/ad2s90.c
> > @@ -0,0 +1,131 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * ad2s90.c simple support for the ADI Resolver to Digital Converters:
> > AD2S90
> > + *
> > + * Copyright (c) 2010-2010 Analog Devices Inc.
> > + */
> > +#include <linux/types.h>
> > +#include <linux/mutex.h>
> > +#include <linux/device.h>
> > +#include <linux/spi/spi.h>
> > +#include <linux/slab.h>
> > +#include <linux/sysfs.h>
> > +#include <linux/module.h>
> > +
> > +#include <linux/iio/iio.h>
> > +#include <linux/iio/sysfs.h>
> > +
> > +/*
> > + * Although chip's max frequency is 2Mhz, it needs 600ns between CS and
> > the
> > + * first falling edge of SCLK, so frequency should be at most 1 / (2 *
> > 6e-7)
> > + */
> > +#define AD2S90_MAX_SPI_FREQ_HZ  830000
> > +
> > +struct ad2s90_state {
> > +	struct mutex lock; /* lock to protect rx buffer */
> > +	struct spi_device *sdev;
> > +	u8 rx[2] ____cacheline_aligned;
> > +};
> > +
> > +static int ad2s90_read_raw(struct iio_dev *indio_dev,
> > +			   struct iio_chan_spec const *chan,
> > +			   int *val,
> > +			   int *val2,
> > +			   long m)
> > +{
> > +	int ret;
> > +	struct ad2s90_state *st = iio_priv(indio_dev);
> > +
> > +	if (chan->type != IIO_ANGL)
> > +		return -EINVAL;
> > +
> > +	switch (m) {
> > +	case IIO_CHAN_INFO_SCALE:
> > +		/* 2 * Pi / 2^12 */
> > +		*val = 6283; /* mV */
> > +		*val2 = 12;
> > +		return IIO_VAL_FRACTIONAL_LOG2;
> > +	case IIO_CHAN_INFO_RAW:
> > +		mutex_lock(&st->lock);
> > +		ret = spi_read(st->sdev, st->rx, 2);
> > +		if (ret < 0) {
> > +			mutex_unlock(&st->lock);
> > +			return ret;
> > +		}
> > +		*val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >>
> > 4);
> > +
> > +		mutex_unlock(&st->lock);
> > +
> > +		return IIO_VAL_INT;
> > +	default:
> > +		break;
> > +	}
> > +
> > +	return -EINVAL;
> > +}
> > +
> > +static const struct iio_info ad2s90_info = {
> > +	.read_raw = ad2s90_read_raw,
> > +};
> > +
> > +static const struct iio_chan_spec ad2s90_chan = {
> > +	.type = IIO_ANGL,
> > +	.indexed = 1,
> > +	.channel = 0,
> > +	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> > BIT(IIO_CHAN_INFO_SCALE),
> > +};
> > +
> > +static int ad2s90_probe(struct spi_device *spi)
> > +{
> > +	struct iio_dev *indio_dev;
> > +	struct ad2s90_state *st;
> > +
> > +	if (spi->max_speed_hz > AD2S90_MAX_SPI_FREQ_HZ) {
> > +		dev_err(&spi->dev, "SPI CLK, %d Hz exceeds %d Hz\n",
> > +			spi->max_speed_hz, AD2S90_MAX_SPI_FREQ_HZ);
> > +		return -EINVAL;
> > +	}
> > +
> > +	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> > +	if (!indio_dev)
> > +		return -ENOMEM;
> > +	st = iio_priv(indio_dev);
> > +	spi_set_drvdata(spi, indio_dev);
> > +
> > +	mutex_init(&st->lock);
> > +	st->sdev = spi;
> > +	indio_dev->dev.parent = &spi->dev;
> > +	indio_dev->info = &ad2s90_info;
> > +	indio_dev->modes = INDIO_DIRECT_MODE;
> > +	indio_dev->channels = &ad2s90_chan;
> > +	indio_dev->num_channels = 1;
> > +	indio_dev->name = spi_get_device_id(spi)->name;
> > +
> > +	return devm_iio_device_register(indio_dev->dev.parent, indio_dev);
> > +}
> > +
> > +static const struct of_device_id ad2s90_of_match[] = {
> > +	{ .compatible = "adi,ad2s90", },
> > +	{}
> > +};
> > +MODULE_DEVICE_TABLE(of, ad2s90_of_match);
> > +
> > +static const struct spi_device_id ad2s90_id[] = {
> > +	{ "ad2s90" },
> > +	{}
> > +};
> > +MODULE_DEVICE_TABLE(spi, ad2s90_id);
> > +
> > +static struct spi_driver ad2s90_driver = {
> > +	.driver = {
> > +		.name = "ad2s90",
> > +		.of_match_table = ad2s90_of_match,
> > +	},
> > +	.probe = ad2s90_probe,
> > +	.id_table = ad2s90_id,
> > +};
> > +module_spi_driver(ad2s90_driver);
> > +
> > +MODULE_AUTHOR("Graff Yang <graff.yang@gmail.com>");
> > +MODULE_DESCRIPTION("Analog Devices AD2S90 Resolver to Digital SPI
> > driver");
> > +MODULE_LICENSE("GPL v2");
> > diff --git a/drivers/staging/iio/resolver/Kconfig
> > b/drivers/staging/iio/resolver/Kconfig
> > index 6a469ee6101f..4a727c17bb8f 100644
> > --- a/drivers/staging/iio/resolver/Kconfig
> > +++ b/drivers/staging/iio/resolver/Kconfig
> > @@ -3,16 +3,6 @@
> >  #
> >  menu "Resolver to digital converters"
> >  
> > -config AD2S90
> > -	tristate "Analog Devices ad2s90 driver"
> > -	depends on SPI
> > -	help
> > -	  Say yes here to build support for Analog Devices spi resolver
> > -	  to digital converters, ad2s90, provides direct access via sysfs.
> > -
> > -	  To compile this driver as a module, choose M here: the
> > -	  module will be called ad2s90.
> > -
> >  config AD2S1210
> >  	tristate "Analog Devices ad2s1210 driver"
> >  	depends on SPI
> > diff --git a/drivers/staging/iio/resolver/Makefile
> > b/drivers/staging/iio/resolver/Makefile
> > index 8d901dc7500b..b2049f2ce36e 100644
> > --- a/drivers/staging/iio/resolver/Makefile
> > +++ b/drivers/staging/iio/resolver/Makefile
> > @@ -2,5 +2,4 @@
> >  # Makefile for Resolver/Synchro drivers
> >  #
> >  
> > -obj-$(CONFIG_AD2S90) += ad2s90.o
> >  obj-$(CONFIG_AD2S1210) += ad2s1210.o
> > diff --git a/drivers/staging/iio/resolver/ad2s90.c
> > b/drivers/staging/iio/resolver/ad2s90.c
> > deleted file mode 100644
> > index a41f5cb10da5..000000000000
> > --- a/drivers/staging/iio/resolver/ad2s90.c
> > +++ /dev/null
> > @@ -1,131 +0,0 @@
> > -// SPDX-License-Identifier: GPL-2.0
> > -/*
> > - * ad2s90.c simple support for the ADI Resolver to Digital Converters:
> > AD2S90
> > - *
> > - * Copyright (c) 2010-2010 Analog Devices Inc.
> > - */
> > -#include <linux/types.h>
> > -#include <linux/mutex.h>
> > -#include <linux/device.h>
> > -#include <linux/spi/spi.h>
> > -#include <linux/slab.h>
> > -#include <linux/sysfs.h>
> > -#include <linux/module.h>
> > -
> > -#include <linux/iio/iio.h>
> > -#include <linux/iio/sysfs.h>
> > -
> > -/*
> > - * Although chip's max frequency is 2Mhz, it needs 600ns between CS and
> > the
> > - * first falling edge of SCLK, so frequency should be at most 1 / (2 *
> > 6e-7)
> > - */
> > -#define AD2S90_MAX_SPI_FREQ_HZ  830000
> > -
> > -struct ad2s90_state {
> > -	struct mutex lock; /* lock to protect rx buffer */
> > -	struct spi_device *sdev;
> > -	u8 rx[2] ____cacheline_aligned;
> > -};
> > -
> > -static int ad2s90_read_raw(struct iio_dev *indio_dev,
> > -			   struct iio_chan_spec const *chan,
> > -			   int *val,
> > -			   int *val2,
> > -			   long m)
> > -{
> > -	int ret;
> > -	struct ad2s90_state *st = iio_priv(indio_dev);
> > -
> > -	if (chan->type != IIO_ANGL)
> > -		return -EINVAL;
> > -
> > -	switch (m) {
> > -	case IIO_CHAN_INFO_SCALE:
> > -		/* 2 * Pi / 2^12 */
> > -		*val = 6283; /* mV */
> > -		*val2 = 12;
> > -		return IIO_VAL_FRACTIONAL_LOG2;
> > -	case IIO_CHAN_INFO_RAW:
> > -		mutex_lock(&st->lock);
> > -		ret = spi_read(st->sdev, st->rx, 2);
> > -		if (ret < 0) {
> > -			mutex_unlock(&st->lock);
> > -			return ret;
> > -		}
> > -		*val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >>
> > 4);
> > -
> > -		mutex_unlock(&st->lock);
> > -
> > -		return IIO_VAL_INT;
> > -	default:
> > -		break;
> > -	}
> > -
> > -	return -EINVAL;
> > -}
> > -
> > -static const struct iio_info ad2s90_info = {
> > -	.read_raw = ad2s90_read_raw,
> > -};
> > -
> > -static const struct iio_chan_spec ad2s90_chan = {
> > -	.type = IIO_ANGL,
> > -	.indexed = 1,
> > -	.channel = 0,
> > -	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> > BIT(IIO_CHAN_INFO_SCALE),
> > -};
> > -
> > -static int ad2s90_probe(struct spi_device *spi)
> > -{
> > -	struct iio_dev *indio_dev;
> > -	struct ad2s90_state *st;
> > -
> > -	if (spi->max_speed_hz > AD2S90_MAX_SPI_FREQ_HZ) {
> > -		dev_err(&spi->dev, "SPI CLK, %d Hz exceeds %d Hz\n",
> > -			spi->max_speed_hz, AD2S90_MAX_SPI_FREQ_HZ);
> > -		return -EINVAL;
> > -	}
> > -
> > -	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> > -	if (!indio_dev)
> > -		return -ENOMEM;
> > -	st = iio_priv(indio_dev);
> > -	spi_set_drvdata(spi, indio_dev);
> > -
> > -	mutex_init(&st->lock);
> > -	st->sdev = spi;
> > -	indio_dev->dev.parent = &spi->dev;
> > -	indio_dev->info = &ad2s90_info;
> > -	indio_dev->modes = INDIO_DIRECT_MODE;
> > -	indio_dev->channels = &ad2s90_chan;
> > -	indio_dev->num_channels = 1;
> > -	indio_dev->name = spi_get_device_id(spi)->name;
> > -
> > -	return devm_iio_device_register(indio_dev->dev.parent, indio_dev);
> > -}
> > -
> > -static const struct of_device_id ad2s90_of_match[] = {
> > -	{ .compatible = "adi,ad2s90", },
> > -	{}
> > -};
> > -MODULE_DEVICE_TABLE(of, ad2s90_of_match);
> > -
> > -static const struct spi_device_id ad2s90_id[] = {
> > -	{ "ad2s90" },
> > -	{}
> > -};
> > -MODULE_DEVICE_TABLE(spi, ad2s90_id);
> > -
> > -static struct spi_driver ad2s90_driver = {
> > -	.driver = {
> > -		.name = "ad2s90",
> > -		.of_match_table = ad2s90_of_match,
> > -	},
> > -	.probe = ad2s90_probe,
> > -	.id_table = ad2s90_id,
> > -};
> > -module_spi_driver(ad2s90_driver);
> > -
> > -MODULE_AUTHOR("Graff Yang <graff.yang@gmail.com>");
> > -MODULE_DESCRIPTION("Analog Devices AD2S90 Resolver to Digital SPI
> > driver");
> > -MODULE_LICENSE("GPL v2");  


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

end of thread, other threads:[~2018-12-01 15:41 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-24  0:23 [PATCH v3 0/7] staging:iio:ad2s90: Add dt support and move out of staging Matheus Tavares
2018-11-24  0:23 ` [PATCH v3 1/7] staging:iio:ad2s90: Add device tree support Matheus Tavares
2018-12-01 15:34   ` Jonathan Cameron
2018-11-24  0:23 ` [PATCH v3 2/7] staging:iio:ad2s90: Remove spi setup that should be done via dt Matheus Tavares
2018-12-01 15:34   ` Jonathan Cameron
2018-11-24  0:23 ` [PATCH v3 3/7] staging:iio:ad2s90: Add max frequency check at probe Matheus Tavares
2018-12-01 15:37   ` Jonathan Cameron
2018-11-24  0:23 ` [PATCH v3 4/7] dt-bindings:iio:resolver: Add docs for ad2s90 Matheus Tavares
2018-11-27  1:52   ` Rob Herring
2018-12-01 15:37     ` Jonathan Cameron
2018-11-24  0:23 ` [PATCH v3 5/7] staging:iio:ad2s90: Replace license text w/ SPDX identifier Matheus Tavares
2018-12-01 15:38   ` Jonathan Cameron
2018-11-24  0:23 ` [PATCH v3 6/7] staging:iio:ad2s90: Add comment to device state mutex Matheus Tavares
2018-12-01 15:39   ` Jonathan Cameron
2018-11-24  0:23 ` [PATCH v3 7/7] staging:iio:ad2s90: Move out of staging Matheus Tavares
2018-11-25  9:56   ` Jonathan Cameron
2018-11-26  7:34   ` Ardelean, Alexandru
2018-12-01 15:41     ` 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).