From owner-svn-src-head@FreeBSD.ORG Tue Jun 19 16:06:28 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B0F7106564A; Tue, 19 Jun 2012 16:06:28 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2B35A8FC14; Tue, 19 Jun 2012 16:06:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5JG6SZD060043; Tue, 19 Jun 2012 16:06:28 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5JG6Ron060041; Tue, 19 Jun 2012 16:06:27 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206191606.q5JG6Ron060041@svn.freebsd.org> From: John Baldwin Date: Tue, 19 Jun 2012 16:06:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237272 - head/sys/dev/pci X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 16:06:28 -0000 Author: jhb Date: Tue Jun 19 16:06:27 2012 New Revision: 237272 URL: http://svn.freebsd.org/changeset/base/237272 Log: Add a 'wmask' variable to hold the expression '(1ul << w->step) - 1' in pcib_grow_window(). This makes the code slightly easier to read and prevents the type of bug fixed in r237271. MFC after: 3 days Modified: head/sys/dev/pci/pci_pci.c Modified: head/sys/dev/pci/pci_pci.c ============================================================================== --- head/sys/dev/pci/pci_pci.c Tue Jun 19 15:15:35 2012 (r237271) +++ head/sys/dev/pci/pci_pci.c Tue Jun 19 16:06:27 2012 (r237272) @@ -815,7 +815,7 @@ static int pcib_grow_window(struct pcib_softc *sc, struct pcib_window *w, int type, u_long start, u_long end, u_long count, u_int flags) { - u_long align, start_free, end_free, front, back; + u_long align, start_free, end_free, front, back, wmask; int error, rid; /* @@ -828,6 +828,7 @@ pcib_grow_window(struct pcib_softc *sc, end = w->rman.rm_end; if (start + count - 1 > end || start + count < start) return (EINVAL); + wmask = (1ul << w->step) - 1; /* * If there is no resource at all, just try to allocate enough @@ -838,8 +839,8 @@ pcib_grow_window(struct pcib_softc *sc, flags &= ~RF_ALIGNMENT_MASK; flags |= RF_ALIGNMENT_LOG2(w->step); } - start &= ~((1ul << w->step) - 1); - end |= ((1ul << w->step) - 1); + start &= ~wmask; + end |= wmask; count = roundup2(count, 1ul << w->step); rid = w->reg; w->res = bus_alloc_resource(sc->dev, type, &rid, start, end, @@ -913,7 +914,7 @@ pcib_grow_window(struct pcib_softc *sc, if (bootverbose) printf("\tfront candidate range: %#lx-%#lx\n", front, end_free); - front &= ~((1ul << w->step) - 1); + front &= ~wmask; front = rman_get_start(w->res) - front; } else front = 0; @@ -941,7 +942,7 @@ pcib_grow_window(struct pcib_softc *sc, if (bootverbose) printf("\tback candidate range: %#lx-%#lx\n", start_free, back); - back |= (1ul << w->step) - 1; + back |= wmask; back -= rman_get_end(w->res); } else back = 0; @@ -1000,10 +1001,8 @@ updatewin: /* Save the new window. */ w->base = rman_get_start(w->res); w->limit = rman_get_end(w->res); - KASSERT((w->base & ((1ul << w->step) - 1)) == 0, - ("start address is not aligned")); - KASSERT((w->limit & ((1ul << w->step) - 1)) == (1ul << w->step) - 1, - ("end address is not aligned")); + KASSERT((w->base & wmask) == 0, ("start address is not aligned")); + KASSERT((w->limit & wmask) == wmask, ("end address is not aligned")); pcib_write_windows(sc, w->mask); return (0); }