All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Jonathan Cameron <jic23@cam.ac.uk>,
	linux-iio@vger.kernel.org, drivers@analog.com
Subject: Re: [PATCH 1/2] staging:iio:ad7780: Make powerdown GPIO optional
Date: Sat, 22 Sep 2012 10:25:52 +0100	[thread overview]
Message-ID: <505D8420.4020703@kernel.org> (raw)
In-Reply-To: <1348234148-22669-1-git-send-email-lars@metafoo.de>

On 09/21/2012 02:29 PM, Lars-Peter Clausen wrote:
> Some designs hardwire the PDRST pin to always on. In this case there is no GPIO
> to control the mode of the device, so make the GPIO optional. Since now all of
> the the platform data fields are optional now, make the platform data as a whole
> optional as well.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
added to togreg branch of iio.git
> ---
>  drivers/staging/iio/adc/ad7780.c |   31 +++++++++++++++++--------------
>  1 file changed, 17 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
> index 5f807ce..1dd7cdb 100644
> --- a/drivers/staging/iio/adc/ad7780.c
> +++ b/drivers/staging/iio/adc/ad7780.c
> @@ -73,7 +73,8 @@ static int ad7780_set_mode(struct ad_sigma_delta *sigma_delta,
>  		break;
>  	}
>  
> -	gpio_set_value(st->powerdown_gpio, val);
> +	if (gpio_is_valid(st->powerdown_gpio))
> +		gpio_set_value(st->powerdown_gpio, val);
>  
>  	return 0;
>  }
> @@ -148,11 +149,6 @@ static int __devinit ad7780_probe(struct spi_device *spi)
>  	struct iio_dev *indio_dev;
>  	int ret, voltage_uv = 0;
>  
> -	if (!pdata) {
> -		dev_dbg(&spi->dev, "no platform data?\n");
> -		return -ENODEV;
> -	}
> -
>  	indio_dev = iio_device_alloc(sizeof(*st));
>  	if (indio_dev == NULL)
>  		return -ENOMEM;
> @@ -174,8 +170,6 @@ static int __devinit ad7780_probe(struct spi_device *spi)
>  	st->chip_info =
>  		&ad7780_chip_info_tbl[spi_get_device_id(spi)->driver_data];
>  
> -	st->powerdown_gpio = pdata->gpio_pdrst;
> -
>  	if (pdata && pdata->vref_mv)
>  		st->int_vref_mv = pdata->vref_mv;
>  	else if (voltage_uv)
> @@ -192,11 +186,17 @@ static int __devinit ad7780_probe(struct spi_device *spi)
>  	indio_dev->num_channels = 1;
>  	indio_dev->info = &ad7780_info;
>  
> -	ret = gpio_request_one(pdata->gpio_pdrst, GPIOF_OUT_INIT_LOW,
> +	if (pdata && gpio_is_valid(pdata->gpio_pdrst)) {
> +
> +		ret = gpio_request_one(pdata->gpio_pdrst, GPIOF_OUT_INIT_LOW,
>  			       "AD7780 /PDRST");
> -	if (ret) {
> -		dev_err(&spi->dev, "failed to request GPIO PDRST\n");
> -		goto error_disable_reg;
> +		if (ret) {
> +			dev_err(&spi->dev, "failed to request GPIO PDRST\n");
> +			goto error_disable_reg;
> +		}
> +		st->powerdown_gpio = pdata->gpio_pdrst;
> +	} else {
> +		st->powerdown_gpio = -1;
>  	}
>  
>  	ret = ad_sd_setup_buffer_and_trigger(indio_dev);
> @@ -212,7 +212,8 @@ static int __devinit ad7780_probe(struct spi_device *spi)
>  error_cleanup_buffer_and_trigger:
>  	ad_sd_cleanup_buffer_and_trigger(indio_dev);
>  error_free_gpio:
> -	gpio_free(pdata->gpio_pdrst);
> +	if (pdata && gpio_is_valid(pdata->gpio_pdrst))
> +		gpio_free(pdata->gpio_pdrst);
>  error_disable_reg:
>  	if (!IS_ERR(st->reg))
>  		regulator_disable(st->reg);
> @@ -233,7 +234,9 @@ static int __devexit ad7780_remove(struct spi_device *spi)
>  	iio_device_unregister(indio_dev);
>  	ad_sd_cleanup_buffer_and_trigger(indio_dev);
>  
> -	gpio_free(st->powerdown_gpio);
> +	if (gpio_is_valid(st->powerdown_gpio))
> +		gpio_free(st->powerdown_gpio);
> +
>  	if (!IS_ERR(st->reg)) {
>  		regulator_disable(st->reg);
>  		regulator_put(st->reg);
> 

      parent reply	other threads:[~2012-09-22  9:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-21 13:29 [PATCH 1/2] staging:iio:ad7780: Make powerdown GPIO optional Lars-Peter Clausen
2012-09-21 13:29 ` [PATCH 2/2] staging:iio:ad7780: Add support for the ad7170/ad7171 Lars-Peter Clausen
2012-09-22  9:26   ` Jonathan Cameron
2012-09-22  9:25 ` Jonathan Cameron [this message]

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=505D8420.4020703@kernel.org \
    --to=jic23@kernel.org \
    --cc=drivers@analog.com \
    --cc=jic23@cam.ac.uk \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    /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.