linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<nuno.sa@analog.com>
Subject: Re: [PATCH v2 4/9] iio: imu: adis: add unlocked __adis_initial_startup()
Date: Fri, 14 Feb 2020 14:31:37 +0000	[thread overview]
Message-ID: <20200214143137.72e995b3@archlinux> (raw)
In-Reply-To: <20200210132606.9315-4-alexandru.ardelean@analog.com>

On Mon, 10 Feb 2020 15:26:01 +0200
Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:

> This change splits the __adis_initial_startup() away from
> adis_initial_startup(). The unlocked version can be used in certain calls
> during probe, where races won't happen since the ADIS driver may not be
> registered yet with IIO.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Applied.  Thanks,

Jonathan

> ---
>  drivers/iio/imu/adis.c       | 14 ++++----------
>  include/linux/iio/imu/adis.h | 13 ++++++++++++-
>  2 files changed, 16 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/iio/imu/adis.c b/drivers/iio/imu/adis.c
> index 022bb54fb748..e4897dad34ab 100644
> --- a/drivers/iio/imu/adis.c
> +++ b/drivers/iio/imu/adis.c
> @@ -365,7 +365,7 @@ static int adis_self_test(struct adis *adis)
>  }
>  
>  /**
> - * adis_inital_startup() - Performs device self-test
> + * __adis_initial_startup() - Device initial setup
>   * @adis: The adis device
>   *
>   * Returns 0 if the device is operational, a negative error code otherwise.
> @@ -373,28 +373,22 @@ static int adis_self_test(struct adis *adis)
>   * This function should be called early on in the device initialization sequence
>   * to ensure that the device is in a sane and known state and that it is usable.
>   */
> -int adis_initial_startup(struct adis *adis)
> +int __adis_initial_startup(struct adis *adis)
>  {
>  	int ret;
>  
> -	mutex_lock(&adis->state_lock);
> -
>  	ret = adis_self_test(adis);
>  	if (ret) {
>  		dev_err(&adis->spi->dev, "Self-test failed, trying reset.\n");
>  		__adis_reset(adis);
>  		ret = adis_self_test(adis);
> -		if (ret) {
> +		if (ret)
>  			dev_err(&adis->spi->dev, "Second self-test failed, giving up.\n");
> -			goto out_unlock;
> -		}
>  	}
>  
> -out_unlock:
> -	mutex_unlock(&adis->state_lock);
>  	return ret;
>  }
> -EXPORT_SYMBOL_GPL(adis_initial_startup);
> +EXPORT_SYMBOL_GPL(__adis_initial_startup);
>  
>  /**
>   * adis_single_conversion() - Performs a single sample conversion
> diff --git a/include/linux/iio/imu/adis.h b/include/linux/iio/imu/adis.h
> index d2fcf45b4cef..15e75670f923 100644
> --- a/include/linux/iio/imu/adis.h
> +++ b/include/linux/iio/imu/adis.h
> @@ -297,6 +297,7 @@ static inline int adis_read_reg_32(struct adis *adis, unsigned int reg,
>  
>  int adis_enable_irq(struct adis *adis, bool enable);
>  int __adis_check_status(struct adis *adis);
> +int __adis_initial_startup(struct adis *adis);
>  
>  static inline int adis_check_status(struct adis *adis)
>  {
> @@ -309,7 +310,17 @@ static inline int adis_check_status(struct adis *adis)
>  	return ret;
>  }
>  
> -int adis_initial_startup(struct adis *adis);
> +/* locked version of __adis_initial_startup() */
> +static inline int adis_initial_startup(struct adis *adis)
> +{
> +	int ret;
> +
> +	mutex_lock(&adis->state_lock);
> +	ret = __adis_initial_startup(adis);
> +	mutex_unlock(&adis->state_lock);
> +
> +	return ret;
> +}
>  
>  int adis_single_conversion(struct iio_dev *indio_dev,
>  	const struct iio_chan_spec *chan, unsigned int error_mask,


  reply	other threads:[~2020-02-14 14:31 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-10 13:25 [PATCH v2 1/9] iio: imu: adis16480: initialize adis_data statically Alexandru Ardelean
2020-02-10 13:25 ` [PATCH v2 2/9] iio: imu: adis16400: " Alexandru Ardelean
2020-02-14 14:29   ` Jonathan Cameron
2020-02-10 13:26 ` [PATCH v2 3/9] iio: gyro: adis16136: " Alexandru Ardelean
2020-02-14 14:30   ` Jonathan Cameron
2020-02-10 13:26 ` [PATCH v2 4/9] iio: imu: adis: add unlocked __adis_initial_startup() Alexandru Ardelean
2020-02-14 14:31   ` Jonathan Cameron [this message]
2020-02-10 13:26 ` [PATCH v2 5/9] iio: imu: adis: Add self_test_reg variable Alexandru Ardelean
2020-02-14 14:33   ` Jonathan Cameron
2020-02-10 13:26 ` [PATCH v2 6/9] iio: imu: adis: Refactor adis_initial_startup Alexandru Ardelean
2020-02-14 14:39   ` Jonathan Cameron
2020-02-10 13:26 ` [PATCH v2 7/9] iio: imu: adis: add support product ID check in adis_initial_startup Alexandru Ardelean
2020-02-14 14:41   ` Jonathan Cameron
2020-02-10 13:26 ` [PATCH v2 8/9] iio: adis16480: Make use of __adis_initial_startup Alexandru Ardelean
2020-02-14 14:44   ` Jonathan Cameron
2020-02-10 13:26 ` [PATCH v2 9/9] iio: adis16460: " Alexandru Ardelean
2020-02-14 14:45   ` Jonathan Cameron
2020-02-14 14:28 ` [PATCH v2 1/9] iio: imu: adis16480: initialize adis_data statically 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=20200214143137.72e995b3@archlinux \
    --to=jic23@kernel.org \
    --cc=alexandru.ardelean@analog.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.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;
as well as URLs for NNTP newsgroup(s).