linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] iio: mxs-lradc: Remove useless check in read_raw
@ 2013-07-03 21:25 Marek Vasut
  2013-07-04 20:22 ` Otavio Salvador
  2013-07-06  9:36 ` Jonathan Cameron
  0 siblings, 2 replies; 4+ messages in thread
From: Marek Vasut @ 2013-07-03 21:25 UTC (permalink / raw)
  To: linux-iio; +Cc: otavio, Marek Vasut, Jonathan Cameron, Fabio Estevam

The removed check in the read_raw implementation was always true,
therefore remove it. This also fixes a bug, by closely inspecting
the code, one can notice the iio_validate_scan_mask_onehot() will
always return 1 and therefore the subsequent condition will always
succeed, therefore making the mxs_lradc_read_raw() function always
return -EINVAL; .

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/staging/iio/adc/mxs-lradc.c |    7 -------
 1 file changed, 7 deletions(-)

V2: Update the patch description, by discussion on the ML, we found
    out this accidentally fixes a bug.

diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
index d92c97a..c318eb6 100644
--- a/drivers/staging/iio/adc/mxs-lradc.c
+++ b/drivers/staging/iio/adc/mxs-lradc.c
@@ -234,7 +234,6 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
 {
 	struct mxs_lradc *lradc = iio_priv(iio_dev);
 	int ret;
-	unsigned long mask;
 
 	if (m != IIO_CHAN_INFO_RAW)
 		return -EINVAL;
@@ -243,12 +242,6 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
 	if (chan->channel > LRADC_MAX_TOTAL_CHANS)
 		return -EINVAL;
 
-	/* Validate the channel if it doesn't intersect with reserved chans. */
-	bitmap_set(&mask, chan->channel, 1);
-	ret = iio_validate_scan_mask_onehot(iio_dev, &mask);
-	if (ret)
-		return -EINVAL;
-
 	/*
 	 * See if there is no buffered operation in progess. If there is, simply
 	 * bail out. This can be improved to support both buffered and raw IO at
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH V2] iio: mxs-lradc: Remove useless check in read_raw
  2013-07-03 21:25 [PATCH V2] iio: mxs-lradc: Remove useless check in read_raw Marek Vasut
@ 2013-07-04 20:22 ` Otavio Salvador
  2013-07-05  8:36   ` Hector Palacios
  2013-07-06  9:36 ` Jonathan Cameron
  1 sibling, 1 reply; 4+ messages in thread
From: Otavio Salvador @ 2013-07-04 20:22 UTC (permalink / raw)
  To: Marek Vasut; +Cc: linux-iio, Jonathan Cameron, Fabio Estevam

On Wed, Jul 3, 2013 at 6:25 PM, Marek Vasut <marex@denx.de> wrote:
> The removed check in the read_raw implementation was always true,
> therefore remove it. This also fixes a bug, by closely inspecting
> the code, one can notice the iio_validate_scan_mask_onehot() will
> always return 1 and therefore the subsequent condition will always
> succeed, therefore making the mxs_lradc_read_raw() function always
> return -EINVAL; .
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Jonathan Cameron <jic23@kernel.org>
> Cc: Fabio Estevam <fabio.estevam@freescale.com>

Tested-by: Otavio Salvador <otavio@ossystems.com.br>

--
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://projetos.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V2] iio: mxs-lradc: Remove useless check in read_raw
  2013-07-04 20:22 ` Otavio Salvador
@ 2013-07-05  8:36   ` Hector Palacios
  0 siblings, 0 replies; 4+ messages in thread
From: Hector Palacios @ 2013-07-05  8:36 UTC (permalink / raw)
  To: linux-iio@vger.kernel.org
  Cc: Otavio Salvador, Marek Vasut, Jonathan Cameron,
	fabio.estevam@freescale.com

On 07/04/2013 10:22 PM, Otavio Salvador wrote:
> On Wed, Jul 3, 2013 at 6:25 PM, Marek Vasut <marex-ynQEQJNshbs@public.gmane.org> wrote:
>> The removed check in the read_raw implementation was always true,
>> therefore remove it. This also fixes a bug, by closely inspecting
>> the code, one can notice the iio_validate_scan_mask_onehot() will
>> always return 1 and therefore the subsequent condition will always
>> succeed, therefore making the mxs_lradc_read_raw() function always
>> return -EINVAL; .
>>
>> Signed-off-by: Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>
>> Cc: Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
>> Cc: Fabio Estevam <fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
>
> Tested-by: Otavio Salvador <otavio-fKevB0iiKLMBZ+LybsDmbA@public.gmane.org>

Acked-by: Hector Palacios <hector.palacios@digi.com>


Best regards,
--
Hector Palacios

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V2] iio: mxs-lradc: Remove useless check in read_raw
  2013-07-03 21:25 [PATCH V2] iio: mxs-lradc: Remove useless check in read_raw Marek Vasut
  2013-07-04 20:22 ` Otavio Salvador
@ 2013-07-06  9:36 ` Jonathan Cameron
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2013-07-06  9:36 UTC (permalink / raw)
  To: Marek Vasut; +Cc: linux-iio, otavio, Fabio Estevam

On 07/03/2013 10:25 PM, Marek Vasut wrote:
> The removed check in the read_raw implementation was always true,
> therefore remove it. This also fixes a bug, by closely inspecting
> the code, one can notice the iio_validate_scan_mask_onehot() will
> always return 1 and therefore the subsequent condition will always
> succeed, therefore making the mxs_lradc_read_raw() function always
> return -EINVAL; .
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Jonathan Cameron <jic23@kernel.org>
> Cc: Fabio Estevam <fabio.estevam@freescale.com>
Applied to the fixes-togreg branch of iio.git.

Thanks,
> ---
>  drivers/staging/iio/adc/mxs-lradc.c |    7 -------
>  1 file changed, 7 deletions(-)
> 
> V2: Update the patch description, by discussion on the ML, we found
>     out this accidentally fixes a bug.
> 
> diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
> index d92c97a..c318eb6 100644
> --- a/drivers/staging/iio/adc/mxs-lradc.c
> +++ b/drivers/staging/iio/adc/mxs-lradc.c
> @@ -234,7 +234,6 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
>  {
>  	struct mxs_lradc *lradc = iio_priv(iio_dev);
>  	int ret;
> -	unsigned long mask;
>  
>  	if (m != IIO_CHAN_INFO_RAW)
>  		return -EINVAL;
> @@ -243,12 +242,6 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
>  	if (chan->channel > LRADC_MAX_TOTAL_CHANS)
>  		return -EINVAL;
>  
> -	/* Validate the channel if it doesn't intersect with reserved chans. */
> -	bitmap_set(&mask, chan->channel, 1);
> -	ret = iio_validate_scan_mask_onehot(iio_dev, &mask);
> -	if (ret)
> -		return -EINVAL;
> -
>  	/*
>  	 * See if there is no buffered operation in progess. If there is, simply
>  	 * bail out. This can be improved to support both buffered and raw IO at
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-07-06  9:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-03 21:25 [PATCH V2] iio: mxs-lradc: Remove useless check in read_raw Marek Vasut
2013-07-04 20:22 ` Otavio Salvador
2013-07-05  8:36   ` Hector Palacios
2013-07-06  9:36 ` Jonathan Cameron

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).