From: Arnd Bergmann <arnd@arndb.de>
To: Valentina Manea <valentina.manea.m@gmail.com>,
Shuah Khan <shuah@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
Krzysztof Opasiak <k.opasiak@samsung.com>,
Johan Hovold <johan@kernel.org>,
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 [thread overview]
Message-ID: <20171107104010.2884193-1-arnd@arndb.de> (raw)
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 <arnd@arndb.de>
---
drivers/usb/usbip/vudc_dev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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)
--
2.9.0
next reply other threads:[~2017-11-07 10:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20171107104018epcas5p1f9c72d541c679e1c5a44e03a901e8498@epcas5p1.samsung.com>
2017-11-07 10:39 ` Arnd Bergmann [this message]
2017-11-07 10:39 ` [PATCH 2/2] usbip: use monotonic timestamps Arnd Bergmann
2017-11-07 11:22 ` Krzysztof Opasiak
2017-11-07 21:10 ` Shuah Khan
2017-11-07 11:21 ` [PATCH 1/2] usbip: fix off-by-one frame number calculation Krzysztof Opasiak
2017-11-07 21:10 ` Shuah Khan
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=20171107104010.2884193-1-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=k.opasiak@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=valentina.manea.m@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox