diff mbox series

[v2] HID: uclogic: Remove useless loop

Message ID 20240418194051.15852-1-stefanberzl@gmail.com (mailing list archive)
State New
Delegated to: Jiri Kosina
Headers show
Series [v2] HID: uclogic: Remove useless loop | expand

Commit Message

Stefan Berzl April 18, 2024, 7:40 p.m. UTC
The while in question does nothing except provide the possibility
to have an infinite loop in case the subreport id is actually the same
as the pen id.

Signed-off-by: Stefan Berzl <stefanberzl@gmail.com>
---
 drivers/hid/hid-uclogic-core.c | 55 ++++++++++++++++------------------
 1 file changed, 25 insertions(+), 30 deletions(-)
diff mbox series

Patch

diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index ad74cbc9a0aa..8219d3dc9de4 100644
--- a/drivers/hid/hid-uclogic-core.c
+++ b/drivers/hid/hid-uclogic-core.c
@@ -431,40 +431,35 @@  static int uclogic_raw_event(struct hid_device *hdev,
 	if (uclogic_exec_event_hook(params, data, size))
 		return 0;
 
-	while (true) {
-		/* Tweak pen reports, if necessary */
-		if ((report_id == params->pen.id) && (size >= 2)) {
-			subreport_list_end =
-				params->pen.subreport_list +
-				ARRAY_SIZE(params->pen.subreport_list);
-			/* Try to match a subreport */
-			for (subreport = params->pen.subreport_list;
-			     subreport < subreport_list_end; subreport++) {
-				if (subreport->value != 0 &&
-				    subreport->value == data[1]) {
-					break;
-				}
-			}
-			/* If a subreport matched */
-			if (subreport < subreport_list_end) {
-				/* Change to subreport ID, and restart */
-				report_id = data[0] = subreport->id;
-				continue;
-			} else {
-				return uclogic_raw_event_pen(drvdata, data, size);
+	/* Tweak pen reports, if necessary */
+	if ((report_id == params->pen.id) && (size >= 2)) {
+		subreport_list_end =
+			params->pen.subreport_list +
+			ARRAY_SIZE(params->pen.subreport_list);
+		/* Try to match a subreport */
+		for (subreport = params->pen.subreport_list;
+		     subreport < subreport_list_end; subreport++) {
+			if (subreport->value != 0 &&
+			    subreport->value == data[1]) {
+				break;
 			}
 		}
-
-		/* Tweak frame control reports, if necessary */
-		for (i = 0; i < ARRAY_SIZE(params->frame_list); i++) {
-			if (report_id == params->frame_list[i].id) {
-				return uclogic_raw_event_frame(
-					drvdata, &params->frame_list[i],
-					data, size);
-			}
+		/* If a subreport matched */
+		if (subreport < subreport_list_end) {
+			/* Change to the (non-pen) subreport ID and continue */
+			report_id = data[0] = subreport->id;
+		} else {
+			return uclogic_raw_event_pen(drvdata, data, size);
 		}
+	}
 
-		break;
+	/* Tweak frame control reports, if necessary */
+	for (i = 0; i < ARRAY_SIZE(params->frame_list); i++) {
+		if (report_id == params->frame_list[i].id) {
+			return uclogic_raw_event_frame(
+				drvdata, &params->frame_list[i],
+				data, size);
+		}
 	}
 
 	return 0;