* [PATCH v3 0/7] staging:iio:ad2s90: Add dt support and move out of staging @ 2018-11-24 0:23 ` Matheus Tavares 0 siblings, 0 replies; 28+ 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] 28+ messages in thread
* [PATCH v3 0/7] staging:iio:ad2s90: Add dt support and move out of staging @ 2018-11-24 0:23 ` Matheus Tavares 0 siblings, 0 replies; 28+ 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: devel, devicetree, linux-iio, linux-kernel, kernel-usp, Alexandru Ardelean, 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] 28+ messages in thread
* [PATCH v3 1/7] staging:iio:ad2s90: Add device tree support 2018-11-24 0:23 ` Matheus Tavares (?) @ 2018-11-24 0:23 ` Matheus Tavares 2018-12-01 15:34 ` Jonathan Cameron -1 siblings, 1 reply; 28+ 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] 28+ 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; 28+ 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] 28+ messages in thread
* Re: [PATCH v3 1/7] staging:iio:ad2s90: Add device tree support @ 2018-12-01 15:34 ` Jonathan Cameron 0 siblings, 0 replies; 28+ messages in thread From: Jonathan Cameron @ 2018-12-01 15:34 UTC (permalink / raw) To: Matheus Tavares Cc: Mark Rutland, devel, Lars-Peter Clausen, Michael Hennerich, devicetree, linux-iio, Greg Kroah-Hartman, linux-kernel, kernel-usp, Rob Herring, Peter Meerwald-Stadler, Hartmut Knaack, Alexandru Ardelean, 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] 28+ messages in thread
* [PATCH v3 2/7] staging:iio:ad2s90: Remove spi setup that should be done via dt 2018-11-24 0:23 ` Matheus Tavares @ 2018-11-24 0:23 ` Matheus Tavares -1 siblings, 0 replies; 28+ 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] 28+ messages in thread
* [PATCH v3 2/7] staging:iio:ad2s90: Remove spi setup that should be done via dt @ 2018-11-24 0:23 ` Matheus Tavares 0 siblings, 0 replies; 28+ 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: devel, devicetree, linux-iio, linux-kernel, kernel-usp, Alexandru Ardelean, 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] 28+ 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 ` Matheus Tavares @ 2018-12-01 15:34 ` Jonathan Cameron -1 siblings, 0 replies; 28+ 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] 28+ messages in thread
* Re: [PATCH v3 2/7] staging:iio:ad2s90: Remove spi setup that should be done via dt @ 2018-12-01 15:34 ` Jonathan Cameron 0 siblings, 0 replies; 28+ messages in thread From: Jonathan Cameron @ 2018-12-01 15:34 UTC (permalink / raw) To: Matheus Tavares Cc: Mark Rutland, devel, Lars-Peter Clausen, Michael Hennerich, devicetree, linux-iio, Greg Kroah-Hartman, linux-kernel, kernel-usp, Rob Herring, Peter Meerwald-Stadler, Hartmut Knaack, Alexandru Ardelean, 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] 28+ messages in thread
* [PATCH v3 3/7] staging:iio:ad2s90: Add max frequency check at probe 2018-11-24 0:23 ` Matheus Tavares ` (2 preceding siblings ...) (?) @ 2018-11-24 0:23 ` Matheus Tavares 2018-12-01 15:37 ` Jonathan Cameron -1 siblings, 1 reply; 28+ 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] 28+ 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; 28+ 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] 28+ messages in thread
* [PATCH v3 4/7] dt-bindings:iio:resolver: Add docs for ad2s90 2018-11-24 0:23 ` Matheus Tavares ` (3 preceding siblings ...) (?) @ 2018-11-24 0:23 ` Matheus Tavares 2018-11-27 1:52 ` Rob Herring -1 siblings, 1 reply; 28+ 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] 28+ 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; 28+ 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] 28+ 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; 28+ 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] 28+ messages in thread
* [PATCH v3 5/7] staging:iio:ad2s90: Replace license text w/ SPDX identifier 2018-11-24 0:23 ` Matheus Tavares ` (4 preceding siblings ...) (?) @ 2018-11-24 0:23 ` Matheus Tavares 2018-12-01 15:38 ` Jonathan Cameron -1 siblings, 1 reply; 28+ 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] 28+ 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; 28+ 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] 28+ messages in thread
* Re: [PATCH v3 5/7] staging:iio:ad2s90: Replace license text w/ SPDX identifier @ 2018-12-01 15:38 ` Jonathan Cameron 0 siblings, 0 replies; 28+ messages in thread From: Jonathan Cameron @ 2018-12-01 15:38 UTC (permalink / raw) To: Matheus Tavares Cc: Mark Rutland, devel, Lars-Peter Clausen, Michael Hennerich, devicetree, linux-iio, Greg Kroah-Hartman, linux-kernel, kernel-usp, Rob Herring, Peter Meerwald-Stadler, Hartmut Knaack, Alexandru Ardelean, 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] 28+ messages in thread
* [PATCH v3 6/7] staging:iio:ad2s90: Add comment to device state mutex 2018-11-24 0:23 ` Matheus Tavares @ 2018-11-24 0:23 ` Matheus Tavares -1 siblings, 0 replies; 28+ 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] 28+ messages in thread
* [PATCH v3 6/7] staging:iio:ad2s90: Add comment to device state mutex @ 2018-11-24 0:23 ` Matheus Tavares 0 siblings, 0 replies; 28+ 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: devel, devicetree, linux-iio, linux-kernel, kernel-usp, Alexandru Ardelean, 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] 28+ messages in thread
* Re: [PATCH v3 6/7] staging:iio:ad2s90: Add comment to device state mutex 2018-11-24 0:23 ` Matheus Tavares @ 2018-12-01 15:39 ` Jonathan Cameron -1 siblings, 0 replies; 28+ 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] 28+ messages in thread
* Re: [PATCH v3 6/7] staging:iio:ad2s90: Add comment to device state mutex @ 2018-12-01 15:39 ` Jonathan Cameron 0 siblings, 0 replies; 28+ messages in thread From: Jonathan Cameron @ 2018-12-01 15:39 UTC (permalink / raw) To: Matheus Tavares Cc: Mark Rutland, devel, Lars-Peter Clausen, Michael Hennerich, devicetree, linux-iio, Greg Kroah-Hartman, linux-kernel, kernel-usp, Rob Herring, Peter Meerwald-Stadler, Hartmut Knaack, Alexandru Ardelean, 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] 28+ messages in thread
* [PATCH v3 7/7] staging:iio:ad2s90: Move out of staging 2018-11-24 0:23 ` Matheus Tavares ` (6 preceding siblings ...) (?) @ 2018-11-24 0:23 ` Matheus Tavares 2018-11-25 9:56 ` Jonathan Cameron 2018-11-26 7:34 ` Ardelean, Alexandru -1 siblings, 2 replies; 28+ 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] 28+ 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; 28+ 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] 28+ messages in thread
* Re: [PATCH v3 7/7] staging:iio:ad2s90: Move out of staging @ 2018-11-25 9:56 ` Jonathan Cameron 0 siblings, 0 replies; 28+ messages in thread From: Jonathan Cameron @ 2018-11-25 9:56 UTC (permalink / raw) To: Matheus Tavares Cc: Mark Rutland, devel, Lars-Peter Clausen, Michael Hennerich, devicetree, linux-iio, Greg Kroah-Hartman, linux-kernel, kernel-usp, Rob Herring, Peter Meerwald-Stadler, Hartmut Knaack, Alexandru Ardelean, 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] 28+ 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; 28+ messages in thread From: Ardelean, Alexandru @ 2018-11-26 7:34 UTC (permalink / raw) To: lars@metafoo.de, robh+dt@kernel.org, knaack.h@gmx.de, jic23@kernel.org, Hennerich, Michael, mark.rutland@arm.com, matheus.bernardino@usp.br, pmeerw@pmeerw.net, gregkh@linuxfoundation.org Cc: victorcolombo@gmail.com, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, kernel-usp@googlegroups.com, devicetree@vger.kernel.org T24gRnJpLCAyMDE4LTExLTIzIGF0IDIyOjIzIC0wMjAwLCBNYXRoZXVzIFRhdmFyZXMgd3JvdGU6 DQo+IE1vdmUgYWQyczkwIHJlc29sdmVyIGRyaXZlciBvdXQgb2Ygc3RhZ2luZyB0byB0aGUgbWFp biB0cmVlLg0KPiANCg0KQWNrZWQtYnk6IEFsZXhhbmRydSBBcmRlbGVhbiA8YWxleGFuZHJ1LmFy ZGVsZWFuQGFuYWxvZy5jb20+DQoNCj4gU2lnbmVkLW9mZi1ieTogTWF0aGV1cyBUYXZhcmVzIDxt YXRoZXVzLmJlcm5hcmRpbm9AdXNwLmJyPg0KPiBTaWduZWQtb2ZmLWJ5OiBWaWN0b3IgQ29sb21i byA8dmljdG9yY29sb21ib0BnbWFpbC5jb20+DQo+IC0tLQ0KPiBDaGFuZ2VzIGluIHYzOg0KPiAg LSBub25lDQo+IA0KPiBDaGFuZ2VzIGluIHYyOg0KPiAgLSBEaXNhYmxlZCBnaXQgbW92ZSBkZXRl Y3Rpb24sIHRvIHNlZSB0aGUgd2hvbGUgY29kZSwgYXMgSm9uYXRoYW4NCj4gIHN1Z2dlc3RlZA0K PiANCj4gIGRyaXZlcnMvaWlvL3Jlc29sdmVyL0tjb25maWcgICAgICAgICAgfCAgMTAgKysNCj4g IGRyaXZlc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SQ0KPiBkcml2 ZXIiKTsNCj4gLU1PRFVMRV9MSUNFTlNFKCJHUEwgdjIiKTsNCg== ^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 7/7] staging:iio:ad2s90: Move out of staging @ 2018-11-26 7:34 ` Ardelean, Alexandru 0 siblings, 0 replies; 28+ messages in thread From: Ardelean, Alexandru @ 2018-11-26 7:34 UTC (permalink / raw) To: lars@metafoo.de, robh+dt@kernel.org, knaack.h@gmx.de, jic23@kernel.org, Hennerich, Michael, mark.rutland@arm.com, matheus.bernardino@usp.br, pmeerw@pmeerw.net, gregkh@linuxfoundation.org Cc: victorcolombo@gmail.com, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, kernel-usp@googlegroups.com, devicetree@vger.kernel.org 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] 28+ messages in thread
* Re: [PATCH v3 7/7] staging:iio:ad2s90: Move out of staging @ 2018-11-26 7:34 ` Ardelean, Alexandru 0 siblings, 0 replies; 28+ messages in thread From: Ardelean, Alexandru @ 2018-11-26 7:34 UTC (permalink / raw) To: lars@metafoo.de, robh+dt@kernel.org, knaack.h@gmx.de, jic23@kernel.org, Hennerich, Michael, mark.rutland@arm.com, matheus.bernardino@usp.br, pmeerw@pmeerw.net, gregkh@linuxfoundation.org Cc: devel@driverdev.osuosl.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com, victorcolombo@gmail.com 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] 28+ 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 -1 siblings, 0 replies; 28+ messages in thread From: Jonathan Cameron @ 2018-12-01 15:41 UTC (permalink / raw) To: Ardelean, Alexandru Cc: lars@metafoo.de, robh+dt@kernel.org, knaack.h@gmx.de, Hennerich, Michael, mark.rutland@arm.com, matheus.bernardino@usp.br, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, victorcolombo@gmail.com, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, kernel-usp@googlegroups.com, devicetree@vger.kernel.org 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] 28+ messages in thread
end of thread, other threads:[~2018-12-02 2:54 UTC | newest] Thread overview: 28+ 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 ` 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-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-11-24 0:23 ` Matheus Tavares 2018-12-01 15:34 ` Jonathan Cameron 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-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 ` Matheus Tavares 2018-12-01 15:39 ` Jonathan Cameron 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-25 9:56 ` Jonathan Cameron 2018-11-26 7:34 ` Ardelean, Alexandru 2018-11-26 7:34 ` Ardelean, Alexandru 2018-11-26 7:34 ` Ardelean, Alexandru 2018-12-01 15:41 ` Jonathan Cameron
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.