Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Dec 2014 21:55:45 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r275468 - head/sys/dev/usb/controller
Message-ID:  <201412032155.sB3LtjJN043364@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412032155.sB3LtjJN043364>