All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Vlad Dogaru <vlad.dogaru@intel.com>, linux-iio@vger.kernel.org
Subject: Re: [PATCH 5/6] iio: sx9500: add GPIO reset pin
Date: Thu, 09 Apr 2015 17:31:09 +0100	[thread overview]
Message-ID: <5526A94D.6050806@kernel.org> (raw)
In-Reply-To: <1428065254-6444-6-git-send-email-vlad.dogaru@intel.com>

On 03/04/15 13:47, Vlad Dogaru wrote:
> If a GPIO reset pin is listed in ACPI or Device Tree, use it to reset
> the device on initialization.
> 
> Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com>
Again this one is fine.
> ---
>  drivers/iio/proximity/sx9500.c | 21 +++++++++++++++++++--
>  1 file changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
> index d1e886c..9738df1 100644
> --- a/drivers/iio/proximity/sx9500.c
> +++ b/drivers/iio/proximity/sx9500.c
> @@ -33,6 +33,7 @@
>  #define SX9500_IRQ_NAME			"sx9500_event"
>  
>  #define SX9500_GPIO_INT			"interrupt"
> +#define SX9500_GPIO_RESET		"reset"
>  
>  /* Register definitions. */
>  #define SX9500_REG_IRQ_SRC		0x00
> @@ -85,6 +86,7 @@ struct sx9500_data {
>  	struct i2c_client *client;
>  	struct iio_trigger *trig;
>  	struct regmap *regmap;
> +	struct gpio_desc *gpiod_rst;
>  	/*
>  	 * Last reading of the proximity status for each channel.  We
>  	 * only send an event to user space when this changes.
> @@ -803,6 +805,13 @@ static int sx9500_init_device(struct iio_dev *indio_dev)
>  	int ret, i;
>  	unsigned int val;
>  
> +	if (data->gpiod_rst) {
> +		gpiod_set_value_cansleep(data->gpiod_rst, 0);
> +		usleep_range(1000, 2000);
> +		gpiod_set_value_cansleep(data->gpiod_rst, 1);
> +		usleep_range(1000, 2000);
> +	}
> +
>  	ret = regmap_write(data->regmap, SX9500_REG_IRQ_MSK, 0);
>  	if (ret < 0)
>  		return ret;
> @@ -850,6 +859,12 @@ static void sx9500_gpio_probe(struct i2c_client *client,
>  			client->irq = gpiod_to_irq(gpio);
>  	}
>  
> +	data->gpiod_rst = devm_gpiod_get_index(dev, SX9500_GPIO_RESET,
> +					       0, GPIOD_OUT_HIGH);
> +	if (IS_ERR(data->gpiod_rst)) {
> +		dev_warn(dev, "gpio get reset pin failed\n");
> +		data->gpiod_rst = NULL;
> +	}
>  }
>  
>  static int sx9500_probe(struct i2c_client *client,
> @@ -873,8 +888,6 @@ static int sx9500_probe(struct i2c_client *client,
>  	if (IS_ERR(data->regmap))
>  		return PTR_ERR(data->regmap);
>  
> -	sx9500_init_device(indio_dev);
> -
>  	indio_dev->dev.parent = &client->dev;
>  	indio_dev->name = SX9500_DRIVER_NAME;
>  	indio_dev->channels = sx9500_channels;
> @@ -890,6 +903,10 @@ static int sx9500_probe(struct i2c_client *client,
>  		return -EINVAL;
>  	}
>  
> +	ret = sx9500_init_device(indio_dev);
> +	if (ret < 0)
> +		return ret;
> +
>  	ret = devm_request_threaded_irq(&client->dev, client->irq,
>  					sx9500_irq_handler,
>  					sx9500_irq_thread_handler,
> 


  reply	other threads:[~2015-04-09 16:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-03 12:47 [PATCH 0/6] iio: sx9500: power and GPIO fixes Vlad Dogaru
2015-04-03 12:47 ` [PATCH 1/6] iio: sx9500: add power management Vlad Dogaru
2015-04-09 16:13   ` Jonathan Cameron
2015-04-03 12:47 ` [PATCH 2/6] iio: sx9500: optimize power usage Vlad Dogaru
2015-04-09 16:27   ` Jonathan Cameron
2015-04-10 10:36     ` Vlad Dogaru
2015-04-12 16:08       ` Jonathan Cameron
2015-04-03 12:47 ` [PATCH 3/6] iio: sx9500: rename GPIO interrupt pin Vlad Dogaru
2015-04-09 16:28   ` Jonathan Cameron
2015-04-18 18:59   ` Jonathan Cameron
2015-04-03 12:47 ` [PATCH 4/6] iio: sx9500: refactor GPIO interrupt code Vlad Dogaru
2015-04-09 16:30   ` Jonathan Cameron
2015-04-03 12:47 ` [PATCH 5/6] iio: sx9500: add GPIO reset pin Vlad Dogaru
2015-04-09 16:31   ` Jonathan Cameron [this message]
2015-04-03 12:47 ` [PATCH 6/6] iio: sx9500: fix formatting Vlad Dogaru
2015-04-09 16:31   ` Jonathan Cameron

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=5526A94D.6050806@kernel.org \
    --to=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=vlad.dogaru@intel.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 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.