All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Fabrice Gasnier <fabrice.gasnier@st.com>
Cc: <benjamin.gaignard@linaro.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <mcoquelin.stm32@gmail.com>,
	<alexandre.torgue@st.com>, <benjamin.gaignard@st.com>,
	<linux-iio@vger.kernel.org>, <lars@metafoo.de>, <knaack.h@gmx.de>,
	<pmeerw@pmeerw.net>
Subject: Re: [PATCH 1/4] iio: trigger: stm32-timer: fix quadrature mode get routine
Date: Sun, 30 Jul 2017 14:43:50 +0100	[thread overview]
Message-ID: <20170730144350.17095cf1@kernel.org> (raw)
In-Reply-To: <1501172340-8448-2-git-send-email-fabrice.gasnier@st.com>

On Thu, 27 Jul 2017 18:18:57 +0200
Fabrice Gasnier <fabrice.gasnier@st.com> wrote:

> Fixes: 4adec7da0536 ("iio: stm32 trigger: Add quadrature encoder device")
> 
> SMS bitfiled is mode + 1. After reset, upon boot, SMS = 0. When reading
> from sysfs, stm32_get_quadrature_mode() returns -1 (e.g. -EPERM) which is
> wrong error code here. So, check SMS bitfiled matches valid encoder mode,
> or return -EINVAL.
> 
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan
> ---
>  drivers/iio/trigger/stm32-timer-trigger.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/trigger/stm32-timer-trigger.c b/drivers/iio/trigger/stm32-timer-trigger.c
> index d22bc56..6aa73d6 100644
> --- a/drivers/iio/trigger/stm32-timer-trigger.c
> +++ b/drivers/iio/trigger/stm32-timer-trigger.c
> @@ -571,11 +571,14 @@ static int stm32_get_quadrature_mode(struct iio_dev *indio_dev,
>  {
>  	struct stm32_timer_trigger *priv = iio_priv(indio_dev);
>  	u32 smcr;
> +	int mode;
>  
>  	regmap_read(priv->regmap, TIM_SMCR, &smcr);
> -	smcr &= TIM_SMCR_SMS;
> +	mode = (smcr & TIM_SMCR_SMS) - 1;
> +	if ((mode < 0) || (mode > ARRAY_SIZE(stm32_quadrature_modes)))
> +		return -EINVAL;
>  
> -	return smcr - 1;
> +	return mode;
>  }
>  
>  static const struct iio_enum stm32_quadrature_mode_enum = {


WARNING: multiple messages have this Message-ID (diff)
From: jic23@kernel.org (Jonathan Cameron)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/4] iio: trigger: stm32-timer: fix quadrature mode get routine
Date: Sun, 30 Jul 2017 14:43:50 +0100	[thread overview]
Message-ID: <20170730144350.17095cf1@kernel.org> (raw)
In-Reply-To: <1501172340-8448-2-git-send-email-fabrice.gasnier@st.com>

On Thu, 27 Jul 2017 18:18:57 +0200
Fabrice Gasnier <fabrice.gasnier@st.com> wrote:

> Fixes: 4adec7da0536 ("iio: stm32 trigger: Add quadrature encoder device")
> 
> SMS bitfiled is mode + 1. After reset, upon boot, SMS = 0. When reading
> from sysfs, stm32_get_quadrature_mode() returns -1 (e.g. -EPERM) which is
> wrong error code here. So, check SMS bitfiled matches valid encoder mode,
> or return -EINVAL.
> 
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan
> ---
>  drivers/iio/trigger/stm32-timer-trigger.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/trigger/stm32-timer-trigger.c b/drivers/iio/trigger/stm32-timer-trigger.c
> index d22bc56..6aa73d6 100644
> --- a/drivers/iio/trigger/stm32-timer-trigger.c
> +++ b/drivers/iio/trigger/stm32-timer-trigger.c
> @@ -571,11 +571,14 @@ static int stm32_get_quadrature_mode(struct iio_dev *indio_dev,
>  {
>  	struct stm32_timer_trigger *priv = iio_priv(indio_dev);
>  	u32 smcr;
> +	int mode;
>  
>  	regmap_read(priv->regmap, TIM_SMCR, &smcr);
> -	smcr &= TIM_SMCR_SMS;
> +	mode = (smcr & TIM_SMCR_SMS) - 1;
> +	if ((mode < 0) || (mode > ARRAY_SIZE(stm32_quadrature_modes)))
> +		return -EINVAL;
>  
> -	return smcr - 1;
> +	return mode;
>  }
>  
>  static const struct iio_enum stm32_quadrature_mode_enum = {

  reply	other threads:[~2017-07-30 13:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-27 16:18 [PATCH 0/4] iio: trigger: stm32-timer fixes Fabrice Gasnier
2017-07-27 16:18 ` Fabrice Gasnier
2017-07-27 16:18 ` [PATCH 1/4] iio: trigger: stm32-timer: fix quadrature mode get routine Fabrice Gasnier
2017-07-27 16:18   ` Fabrice Gasnier
2017-07-30 13:43   ` Jonathan Cameron [this message]
2017-07-30 13:43     ` Jonathan Cameron
2017-07-27 16:18 ` [PATCH 2/4] iio: trigger: stm32-timer: fix write_raw return value Fabrice Gasnier
2017-07-27 16:18   ` Fabrice Gasnier
2017-07-30 13:45   ` Jonathan Cameron
2017-07-30 13:45     ` Jonathan Cameron
2017-07-27 16:18 ` [PATCH 3/4] iio: trigger: stm32-timer: fix get/set down count direction Fabrice Gasnier
2017-07-27 16:18   ` Fabrice Gasnier
2017-07-30 13:46   ` Jonathan Cameron
2017-07-30 13:46     ` Jonathan Cameron
2017-07-27 16:19 ` [PATCH 4/4] iio: trigger: stm32-timer: add enable attribute Fabrice Gasnier
2017-07-27 16:19   ` Fabrice Gasnier
2017-07-30 13:49   ` Jonathan Cameron
2017-07-30 13:49     ` Jonathan Cameron
2017-07-28  8:14 ` [PATCH 0/4] iio: trigger: stm32-timer fixes Benjamin Gaignard
2017-07-28  8:14   ` Benjamin Gaignard
2017-07-28  8:14   ` Benjamin Gaignard

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=20170730144350.17095cf1@kernel.org \
    --to=jic23@kernel.org \
    --cc=alexandre.torgue@st.com \
    --cc=benjamin.gaignard@linaro.org \
    --cc=benjamin.gaignard@st.com \
    --cc=fabrice.gasnier@st.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcoquelin.stm32@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 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.