mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Nikita Yushchenko <nikita.yoush@cogentembedded.com>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Matt Ranostay <mranostay@gmail.com>,
	Gregor Boirie <gregor.boirie@parrot.com>,
	Sanchayan Maity <maitysanchayan@gmail.com>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jeff White <Jeff.White@zii.aero>,
	Chris Healy <Chris.Healy@zii.aero>,
	Vladimir Barinov <vladimir.barinov@cogentembedded.com>
Subject: Re: [PATCH 4/4] iio: hi8435: cleanup reset gpio
Date: Sat, 20 May 2017 17:37:39 +0100	[thread overview]
Message-ID: <9d66f2f3-001b-c9e0-852b-189d140702e3@kernel.org> (raw)
In-Reply-To: <20170519144802.14427-4-nikita.yoush@cogentembedded.com>

On 19/05/17 15:48, Nikita Yushchenko wrote:
> Reset GPIO is active low.
> 
> Currently driver uses gpiod_set_value(1) to clean reset, which depends
> on device tree to contain GPIO_ACTIVE_HIGH - that does not match reality.
> 
> This fixes driver to use _raw version of gpiod_set_value() to enforce
> active-low semantics despite of what's written in device tree. Allowing
> device tree to override that only opens possibility for errors and does
> not add any value.
> 
> Additionally, use _cansleep version to make things work with i2c-gpio
> and other sleeping gpio drivers.
> 
> Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Hopefully we don't have any 'interesting' wiring schemes out there
that actually have a not gate on that wire.

Your argument seems sound to me so applied to the togreg branch
of iio.git and pushed out as testing for the autobuilders to play with
it.

Again, input from Vladimir would be particularly welcome!

Jonathan
> ---
>   drivers/iio/adc/hi8435.c | 12 +++++++-----
>   1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/adc/hi8435.c b/drivers/iio/adc/hi8435.c
> index d09cb6ff8044..ab59969b7c49 100644
> --- a/drivers/iio/adc/hi8435.c
> +++ b/drivers/iio/adc/hi8435.c
> @@ -476,13 +476,15 @@ static int hi8435_probe(struct spi_device *spi)
>   	priv->spi = spi;
>   
>   	reset_gpio = devm_gpiod_get(&spi->dev, NULL, GPIOD_OUT_LOW);
> -	if (IS_ERR(reset_gpio)) {
> -		/* chip s/w reset if h/w reset failed */
> +	if (!IS_ERR(reset_gpio)) {
> +		/* need >=100ns low pulse to reset chip */
> +		gpiod_set_raw_value_cansleep(reset_gpio, 0);
> +		udelay(1);
> +		gpiod_set_raw_value_cansleep(reset_gpio, 1);
> +	} else {
> +		/* s/w reset chip if h/w reset is not available */
>   		hi8435_writeb(priv, HI8435_CTRL_REG, HI8435_CTRL_SRST);
>   		hi8435_writeb(priv, HI8435_CTRL_REG, 0);
> -	} else {
> -		udelay(5);
> -		gpiod_set_value(reset_gpio, 1);
>   	}
>   
>   	spi_set_drvdata(spi, idev);
> 

  reply	other threads:[~2017-05-20 16:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-19 14:47 [PATCH 1/4] iio: hi8435: add raw access Nikita Yushchenko
2017-05-19 14:48 ` [PATCH 2/4] iio: hi8435: avoid garbage event at first enable Nikita Yushchenko
2017-05-20 16:34   ` Jonathan Cameron
2017-05-22 18:20   ` Vladimir Barinov
2017-05-23  7:21     ` Nikita Yushchenko
2017-05-19 14:48 ` [PATCH 3/4] iio: hi8435: make in_voltage_sensing_mode_available visible Nikita Yushchenko
2017-05-20 16:35   ` Jonathan Cameron
2017-05-19 14:48 ` [PATCH 4/4] iio: hi8435: cleanup reset gpio Nikita Yushchenko
2017-05-20 16:37   ` Jonathan Cameron [this message]
     [not found]   ` <18fc343b-d7a4-c5b8-84e6-702af6e94e44@cogentembedded.com>
2017-05-23  8:18     ` Nikita Yushchenko
2017-05-24 11:27       ` Vladimir Barinov
2017-05-24 19:38         ` Jonathan Cameron
2017-05-25  6:27           ` Nikita Yushchenko
2017-05-28 15:42             ` Jonathan Cameron
2017-05-29  7:57               ` Nikita Yushchenko
2017-05-29 17:08             ` Linus Walleij
2017-05-20 16:33 ` [PATCH 1/4] iio: hi8435: add raw access Jonathan Cameron
2017-05-22 17:27   ` Vladimir Barinov

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=9d66f2f3-001b-c9e0-852b-189d140702e3@kernel.org \
    --to=jic23@kernel.org \
    --cc=Chris.Healy@zii.aero \
    --cc=Jeff.White@zii.aero \
    --cc=gregor.boirie@parrot.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maitysanchayan@gmail.com \
    --cc=mranostay@gmail.com \
    --cc=nikita.yoush@cogentembedded.com \
    --cc=pmeerw@pmeerw.net \
    --cc=vladimir.barinov@cogentembedded.com \
    /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

all inboxes | Powered by JetHome®