Commit 2bff2da2 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[PATCH] UHCI: Convert remainder to bitwise-and

This patch, suggested by Karsten Wiese, converts a few remainder ('%')
operations in the UHCI driver to bitwise-and ('&').  It's not a huge
change, but this is a common idiom in C and it will save a few bytes with
some compilers.  Also one of the changes is in an inner loop, so it might
help a little bit.



From: Karsten Wiese <annabellesgarden@yahoo.de>
Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 196260c1
......@@ -92,7 +92,7 @@ static char *errbuf;
static kmem_cache_t *uhci_up_cachep; /* urb_priv */
static int uhci_get_current_frame_number(struct uhci_hcd *uhci);
static unsigned int uhci_get_current_frame_number(struct uhci_hcd *uhci);
static int uhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb);
static void uhci_unlink_generic(struct uhci_hcd *uhci, struct urb *urb);
static void uhci_remove_pending_urbps(struct uhci_hcd *uhci);
......@@ -174,7 +174,7 @@ static inline void uhci_fill_td(struct uhci_td *td, u32 status,
*/
static void uhci_insert_td_frame_list(struct uhci_hcd *uhci, struct uhci_td *td, unsigned framenum)
{
framenum %= UHCI_NUMFRAMES;
framenum &= (UHCI_NUMFRAMES - 1);
td->frame = framenum;
......@@ -1145,15 +1145,14 @@ static int isochronous_find_start(struct uhci_hcd *uhci, struct urb *urb)
limits = isochronous_find_limits(uhci, urb, &start, &end);
if (urb->transfer_flags & URB_ISO_ASAP) {
if (limits) {
int curframe;
curframe = uhci_get_current_frame_number(uhci) % UHCI_NUMFRAMES;
urb->start_frame = (curframe + 10) % UHCI_NUMFRAMES;
} else
if (limits)
urb->start_frame =
(uhci_get_current_frame_number(uhci) +
10) & (UHCI_NUMFRAMES - 1);
else
urb->start_frame = end;
} else {
urb->start_frame %= UHCI_NUMFRAMES;
urb->start_frame &= (UHCI_NUMFRAMES - 1);
/* FIXME: Sanity check */
}
......@@ -1514,7 +1513,7 @@ static int uhci_fsbr_timeout(struct uhci_hcd *uhci, struct urb *urb)
*
* returns the current frame number for a USB bus/controller.
*/
static int uhci_get_current_frame_number(struct uhci_hcd *uhci)
static unsigned int uhci_get_current_frame_number(struct uhci_hcd *uhci)
{
return inw(uhci->io_addr + USBFRNUM);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment