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

Weongyo Jeong weongyo at FreeBSD.org
Wed Sep 22 19:08:17 UTC 2010


Author: weongyo
Date: Wed Sep 22 19:08:17 2010
New Revision: 213010
URL: http://svn.freebsd.org/changeset/base/213010

Log:
  Returns with correct buffer length for a single page case.  In the
  previous there was no way to check the boundary because the length was
  always -1.

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 19:08:11 2010	(r213009)
+++ user/weongyo/usb/sys/dev/usb/usb_busdma.c	Wed Sep 22 19:08:17 2010	(r213010)
@@ -78,10 +78,11 @@ static void	usb_pc_common_mem_cb(void *,
  * been properly initialized !
  *------------------------------------------------------------------------*/
 void
-usbd_get_page(struct usb_page_cache *pc, usb_frlength_t offset,
+usbd_get_page(struct usb_page_cache *pc, usb_frlength_t offset0,
     struct usb_page_search *res)
 {
 	struct usb_page *page;
+	usb_frlength_t offset = offset0;
 	int index;
 
 #if USB_HAVE_BUSDMA
@@ -106,7 +107,10 @@ usbd_get_page(struct usb_page_cache *pc,
 			res->length = USB_PAGE_SIZE - offset;
 			res->physaddr = page[index].physaddr + offset;
 		} else {
-			res->length = 0 - 1;
+			USB_ASSERT(page[index].physlen > offset0,
+			    ("wrong offset (%zd/ %d)", page[index].physlen,
+			    offset0));
+			res->length = page[index].physlen - offset0;
 			res->physaddr = page[index].physaddr + offset;
 		}
 		if (!pc->buffer) {


More information about the svn-src-user mailing list