diff mbox series

input: touchscreen: replace conditional statement with max()

Message ID 20210803003857.GA1560352@pc (mailing list archive)
State Rejected
Headers show
Series input: touchscreen: replace conditional statement with max() | expand

Commit Message

Salah Triki Aug. 3, 2021, 12:38 a.m. UTC
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(-)

Comments

Johan Hovold Aug. 4, 2021, 9:45 a.m. UTC | #1
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
diff mbox series

Patch

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