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; ...@@ -92,7 +92,7 @@ static char *errbuf;
static kmem_cache_t *uhci_up_cachep; /* urb_priv */ 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 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_unlink_generic(struct uhci_hcd *uhci, struct urb *urb);
static void uhci_remove_pending_urbps(struct uhci_hcd *uhci); 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, ...@@ -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) 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; td->frame = framenum;
...@@ -1145,15 +1145,14 @@ static int isochronous_find_start(struct uhci_hcd *uhci, struct urb *urb) ...@@ -1145,15 +1145,14 @@ static int isochronous_find_start(struct uhci_hcd *uhci, struct urb *urb)
limits = isochronous_find_limits(uhci, urb, &start, &end); limits = isochronous_find_limits(uhci, urb, &start, &end);
if (urb->transfer_flags & URB_ISO_ASAP) { if (urb->transfer_flags & URB_ISO_ASAP) {
if (limits) { if (limits)
int curframe; urb->start_frame =
(uhci_get_current_frame_number(uhci) +
curframe = uhci_get_current_frame_number(uhci) % UHCI_NUMFRAMES; 10) & (UHCI_NUMFRAMES - 1);
urb->start_frame = (curframe + 10) % UHCI_NUMFRAMES; else
} else
urb->start_frame = end; urb->start_frame = end;
} else { } else {
urb->start_frame %= UHCI_NUMFRAMES; urb->start_frame &= (UHCI_NUMFRAMES - 1);
/* FIXME: Sanity check */ /* FIXME: Sanity check */
} }
...@@ -1514,7 +1513,7 @@ static int uhci_fsbr_timeout(struct uhci_hcd *uhci, struct urb *urb) ...@@ -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. * 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); 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