Skip to contentSkip to conversation

input: touchscreen: replace conditional statement with max()

PATCH In review Salah Triki 2 participants 2 messages Aug 3, 2021 – Aug 4, 2021

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

PATCH 1/1 input: touchscreen: replace conditional statement with max()

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

---
 drivers/input/touchscreen/usbtouchscreen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/usbtouchscreen.c +1 -1
index 43c521f50c85..69f36d4f6cea 100644
@@ -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;
 }
Signature · 1 line
2.25.1
#1 lore raw
Quoted 13 lines · Salah Triki

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

---
 drivers/input/touchscreen/usbtouchscreen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/usbtouchscreen.c +0 -0
index 43c521f50c85..69f36d4f6cea 100644

drivers/input/touchscreen/usbtouchscreen.c static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt) · line 272

Quoted 5 lines
drivers/input/touchscreen/usbtouchscreen.c +1 -1
@@ -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.

drivers/input/touchscreen/usbtouchscreen.c static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt) · line 275

Quoted 3 lines
drivers/input/touchscreen/usbtouchscreen.c +0 -0
 	return 1;
 }

Johan