linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] input: touchscreen: mxs-lradc: || vs && typos
@ 2017-04-26 21:04 Dan Carpenter
  2017-04-26 21:12 ` Dmitry Torokhov
  2017-04-27  8:03 ` Lee Jones
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2017-04-26 21:04 UTC (permalink / raw)
  To: Dmitry Torokhov, Ksenija Stanojevic
  Cc: Lee Jones, Marek Vasut, linux-input, kernel-janitors, linux-iio

These tests are meaningless as is because "adapt" can't possibly be both
less than 1 and greater than 32.

Fixes: d81ca730e3e4 ("input: touchscreen: mxs-lradc: Add support for touchscreen")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/input/touchscreen/mxs-lradc-ts.c b/drivers/input/touchscreen/mxs-lradc-ts.c
index ff9cda29d9a0..369ef83234ef 100644
--- a/drivers/input/touchscreen/mxs-lradc-ts.c
+++ b/drivers/input/touchscreen/mxs-lradc-ts.c
@@ -642,7 +642,7 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev)
 	if (of_property_read_u32(node, "fsl,ave-ctrl", &adapt)) {
 		ts->over_sample_cnt = 4;
 	} else {
-		if (adapt >= 1 || adapt <= 32) {
+		if (adapt >= 1 && adapt <= 32) {
 			ts->over_sample_cnt = adapt;
 		} else {
 			dev_err(ts->dev, "Invalid sample count (%u)\n",
@@ -654,7 +654,7 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev)
 	if (of_property_read_u32(node, "fsl,ave-delay", &adapt)) {
 		ts->over_sample_delay = 2;
 	} else {
-		if (adapt >= 2 || adapt <= LRADC_DELAY_DELAY_MASK + 1) {
+		if (adapt >= 2 && adapt <= LRADC_DELAY_DELAY_MASK + 1) {
 			ts->over_sample_delay = adapt;
 		} else {
 			dev_err(ts->dev, "Invalid sample delay (%u)\n",
@@ -666,7 +666,7 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev)
 	if (of_property_read_u32(node, "fsl,settling", &adapt)) {
 		ts->settling_delay = 10;
 	} else {
-		if (adapt >= 1 || adapt <= LRADC_DELAY_DELAY_MASK) {
+		if (adapt >= 1 && adapt <= LRADC_DELAY_DELAY_MASK) {
 			ts->settling_delay = adapt;
 		} else {
 			dev_err(ts->dev, "Invalid settling delay (%u)\n",

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

* Re: [PATCH 2/2] input: touchscreen: mxs-lradc: || vs && typos
  2017-04-26 21:04 [PATCH 2/2] input: touchscreen: mxs-lradc: || vs && typos Dan Carpenter
@ 2017-04-26 21:12 ` Dmitry Torokhov
  2017-04-27  8:03 ` Lee Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2017-04-26 21:12 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Ksenija Stanojevic, Lee Jones, Marek Vasut, linux-input,
	kernel-janitors, linux-iio

On Thu, Apr 27, 2017 at 12:04:31AM +0300, Dan Carpenter wrote:
> These tests are meaningless as is because "adapt" can't possibly be both
> less than 1 and greater than 32.
> 
> Fixes: d81ca730e3e4 ("input: touchscreen: mxs-lradc: Add support for touchscreen")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Lee, could you take this one?

> diff --git a/drivers/input/touchscreen/mxs-lradc-ts.c b/drivers/input/touchscreen/mxs-lradc-ts.c
> index ff9cda29d9a0..369ef83234ef 100644
> --- a/drivers/input/touchscreen/mxs-lradc-ts.c
> +++ b/drivers/input/touchscreen/mxs-lradc-ts.c
> @@ -642,7 +642,7 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev)
>  	if (of_property_read_u32(node, "fsl,ave-ctrl", &adapt)) {
>  		ts->over_sample_cnt = 4;
>  	} else {
> -		if (adapt >= 1 || adapt <= 32) {
> +		if (adapt >= 1 && adapt <= 32) {
>  			ts->over_sample_cnt = adapt;
>  		} else {
>  			dev_err(ts->dev, "Invalid sample count (%u)\n",
> @@ -654,7 +654,7 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev)
>  	if (of_property_read_u32(node, "fsl,ave-delay", &adapt)) {
>  		ts->over_sample_delay = 2;
>  	} else {
> -		if (adapt >= 2 || adapt <= LRADC_DELAY_DELAY_MASK + 1) {
> +		if (adapt >= 2 && adapt <= LRADC_DELAY_DELAY_MASK + 1) {
>  			ts->over_sample_delay = adapt;
>  		} else {
>  			dev_err(ts->dev, "Invalid sample delay (%u)\n",
> @@ -666,7 +666,7 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev)
>  	if (of_property_read_u32(node, "fsl,settling", &adapt)) {
>  		ts->settling_delay = 10;
>  	} else {
> -		if (adapt >= 1 || adapt <= LRADC_DELAY_DELAY_MASK) {
> +		if (adapt >= 1 && adapt <= LRADC_DELAY_DELAY_MASK) {
>  			ts->settling_delay = adapt;
>  		} else {
>  			dev_err(ts->dev, "Invalid settling delay (%u)\n",

Thanks.

-- 
Dmitry

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

* Re: [PATCH 2/2] input: touchscreen: mxs-lradc: || vs && typos
  2017-04-26 21:04 [PATCH 2/2] input: touchscreen: mxs-lradc: || vs && typos Dan Carpenter
  2017-04-26 21:12 ` Dmitry Torokhov
@ 2017-04-27  8:03 ` Lee Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Lee Jones @ 2017-04-27  8:03 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Dmitry Torokhov, Ksenija Stanojevic, Marek Vasut,
	linux-input-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA

On Thu, 27 Apr 2017, Dan Carpenter wrote:

> These tests are meaningless as is because "adapt" can't possibly be both
> less than 1 and greater than 32.
> 
> Fixes: d81ca730e3e4 ("input: touchscreen: mxs-lradc: Add support for touchscreen")
> Signed-off-by: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

Applied, thanks.

> diff --git a/drivers/input/touchscreen/mxs-lradc-ts.c b/drivers/input/touchscreen/mxs-lradc-ts.c
> index ff9cda29d9a0..369ef83234ef 100644
> --- a/drivers/input/touchscreen/mxs-lradc-ts.c
> +++ b/drivers/input/touchscreen/mxs-lradc-ts.c
> @@ -642,7 +642,7 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev)
>  	if (of_property_read_u32(node, "fsl,ave-ctrl", &adapt)) {
>  		ts->over_sample_cnt = 4;
>  	} else {
> -		if (adapt >= 1 || adapt <= 32) {
> +		if (adapt >= 1 && adapt <= 32) {
>  			ts->over_sample_cnt = adapt;
>  		} else {
>  			dev_err(ts->dev, "Invalid sample count (%u)\n",
> @@ -654,7 +654,7 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev)
>  	if (of_property_read_u32(node, "fsl,ave-delay", &adapt)) {
>  		ts->over_sample_delay = 2;
>  	} else {
> -		if (adapt >= 2 || adapt <= LRADC_DELAY_DELAY_MASK + 1) {
> +		if (adapt >= 2 && adapt <= LRADC_DELAY_DELAY_MASK + 1) {
>  			ts->over_sample_delay = adapt;
>  		} else {
>  			dev_err(ts->dev, "Invalid sample delay (%u)\n",
> @@ -666,7 +666,7 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev)
>  	if (of_property_read_u32(node, "fsl,settling", &adapt)) {
>  		ts->settling_delay = 10;
>  	} else {
> -		if (adapt >= 1 || adapt <= LRADC_DELAY_DELAY_MASK) {
> +		if (adapt >= 1 && adapt <= LRADC_DELAY_DELAY_MASK) {
>  			ts->settling_delay = adapt;
>  		} else {
>  			dev_err(ts->dev, "Invalid settling delay (%u)\n",

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

end of thread, other threads:[~2017-04-27  8:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-26 21:04 [PATCH 2/2] input: touchscreen: mxs-lradc: || vs && typos Dan Carpenter
2017-04-26 21:12 ` Dmitry Torokhov
2017-04-27  8:03 ` Lee Jones

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