From patchwork Tue Nov 7 10:39:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 118145 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3810434qgn; Tue, 7 Nov 2017 02:40:31 -0800 (PST) X-Google-Smtp-Source: ABhQp+SeMGaRV5mw7sIL4aiTQWPao+uMYPHih0zp8AFkDYBb9wKt0VEYSQpmeUdnSdzUJl5xsdjC X-Received: by 10.101.68.69 with SMTP id e5mr17943601pgq.282.1510051231512; Tue, 07 Nov 2017 02:40:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510051231; cv=none; d=google.com; s=arc-20160816; b=LMU72RA9hJlxhYND5RHD9KB2sw4Wuf42XIaDbkaCRBMZWUWcbFNDhcanVsEAcIBRs8 W7oE9zHQzQ3tQu22h7Kpp/dXbqvF8P140uY5YalqpaR6nV5ezkhZMXYUXsvKK98b/0MF Xo3542TfF65LZ20uwCGd4o2zWDGs3+IuWHmLofDlWB4d0YpSdlqHTkTOH/OewmgZCDO3 3gVtF9F2pa/qiBiogJj2xVwLPcGEbbGOeDm81xCCCyrdlsn2wPfxJKN4ihdIklRpivpK SdQ9GjfjDcCAeIePQglTgjifoONLb9q+ScC7nxBE6NmbLIYf+mZfTDzlhRW3phj91ja2 oINQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Y3FfHTCD/8HpbPZeKyM1h1sjdoOh2fFIEnfHZt4gASc=; b=iIlrqZg87MXaqccYbpUs1cv5PvUtC7bWgkyB8FiVfnf9Krm/maamaWuls9XCwmggG7 +tINp92x7vb9yMlgw31U+FMbhGApN+9ABYnru8Z3IoDn8mdLg0Y+Z5tEBvi9At3IWxaH frvL/XoQqoJxeBD7Zl5lHHIQ8/wX5+uPW/3nWnOqMxDNqKKUU5aBL3UTwgTbzp1pBpKy SGRcvhgGXs+9CGoTFqWs7UbsifgIQD4uhqMyRLlqkViL9YdE2kIsNlxoDrfTfFoRdA4u aa7hUCjOhBgQ07F4gZ2Qia4cvY4o0w/1rl8GunmDmpq9/XaHWchgCUg6mGFFyr/Haojx HBRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s19si863845plp.458.2017.11.07.02.40.31; Tue, 07 Nov 2017 02:40:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757136AbdKGKk2 (ORCPT + 26 others); Tue, 7 Nov 2017 05:40:28 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:51067 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757119AbdKGKkX (ORCPT ); Tue, 7 Nov 2017 05:40:23 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.145]) with ESMTPA (Nemesis) id 0MWRtC-1ejgLx2whu-00XbiV; Tue, 07 Nov 2017 11:40:11 +0100 From: Arnd Bergmann To: Valentina Manea , Shuah Khan , Greg Kroah-Hartman Cc: Arnd Bergmann , Krzysztof Opasiak , Johan Hovold , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] usbip: fix off-by-one frame number calculation Date: Tue, 7 Nov 2017 11:39:56 +0100 Message-Id: <20171107104010.2884193-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:TxQacLp55x7jhRYC8cT/3bd4g/andhnLCNOrNuqw2hxsecqWCwH dRtBRsALJlAJIrXirEsHqm3hAQ57uHAUeXwQJR+UCKX1TTSLpnfhx1QNtlJW+dzgD3ZOMck v1vyRuowsFaCCqacFdlyJGe6WUd5PhX1kaFN7yt2F+rMdQ0dpafTLVANfNerXI0D1OmNJIE E3aE3ni/viiQuySnmifIA== X-UI-Out-Filterresults: notjunk:1; V01:K0:OiNH6YCWpWU=:1upv3CwE2wpkjufpyrjja2 2IE5nzjJjUS3oBPsVXi7eoC154K5bjaYTM9VY5ZfzVg/fp+eMNCbSoUMHNwG0qrpXv0BDNE6W vmiNIiwoq99+yImYZzRsdGttEYE5mYAc44IGU+1vCH5k3Mn5KlO5wq1VskVCtPwKz0puK0Suf Fl4oa0u1ILPWQmjYNgsO8r2kRs4xQklpHb07UxxCxQn2Ik1wwIStlVz0QoZRZleJkzZXvjpvm CTxwMvbMar/UkzrlRyaQMqKf7VjJagUujqjczdhaxyl9pwIkVr4JzLo0kUFXkp3G7gUSwSGy0 uSB/EGxxwvvwOGFc0paDM2fJ6+jWjLJryTx40u+swTyE2Ng57QNxLdV3pdHGHTwXPTjTG38UU pSQ9c9oqLw97xR161q7tWUzvt6nsDBs4/pBkovBX8A0uWIIJVczHa8uTp/rqlHIC3hGNVzXhX wnk8Zz8bKUEsdOBBPcmE/mzaW8VNNV4ZSp1zCcoLxZii8f0ddDhDVUnZptcrG9a8DVvFj/m2A sT0MNg1dj4ICglCVWXe2fEIjxnc0OTxGOanN+Mh7OusSWxJvpc9uWE6H08ISfBk1y1dIIRwyv pisbpqyKh97SQRsp+H5poxYhMsDEMwTFwq3kNXl7wCr22OCaYTgyHI/qqm+IaNEoU2m8K5qaK SJaPkC2/Zw2Jf+1Im/isdIe+OgcOSwZXjUwjJ/OBarWnyJeAbXThva57JM4JJ0T7DPsXHo/5M /H1luS1Dnp6H1VhsEhU1q8IRsLf1bJatwyjCPQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org vgadget_get_frame returns a frame number from 0 to 2046, which may require an expensive division operation to wrap at one lower than the usual number. I can't see any reason for this, and all other drivers wrap at a power-of-two number. My best explanation is that it was a simple typo, so I'm changing the % modulo operator into a cheaper bitmask that the other drivers use, to make it wrap after 0x7ff rather than before it. Signed-off-by: Arnd Bergmann --- drivers/usb/usbip/vudc_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.0 Reviewed-by: Krzysztof Opasiak Acked-by: Shuah Khan diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c index 0c07348820ea..16fb4f85a6f6 100644 --- a/drivers/usb/usbip/vudc_dev.c +++ b/drivers/usb/usbip/vudc_dev.c @@ -145,7 +145,7 @@ static int vgadget_get_frame(struct usb_gadget *_gadget) do_gettimeofday(&now); return ((now.tv_sec - udc->start_time.tv_sec) * 1000 + (now.tv_usec - udc->start_time.tv_usec) / 1000) - % 0x7FF; + & 0x7FF; } static int vgadget_set_selfpowered(struct usb_gadget *_gadget, int value)