svn commit: r206965 - in stable/8/sys/dev: bwn siba

Weongyo Jeong weongyo at FreeBSD.org
Wed Apr 21 00:06:40 UTC 2010


Author: weongyo
Date: Wed Apr 21 00:06:39 2010
New Revision: 206965
URL: http://svn.freebsd.org/changeset/base/206965

Log:
  MFC r204542:
    calculates the integer square root if a positive integer X is larger
    than 256 instead of using sqrt_table.
  
    Reported by: Joe Marcus Clarke <marcus at freebsd dot org>

Modified:
  stable/8/sys/dev/bwn/if_bwn.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/dev/uath/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/siba/siba_cc.c   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/geom/sched/   (props changed)

Modified: stable/8/sys/dev/bwn/if_bwn.c
==============================================================================
--- stable/8/sys/dev/bwn/if_bwn.c	Wed Apr 21 00:05:22 2010	(r206964)
+++ stable/8/sys/dev/bwn/if_bwn.c	Wed Apr 21 00:06:39 2010	(r206965)
@@ -12846,7 +12846,6 @@ bwn_phy_lp_clear_deaf(struct bwn_mac *ma
 static unsigned int
 bwn_sqrt(struct bwn_mac *mac, unsigned int x)
 {
-	struct bwn_softc *sc = mac->mac_sc;
 	/* Table holding (10 * sqrt(x)) for x between 1 and 256. */
 	static uint8_t sqrt_table[256] = {
 		10, 14, 17, 20, 22, 24, 26, 28,
@@ -12886,9 +12885,11 @@ bwn_sqrt(struct bwn_mac *mac, unsigned i
 	if (x == 0)
 		return (0);
 	if (x >= 256) {
-		device_printf(sc->sc_dev,
-		    "out of bounds of the square-root table (%d)\n", x);
-		return (16);
+		unsigned int tmp;
+
+		for (tmp = 0; x >= (2 * tmp) + 1; x -= (2 * tmp++) + 1)
+			/* do nothing */ ;
+		return (tmp);
 	}
 	return (sqrt_table[x - 1] / 10);
 }


More information about the svn-src-all mailing list