svn commit: r275468 - head/sys/dev/usb/controller

Hans Petter Selasky hselasky at FreeBSD.org
Wed Dec 3 21:55:45 UTC 2014


Author: hselasky
Date: Wed Dec  3 21:55:44 2014
New Revision: 275468
URL: https://svnweb.freebsd.org/changeset/base/275468

Log:
  Optimise the bit searching loops, by quickly skipping the 16 first set
  bits if all the 16 first bits are set. This way the worst case
  searching time is reduced from 32 to 16 cycles.

Modified:
  head/sys/dev/usb/controller/saf1761_otg.c

Modified: head/sys/dev/usb/controller/saf1761_otg.c
==============================================================================
--- head/sys/dev/usb/controller/saf1761_otg.c	Wed Dec  3 21:48:30 2014	(r275467)
+++ head/sys/dev/usb/controller/saf1761_otg.c	Wed Dec  3 21:55:44 2014	(r275468)
@@ -230,7 +230,7 @@ saf1761_host_channel_alloc(struct saf176
 		map = sc->sc_host_intr_map |
 		    sc->sc_host_intr_busy_map[0] |
 		    sc->sc_host_intr_busy_map[1];
-		for (x = 0; x != 32; x++) {
+		for (x = ((map & 0xFFFF) == 0xFFFF) ? 16 : 0; x != 32; x++) {
 			if (map & (1 << x))
 				continue;
 			sc->sc_host_intr_map |= (1 << x);
@@ -242,7 +242,7 @@ saf1761_host_channel_alloc(struct saf176
 		map = sc->sc_host_isoc_map |
 		    sc->sc_host_isoc_busy_map[0] |
 		    sc->sc_host_isoc_busy_map[1];
-		for (x = 0; x != 32; x++) {
+		for (x = ((map & 0xFFFF) == 0xFFFF) ? 16 : 0; x != 32; x++) {
 			if (map & (1 << x))
 				continue;
 			sc->sc_host_isoc_map |= (1 << x);
@@ -254,7 +254,7 @@ saf1761_host_channel_alloc(struct saf176
 		map = sc->sc_host_async_map |
 		    sc->sc_host_async_busy_map[0] |
 		    sc->sc_host_async_busy_map[1];
-		for (x = 0; x != 32; x++) {
+		for (x = ((map & 0xFFFF) == 0xFFFF) ? 16 : 0; x != 32; x++) {
 			if (map & (1 << x))
 				continue;
 			sc->sc_host_async_map |= (1 << x);


More information about the svn-src-all mailing list