From: Jonathan Cameron <jic23@kernel.org>
To: Nishad Kamdar <nishadkamdar@gmail.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Hartmut Knaack <knaack.h@gmx.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-iio@vger.kernel.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/4] staging: iio: ad7816: Do not use busy_pin in case of AD7818
Date: Sun, 11 Nov 2018 12:35:03 +0000 [thread overview]
Message-ID: <20181111123503.3a4acef2@archlinux> (raw)
In-Reply-To: <3f0bc36261c54c945a3213ef03425099e57e9060.1541733949.git.nishadkamdar@gmail.com>
On Fri, 9 Nov 2018 13:06:24 +0530
Nishad Kamdar <nishadkamdar@gmail.com> wrote:
> AD7818 does not support busy_pin functionality as per datasheet.
> Hence drop busy_pin when AD7818 is used.
>
> Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.
A slight concern that I can't immediately find an answer to,
is whether we should be waiting a short while for the ad7818 given
we can't wait on the gpio? We can add this in a follow up patch
if it is necessary.
Thanks,
Jonathan
> ---
> drivers/staging/iio/adc/ad7816.c | 35 ++++++++++++++++++++++----------
> 1 file changed, 24 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c
> index 12c4e0ab4713..3cda5cd09365 100644
> --- a/drivers/staging/iio/adc/ad7816.c
> +++ b/drivers/staging/iio/adc/ad7816.c
> @@ -43,6 +43,7 @@
> */
>
> struct ad7816_chip_info {
> + kernel_ulong_t id;
> struct spi_device *spi_dev;
> struct gpio_desc *rdwr_pin;
> struct gpio_desc *convert_pin;
> @@ -52,6 +53,12 @@ struct ad7816_chip_info {
> u8 mode;
> };
>
> +enum ad7816_type {
> + ID_AD7816,
> + ID_AD7817,
> + ID_AD7818,
> +};
> +
> /*
> * ad7816 data access by SPI
> */
> @@ -78,8 +85,10 @@ static int ad7816_spi_read(struct ad7816_chip_info *chip, u16 *data)
> gpiod_set_value(chip->convert_pin, 1);
> }
>
> - while (gpiod_get_value(chip->busy_pin))
> - cpu_relax();
> + if (chip->id == ID_AD7816 || chip->id == ID_AD7817) {
> + while (gpiod_get_value(chip->busy_pin))
> + cpu_relax();
> + }
>
> gpiod_set_value(chip->rdwr_pin, 0);
> gpiod_set_value(chip->rdwr_pin, 1);
> @@ -359,6 +368,7 @@ static int ad7816_probe(struct spi_device *spi_dev)
> for (i = 0; i <= AD7816_CS_MAX; i++)
> chip->oti_data[i] = 203;
>
> + chip->id = spi_get_device_id(spi_dev)->driver_data;
> chip->rdwr_pin = devm_gpiod_get(&spi_dev->dev, "rdwr", GPIOD_IN);
> if (IS_ERR(chip->rdwr_pin)) {
> ret = PTR_ERR(chip->rdwr_pin);
> @@ -373,12 +383,15 @@ static int ad7816_probe(struct spi_device *spi_dev)
> ret);
> return ret;
> }
> - chip->busy_pin = devm_gpiod_get(&spi_dev->dev, "busy", GPIOD_IN);
> - if (IS_ERR(chip->busy_pin)) {
> - ret = PTR_ERR(chip->busy_pin);
> - dev_err(&spi_dev->dev, "Failed to request busy GPIO: %d\n",
> - ret);
> - return ret;
> + if (chip->id == ID_AD7816 || chip->id == ID_AD7817) {
> + chip->busy_pin = devm_gpiod_get(&spi_dev->dev, "busy",
> + GPIOD_IN);
> + if (IS_ERR(chip->busy_pin)) {
> + ret = PTR_ERR(chip->busy_pin);
> + dev_err(&spi_dev->dev, "Failed to request busy GPIO: %d\n",
> + ret);
> + return ret;
> + }
> }
>
> indio_dev->name = spi_get_device_id(spi_dev)->name;
> @@ -409,9 +422,9 @@ static int ad7816_probe(struct spi_device *spi_dev)
> }
>
> static const struct spi_device_id ad7816_id[] = {
> - { "ad7816", 0 },
> - { "ad7817", 0 },
> - { "ad7818", 0 },
> + { "ad7816", ID_AD7816 },
> + { "ad7817", ID_AD7817 },
> + { "ad7818", ID_AD7818 },
> {}
> };
>
next prev parent reply other threads:[~2018-11-11 22:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-09 7:34 [PATCH v3 0/4] staging: iio: ad7816: Switch to the gpio descriptor interface Nishad Kamdar
2018-11-09 7:35 ` [PATCH v3 1/4] " Nishad Kamdar
2018-11-09 8:05 ` Ardelean, Alexandru
2018-11-09 8:08 ` Ardelean, Alexandru
2018-11-11 12:24 ` Jonathan Cameron
2018-11-11 12:31 ` Jonathan Cameron
2018-11-14 17:06 ` Nishad Kamdar
2018-11-09 7:36 ` [PATCH v3 2/4] staging: iio: ad7816: Do not use busy_pin in case of AD7818 Nishad Kamdar
2018-11-11 12:35 ` Jonathan Cameron [this message]
2018-11-09 7:37 ` [PATCH v3 3/4] staging: iio: ad7816: Set RD/WR pin and CONVST pin as outputs Nishad Kamdar
2018-11-11 12:36 ` Jonathan Cameron
2018-11-09 7:38 ` [PATCH v3 4/4] staging: iio: ad7816: Add device tree table Nishad Kamdar
2018-11-09 8:11 ` Ardelean, Alexandru
2018-11-11 12:38 ` Jonathan Cameron
2018-11-14 16:54 ` Nishad Kamdar
2018-11-14 16:29 ` Nishad Kamdar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181111123503.3a4acef2@archlinux \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nishadkamdar@gmail.com \
--cc=pmeerw@pmeerw.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).