Skip to contentSkip to conversation

iio: mxs-lradc: Remove useless check in read_raw

PATCH Applied Marek Vasut 4 participants 4 messages Jul 3, 2013 – Jul 6, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 iio: mxs-lradc: Remove useless check in read_raw

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

Cc Jonathan Cameron <[email protected]>
Cc Fabio Estevam <[email protected]>
---
 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.

drivers/staging/iio/adc/mxs-lradc.c +0 -7
index d92c97a..c318eb6 100644
@@ -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
Signature · 1 line
1.7.10.4
Tested-by on v2 1/1
#1 lore raw
Quoted 10 lines · Marek Vasut

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

Cc Jonathan Cameron <[email protected]>
Cc Fabio Estevam <[email protected]>

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

#2 lore raw
Quoted 8 lines · Otavio Salvador
Quoted 7 lines · Marek Vasut

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

Quoted 5 lines
Quoted 3 lines
Cc Jonathan Cameron <[email protected]>
Cc Fabio Estevam <[email protected]>

Best regards,
--
Hector Palacios

maintainer Applied
#3 lore raw
In reply to Marek Vasut
Quoted 10 lines · Marek Vasut

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

Cc Jonathan Cameron <[email protected]>
Cc Fabio Estevam <[email protected]>

Applied to the fixes-togreg branch of iio.git.

Thanks,

Quoted 33 lines
---
 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.

drivers/staging/iio/adc/mxs-lradc.c +0 -7
index d92c97a..c318eb6 100644
@@ -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