Greg:
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.
Please apply.
Alan Stern
Sent-by: Karsten Wiese <[EMAIL PROTECTED]>
Signed-off-by: Alan Stern <[EMAIL PROTECTED]>
===== drivers/usb/host/uhci-hcd.c 1.139 vs edited =====
--- 1.139/drivers/usb/host/uhci-hcd.c 2004-10-21 16:02:20 -04:00
+++ edited/drivers/usb/host/uhci-hcd.c 2004-10-27 10:16:17 -04:00
@@ -92,7 +92,7 @@
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 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 @@
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 @@
*
* 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);
}
-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel