Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp223lqp; Fri, 12 Apr 2024 08:52:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXC1HzUzXkjpKw81wv9WxPbrdK1CPUHPbc1tJAIBhHT+VIIJyw0gAj6ohGs6jzUbPgWozc8t+CneSwBGptcpy70aVk6u+hp4xqBklMSlQ== X-Google-Smtp-Source: AGHT+IEyIN4bCfrAx3GALZ7eFMHruxUCXbXwnE7NlrqSDebaVlLyFottH2cewaeqOZw2exbE167I X-Received: by 2002:a0c:f749:0:b0:69b:4ec9:5232 with SMTP id e9-20020a0cf749000000b0069b4ec95232mr7247257qvo.26.1712937141437; Fri, 12 Apr 2024 08:52:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712937141; cv=pass; d=google.com; s=arc-20160816; b=ksWcXOTfZTH5sAmTZePA6UzPJdefUt13IGNPISwDLkVn/TBnjc/hhxNuuk+xGBzKJY hmVFArhbcDqnPQIOD8j5DCZHzcVXyEXLi/bLB4E2LMILobxeBJGVZ8mILLVi4pc4vSYt mQBIer7RsS3Bwp0640YVyOeXUSC80tQjEU677gyomA9H+zEWkwZEtkcRFR274N2O1ZKT TYfMyuhpLbTNWwy9Q0SCu3ZNA8NZreoT7AcnTFvyXvGpTFkdaFan0CpCmz1IA9uyoXuG AoUAKpw93M547jPfTYqxxtJwlVK464HDJQu1aWLgPmeOIjqE0ZsOtqlJi0qLLU0UFFy0 X0aQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:references:message-id:in-reply-to:subject:cc:to:from :date:dkim-signature; bh=jBHbRvrCVuKoujdBwyCLb90KCu05Y3oHRNkk6rZqXF8=; fh=f45QJYFSHmEnk8v9x41dk60Txqq1KXRngaS3YdRjgK8=; b=Orpc0SV0nB3mU7/kRVhOGHBu/qJu6K9mgW82ATXRJtX63XEGd1iy12P+DbJZRM9h// xWD7VLcjil/09hAA/1qhMBs5kyj0nTrvH18P/8mTPbWQDzt4jP4Y4Na1cmxTlq/RS7FF 7aconKuSaFVUrZCptGR+24rZmiak3zXubWsEun0GnvUvlimMRKAb7O4u7qb8Um1ziMji 103FNiDIQmEVxJXOH9kFtmKSWuG1FiSJTcz25E04npaA5+AoHw4d6zOq9vW8aUzz/ENt 0Ebb83ZTmXbGMHgwuKqF/z09ZiAhcl9Fx8ZLNpokOdbZCeiqw2rHHz3Zj7pf42p4xE1z v+Ng==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SDGnhZZS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-142978-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142978-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id n13-20020a0cbe8d000000b0069b50a7bff3si3027105qvi.513.2024.04.12.08.52.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 08:52:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142978-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SDGnhZZS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-142978-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142978-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 54A6B1C22C7B for ; Fri, 12 Apr 2024 15:52:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C754B14882F; Fri, 12 Apr 2024 15:52:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SDGnhZZS" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9E6A146A75; Fri, 12 Apr 2024 15:52:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712937132; cv=none; b=dPcDeVQP3K0ybSk5aO+8knfK0h8st/gIOtcpBWBbhgzHqxb1w6ohFODKXO8+mdIp1EGkxrSrOaoxvTXI8H7b6XCHyV+PmxoRSNu50QZP0NE9mD4abY5ZYToM4R8k7bEK0C3fy/zDNJ7nvOl86uvo8OFnTRm5zyrfWCheATjJ6cs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712937132; c=relaxed/simple; bh=n3FhrSSGNYinFWKOLI9XEyvtmcy6wfy49qe1cma28H4=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=eCtXzx6Fpe0/wUwnLpXeaHwxH7tt37IMQSa34dPGfQA53pDd9MydbQYfHyps7ZHxQLcWaHi9q8Up1G9rQq6RX/ygeYFs9/x/9TMacINvgXZImJ0OTZIIs4Dbcf8+IS6Pqf4Mn1eLUoQKBweBZ941Kh1azPZ0AXtsxonkq/c43zg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SDGnhZZS; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23881C3277B; Fri, 12 Apr 2024 15:52:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712937131; bh=n3FhrSSGNYinFWKOLI9XEyvtmcy6wfy49qe1cma28H4=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=SDGnhZZS5hf5QwVfBTJ6uevszB2ptzmTwOips9QfzlEs1pqGzbzioFNWpFk/T6KdY dcXdNeRze7eBE84N2WBpgYuzDAJjg+BphAPJssccka1Ml+DcJEp+X4N6x3KGweOicI +mZTLTMdmEcIpnEFx3zQ8KjPA9+hFIFNqdKZaKFrpgiGy4lvGBcamaV2/bDQ8Xt14Q EU8R0M9oDpqcLaCobgvEoGDC7bjIaQ6UAg/TM87nLBrk1rtUoGSKoPwK36lYMk5bIl hYYMhQlVFgOcW/w2YBAHkb3speBI66/06v4LxVFv1PGhAiScXTco+l1MN5x0Y5w+AW DQL6kjT+QLPzA== Date: Fri, 12 Apr 2024 17:52:09 +0200 (CEST) From: Jiri Kosina To: Stefan Berzl cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Nikolai Kondrashov Subject: Re: [PATCH] HID: uclogic: Remove useless loop In-Reply-To: <20240401004757.22708-1-stefanberzl@gmail.com> Message-ID: References: <20240401004757.22708-1-stefanberzl@gmail.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII On Mon, 1 Apr 2024, Stefan Berzl wrote: > 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 Let me CC Nicolai, the author of the code of question (8b013098be2c9). > --- > 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, ¶ms->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, ¶ms->frame_list[i], > + data, size); > + } > } > > return 0; > -- > 2.43.0 > -- Jiri Kosina SUSE Labs