Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3770719ioo; Mon, 30 May 2022 09:12:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+C9GzSuFzuBGLrTXyvLIS91+Y1dwiQeYXfJ77GHC/wPtjDLnWydP+hcbQZiFg1nf29UjU X-Received: by 2002:a17:907:6e11:b0:6fe:feaa:bb04 with SMTP id sd17-20020a1709076e1100b006fefeaabb04mr31367967ejc.187.1653927133990; Mon, 30 May 2022 09:12:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653927133; cv=none; d=google.com; s=arc-20160816; b=l0viB8S5k2Nhk7uux7lA92GIl+D/cdYxuX01HI/BEM5BsvzDntlKi+Hyfz/TSgzYQk VUukJeZ/bHHq0e8x8eSSRdnHlmdAOvBksGOsttIEVXtwBCNcB2MTAObVvmrrHF+Sq8Vo U5tPUz2DUhk6m1KzmFhslAUmsKYMbuUl6d5lzkHtpRjZOtNMiFqYGDtXVpijasao5S9O dtclk/oTH4XLMF9nsX1wujewE+MfeNRfRfGVxfFS8PFINGNOZfevAlphlL50Khfhs/1F hzNddRjB1Rbsl9u6XD0VCzIbFiWT6/pKDzOy+nshIS1DlMMb/z1IoMoJ/42UKoXo7Fgg L5XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=3IqEUaHXVUti1x+VtbbIBYixMF/dH9xlsIzM142Izsk=; b=PRmAK50b3WDpMBXL29lMTU4h2co3B0skbPErJM/2MRXetuDMCAetFw8FqGTBzq06YI D63PYci7dwNAVo0DD0+BxrIFEs4NqM1PUPKfJPr8MOiLNi17w8BsY5xF0vdxpeymf4AZ 0KxWO/IGduMGH902yWKdEZiUSbSQ/hybgyNR532ZtlXz629p6xohChfOtYzQ+3sU0L3+ M8e0Ct4As9UwxkLjC1p8BqeXeuqcMXte5ywm31UPVAy7C9KmojozVAz2uti/Nl6MjdRi 3TrKav1LwsTQoqDKcTfHSPN3PG9Hn2f6lMRrkRjaKSgJDrxsodM4KG3BSZe9s5WIQipM wMXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XnI93CKr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v11-20020a170906180b00b006feb41515a7si11939588eje.857.2022.05.30.09.11.47; Mon, 30 May 2022 09:12:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XnI93CKr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231865AbiE2Vtz (ORCPT + 99 others); Sun, 29 May 2022 17:49:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230326AbiE2Vtx (ORCPT ); Sun, 29 May 2022 17:49:53 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03FAA78EF9; Sun, 29 May 2022 14:49:51 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id p19so5412664wmg.2; Sun, 29 May 2022 14:49:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:content-language:to:cc :references:from:subject:in-reply-to:content-transfer-encoding; bh=3IqEUaHXVUti1x+VtbbIBYixMF/dH9xlsIzM142Izsk=; b=XnI93CKrvklEf5VGEZl1YQAXwpLwRtBcNZjt1+tVeQ29g/wwmdKVsgOCtTkh99uvLm RgUbQJDX9zo8sSLnX7Fb02xAA6gavGSyTNoo6Ba2LnE02BQBkhd05v8wmvKg0Uufsiia xNYexS5tKEF7R2akh5g52zG2p9dLYBDN4L4khw1+PYnVPgtJASd3hjrmB3/nlDY1K++d iGvgpTpGjTizaJzf0M5eYr4kcV5uvIWTGA2LWTlrA7+ICR6X3K2DD3tzMxNtrvBOpYBl iQsv7wYArwZQjvpVtXOhbSO+QyutyVHqgNaqvgC9dadjjvbxdKMOkS3oRAKPnwWZdiNj RSwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:subject:in-reply-to :content-transfer-encoding; bh=3IqEUaHXVUti1x+VtbbIBYixMF/dH9xlsIzM142Izsk=; b=SvgChpiFtT7YNJjloe7qOEmHEs1ub0d0EE24yUwMUAKyHhqN/FQddNpJ6owgHjCgbi IUzZFjyIvM5NNZa2/jIaaXQJ7NOGyOpWGWNz2dX/MIxegR+5eAih2UGiSaHb1gFfcsUE /Ow/4rh1sjSMne9a0wE6iG141rtBvwLc+Zl8RTiJXmQRw77+AFs584SZ4Llv5iOkgyBl fuYHHSejbs4cj4+4Myay+CQCjxp6N7LCo66w0RRnFYFcdKUSDn7+QgTezDcyaVnJVutw qwDaaV+ijz2DTNepgfOeub39gevJkpuazV6EGKrbPWIGtOlUOt5WiNmKI1Gs3B5HZ8pT sjSA== X-Gm-Message-State: AOAM5324IDV6smE4YEaasWb3fD8STVS4uhO7fzy2au9Ol5HAeJ0AwNUZ o7K+MROBuiGzmgU6gSX0W9o= X-Received: by 2002:a1c:7207:0:b0:397:66ee:9d71 with SMTP id n7-20020a1c7207000000b0039766ee9d71mr16384904wmc.8.1653860989542; Sun, 29 May 2022 14:49:49 -0700 (PDT) Received: from [192.168.178.29] (ipb2196a76.dynamic.kabel-deutschland.de. [178.25.106.118]) by smtp.gmail.com with ESMTPSA id o1-20020a5d47c1000000b0020fff0ea0a3sm7288566wrc.116.2022.05.29.14.49.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 May 2022 14:49:49 -0700 (PDT) Message-ID: <17153eb3-0eb9-cc05-4b65-9c0f4e8d3c90@gmail.com> Date: Sun, 29 May 2022 23:49:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Content-Language: en-US To: =?UTF-8?B?Sm9zw6kgRXhww7NzaXRv?= , jikos@kernel.org Cc: benjamin.tissoires@redhat.com, spbnick@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220518224702.1409327-1-jose.exposito89@gmail.com> <20220518224702.1409327-4-jose.exposito89@gmail.com> From: Stefan Berzl Subject: [PATCH for-5.19/uclogic] HID: uclogic: Remove useless loop In-Reply-To: <20220518224702.1409327-4-jose.exposito89@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 c0fe66e50c58..1a6b941f3964 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -423,40 +423,35 @@ static int uclogic_raw_event(struct hid_device *hdev, if (report->type != HID_INPUT_REPORT) 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.36.1