svn commit: r213022 - user/weongyo/usb/sys/dev/usb

Weongyo Jeong weongyo at FreeBSD.org
Wed Sep 22 20:07:03 UTC 2010


Author: weongyo
Date: Wed Sep 22 20:07:02 2010
New Revision: 213022
URL: http://svn.freebsd.org/changeset/base/213022

Log:
  Calculates the remained buffer if pc->ismultiseg == 1.  According to the
  current implementation the last segment should be handled carefully
  because its position could vary.

Modified:
  user/weongyo/usb/sys/dev/usb/usb_busdma.c

Modified: user/weongyo/usb/sys/dev/usb/usb_busdma.c
==============================================================================
--- user/weongyo/usb/sys/dev/usb/usb_busdma.c	Wed Sep 22 20:04:03 2010	(r213021)
+++ user/weongyo/usb/sys/dev/usb/usb_busdma.c	Wed Sep 22 20:07:02 2010	(r213022)
@@ -82,7 +82,7 @@ usbd_get_page(struct usb_page_cache *pc,
     struct usb_page_search *res)
 {
 	struct usb_page *page;
-	usb_frlength_t offset = offset0;
+	usb_frlength_t end, offset = offset0;
 	int index;
 
 #if USB_HAVE_BUSDMA
@@ -104,7 +104,17 @@ usbd_get_page(struct usb_page_cache *pc,
 			    ("invalid index number (%d / %d)", index,
 			    pc->npages));
 			offset %= USB_PAGE_SIZE;
-			res->length = USB_PAGE_SIZE - offset;
+			/* If it's the last segment handle differently */
+			if ((index + 1) != pc->npages)
+				res->length = USB_PAGE_SIZE - offset;
+			else {
+				end = page[index].physlen;
+				if (index == 0)
+					end += pc->page_offset_buf;
+				USB_ASSERT(end >= offset,
+				    ("wrong offset (%d / %d)", end, offset));
+				res->length = end - offset;
+			}
 			res->physaddr = page[index].physaddr + offset;
 		} else {
 			USB_ASSERT(pc->npages == 1,


More information about the svn-src-user mailing list