Module Name: src Committed By: skrll Date: Tue Mar 3 06:36:53 UTC 2015
Modified Files: src/sys/dev/usb [nick-nhusb]: ehci.c ehcireg.h Log Message: Improve EHCI_PAGE macros and usage. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.234.2.36 -r1.234.2.37 src/sys/dev/usb/ehci.c cvs rdiff -u -r1.34.14.4 -r1.34.14.5 src/sys/dev/usb/ehcireg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/usb/ehci.c diff -u src/sys/dev/usb/ehci.c:1.234.2.36 src/sys/dev/usb/ehci.c:1.234.2.37 --- src/sys/dev/usb/ehci.c:1.234.2.36 Mon Mar 2 22:16:38 2015 +++ src/sys/dev/usb/ehci.c Tue Mar 3 06:36:53 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ehci.c,v 1.234.2.36 2015/03/02 22:16:38 skrll Exp $ */ +/* $NetBSD: ehci.c,v 1.234.2.37 2015/03/03 06:36:53 skrll Exp $ */ /* * Copyright (c) 2004-2012 The NetBSD Foundation, Inc. @@ -53,7 +53,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.36 2015/03/02 22:16:38 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.37 2015/03/03 06:36:53 skrll Exp $"); #include "ohci.h" #include "uhci.h" @@ -2835,12 +2835,12 @@ ehci_alloc_sqtd_chain(struct ehci_pipe * } /* Find number of pages we'll be using, insert dma addresses */ - pages = EHCI_PAGE(curlen + EHCI_PAGE_SIZE - 1) >> 12; + pages = EHCI_NPAGES(curlen); KASSERT(pages <= EHCI_QTD_NBUFFERS); pageoffs = EHCI_PAGE(curoffs); for (i = 0; i < pages; i++) { a = DMAADDR(dma, pageoffs + i * EHCI_PAGE_SIZE); - cur->qtd.qtd_buffer[i] = htole32(a & 0xFFFFF000); + cur->qtd.qtd_buffer[i] = htole32(EHCI_PAGE(a)); /* Cast up to avoid compiler warnings */ cur->qtd.qtd_buffer_hi[i] = htole32((uint64_t)a >> 32); } Index: src/sys/dev/usb/ehcireg.h diff -u src/sys/dev/usb/ehcireg.h:1.34.14.4 src/sys/dev/usb/ehcireg.h:1.34.14.5 --- src/sys/dev/usb/ehcireg.h:1.34.14.4 Sun Feb 1 08:45:04 2015 +++ src/sys/dev/usb/ehcireg.h Tue Mar 3 06:36:53 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ehcireg.h,v 1.34.14.4 2015/02/01 08:45:04 skrll Exp $ */ +/* $NetBSD: ehcireg.h,v 1.34.14.5 2015/03/03 06:36:53 skrll Exp $ */ /* * Copyright (c) 2001, 2004 The NetBSD Foundation, Inc. @@ -188,10 +188,12 @@ #define EHCI_MAX_PORTS 16 /* only 4 bits available in EHCI_HCS_N_PORTS */ /* No data structure may cross a page boundary. */ -#define EHCI_PAGE_SIZE 0x1000 -#define EHCI_PAGE_MASK (EHCI_PAGE_SIZE - 1) -#define EHCI_PAGE(x) ((x) & ~EHCI_PAGE_MASK) -#define EHCI_PAGE_OFFSET(x) ((x) & EHCI_PAGE_MASK) +#define EHCI_PAGE_SHIFT 12 +#define EHCI_PAGE_SIZE (1 << EHCI_PAGE_SHIFT) +#define EHCI_PAGE_MASK (EHCI_PAGE_SIZE - 1) +#define EHCI_PAGE(x) ((x) & ~EHCI_PAGE_MASK) +#define EHCI_PAGE_OFFSET(x) ((x) & EHCI_PAGE_MASK) +#define EHCI_NPAGES(x) (((x) + EHCI_PAGE_MASK) >> EHCI_PAGE_SHIFT) typedef uint32_t ehci_link_t; #define EHCI_LINK_TERMINATE 0x00000001