All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Berzl <stefanberzl@gmail.com>
To: jikos@kernel.org
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Stefan Berzl <stefanberzl@gmail.com>
Subject: [PATCH] HID: uclogic: Remove useless loop
Date: Mon,  1 Apr 2024 02:47:57 +0200	[thread overview]
Message-ID: <20240401004757.22708-1-stefanberzl@gmail.com> (raw)

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 --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index ad74cbc9a0aa..a56f4de216de 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 subreport ID, and restart */
+			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;
-- 
2.43.0


             reply	other threads:[~2024-04-01  0:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-01  0:47 Stefan Berzl [this message]
2024-04-12 15:52 ` [PATCH] HID: uclogic: Remove useless loop Jiri Kosina
2024-04-18 13:31   ` Stefan Berzl
2024-04-18 17:04     ` Nikolai Kondrashov
2024-04-18 18:46       ` Stefan Berzl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240401004757.22708-1-stefanberzl@gmail.com \
    --to=stefanberzl@gmail.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.