LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] input: touchscreen: replace conditional statement with max()
@ 2021-08-03  0:38 Salah Triki
  2021-08-04  9:45 ` Johan Hovold
  0 siblings, 1 reply; 2+ messages in thread
From: Salah Triki @ 2021-08-03  0:38 UTC (permalink / raw)
  To: Dmitry Torokhov, Salah Triki, Johan Hovold, Lee Jones, gregkh
  Cc: linux-input, linux-kernel

Replace conditional statement with max() in order to make code cleaner.
Issue found by coccinelle.

Signed-off-by: Salah Triki <salah.triki@gmail.com>
---
 drivers/input/touchscreen/usbtouchscreen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index 43c521f50c85..69f36d4f6cea 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -269,7 +269,7 @@ static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
 
 	tmp = tmp - 0xA000;
 	dev->touch = (tmp > 0);
-	dev->press = (tmp > 0 ? tmp : 0);
+	dev->press = max(tmp, 0);
 
 	return 1;
 }
-- 
2.25.1


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

* Re: [PATCH] input: touchscreen: replace conditional statement with max()
  2021-08-03  0:38 [PATCH] input: touchscreen: replace conditional statement with max() Salah Triki
@ 2021-08-04  9:45 ` Johan Hovold
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2021-08-04  9:45 UTC (permalink / raw)
  To: Salah Triki; +Cc: Dmitry Torokhov, Lee Jones, gregkh, linux-input, linux-kernel

On Tue, Aug 03, 2021 at 01:38:57AM +0100, Salah Triki wrote:
> Replace conditional statement with max() in order to make code cleaner.
> Issue found by coccinelle.
> 
> Signed-off-by: Salah Triki <salah.triki@gmail.com>
> ---
>  drivers/input/touchscreen/usbtouchscreen.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
> index 43c521f50c85..69f36d4f6cea 100644
> --- a/drivers/input/touchscreen/usbtouchscreen.c
> +++ b/drivers/input/touchscreen/usbtouchscreen.c
> @@ -269,7 +269,7 @@ static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
>  
>  	tmp = tmp - 0xA000;
>  	dev->touch = (tmp > 0);
> -	dev->press = (tmp > 0 ? tmp : 0);
> +	dev->press = max(tmp, 0);

I'm afraid that like the related patch you've posted elsewhere, this not
an improvement either.

>  
>  	return 1;
>  }

Johan

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

end of thread, other threads:[~2021-08-04  9:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-03  0:38 [PATCH] input: touchscreen: replace conditional statement with max() Salah Triki
2021-08-04  9:45 ` Johan Hovold

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