summaryrefslogtreecommitdiff
path: root/drivers/hid/usbhid
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2021-09-01 19:36:06 +0300
committerJiri Kosina <jkosina@suse.cz>2021-09-01 21:52:32 +0300
commitd2f311ec91984adb219ac6985d4dd72c37ae734d (patch)
tree7164eabfbb51ff5d7a8876c2b1ff481af854de19 /drivers/hid/usbhid
parent0a824efdb724e07574bafcd2c2486b2a3de35ff6 (diff)
downloadlinux-d2f311ec91984adb219ac6985d4dd72c37ae734d.tar.xz
HID: usbhid: Simplify code in hid_submit_ctrl()
This patch makes a small simplification to the code in hid_submit_ctrl(). The test for maxpacket being > 0 is unnecessary, because endpoint 0 always has a maxpacket value which is >= 8. Furthermore, endpoint 0's maxpacket value is always a power of 2, so instead of open-coding the round-to-next-multiple computation we can call the optimized round_up() routine. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/usbhid')
-rw-r--r--drivers/hid/usbhid/hid-core.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index c56cb03c1551..2dcaf31eb9cd 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -388,14 +388,10 @@ static int hid_submit_ctrl(struct hid_device *hid)
usbhid->urbctrl->pipe = usb_rcvctrlpipe(hid_to_usb_dev(hid), 0);
maxpacket = usb_maxpacket(hid_to_usb_dev(hid),
usbhid->urbctrl->pipe, 0);
- if (maxpacket > 0) {
- len += (len == 0); /* Don't allow 0-length reports */
- len = DIV_ROUND_UP(len, maxpacket);
- len *= maxpacket;
- if (len > usbhid->bufsize)
- len = usbhid->bufsize;
- } else
- len = 0;
+ len += (len == 0); /* Don't allow 0-length reports */
+ len = round_up(len, maxpacket);
+ if (len > usbhid->bufsize)
+ len = usbhid->bufsize;
}
usbhid->urbctrl->transfer_buffer_length = len;
usbhid->urbctrl->dev = hid_to_usb_dev(hid);