Module Name:    src
Committed By:   scw
Date:           Sat Mar 13 16:28:13 UTC 2010

Modified Files:
        src/sys/dev/usb: ucomvar.h uftdi.c

Log Message:
Fix PR kern/42838 using option #1 as described by KIYOHARA Takashi in
http://mail-index.netbsd.org/current-users/2010/02/20/msg012654.html

Add a comment in struct ucom_methods to explain usage of 'ptr' and 'count'
in the ucom_read handler.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/usb/ucomvar.h
cvs rdiff -u -r1.45 -r1.46 src/sys/dev/usb/uftdi.c

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/ucomvar.h
diff -u src/sys/dev/usb/ucomvar.h:1.17 src/sys/dev/usb/ucomvar.h:1.18
--- src/sys/dev/usb/ucomvar.h:1.17	Sat May 24 16:40:58 2008
+++ src/sys/dev/usb/ucomvar.h	Sat Mar 13 16:28:13 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucomvar.h,v 1.17 2008/05/24 16:40:58 cube Exp $	*/
+/*	$NetBSD: ucomvar.h,v 1.18 2010/03/13 16:28:13 scw Exp $	*/
 
 /*
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -47,6 +47,14 @@
 			  void *data, int flag, usb_proc_ptr p);
 	int (*ucom_open)(void *sc, int portno);
 	void (*ucom_close)(void *sc, int portno);
+	/*
+	 * Note: The 'ptr' and 'count' pointers can be adjusted as follows:
+	 *  ptr: If consuming characters from the start of the buffer,
+	 *       advance '*ptr' to skip the data consumed.
+	 *  count: If consuming characters at the end of the buffer,
+	 *         decrement '*count' by the number of characters consumed.
+	 * If consuming all characters, set '*count' to zero.
+	 */
 	void (*ucom_read)(void *sc, int portno, u_char **ptr, u_int32_t *count);
 	void (*ucom_write)(void *sc, int portno, u_char *to, u_char *from,
 			   u_int32_t *count);

Index: src/sys/dev/usb/uftdi.c
diff -u src/sys/dev/usb/uftdi.c:1.45 src/sys/dev/usb/uftdi.c:1.46
--- src/sys/dev/usb/uftdi.c:1.45	Mon Jan 18 20:57:13 2010
+++ src/sys/dev/usb/uftdi.c	Sat Mar 13 16:28:13 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: uftdi.c,v 1.45 2010/01/18 20:57:13 martin Exp $	*/
+/*	$NetBSD: uftdi.c,v 1.46 2010/03/13 16:28:13 scw Exp $	*/
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uftdi.c,v 1.45 2010/01/18 20:57:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uftdi.c,v 1.46 2010/03/13 16:28:13 scw Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -426,9 +426,8 @@
 		ucom_status_change(device_private(sc->sc_subdev[portno-1]));
 	}
 
-	/* Pick up status and adjust data part. */
+	/* Adjust buffer pointer to skip status prefix */
 	*ptr += 2;
-	*count -= 2;
 }
 
 Static void

Reply via email to