Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 May 2009 18:06:53 +0000 (UTC)
From:      Andrew Thompson <thompsa@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r192055 - head/sys/dev/usb
Message-ID:  <200905131806.n4DI6rDs063574@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: thompsa
Date: Wed May 13 18:06:52 2009
New Revision: 192055
URL: http://svn.freebsd.org/changeset/base/192055

Log:
  Make sure collections have the usage field set.
  
  Submitted by:	Hans Petter Selasky

Modified:
  head/sys/dev/usb/usb_hid.c

Modified: head/sys/dev/usb/usb_hid.c
==============================================================================
--- head/sys/dev/usb/usb_hid.c	Wed May 13 18:05:40 2009	(r192054)
+++ head/sys/dev/usb/usb_hid.c	Wed May 13 18:06:52 2009	(r192055)
@@ -309,6 +309,7 @@ hid_get_item(struct hid_data *s, struct 
 				c->kind = hid_collection;
 				c->collection = dval;
 				c->collevel++;
+				c->usage = s->usage_last;
 				*h = *c;
 				return (1);
 			case 11:	/* Feature */
@@ -408,6 +409,9 @@ hid_get_item(struct hid_data *s, struct 
 				if (bSize != 4)
 					dval = (dval & mask) | c->_usage_page;
 
+				/* set last usage, in case of a collection */
+				s->usage_last = dval;
+
 				if (s->nusage < MAXUSAGE) {
 					s->usages_min[s->nusage] = dval;
 					s->usages_max[s->nusage] = dval;
@@ -630,9 +634,11 @@ hid_is_collection(const void *desc, usb2
 	if (hd == NULL)
 		return (0);
 
-	err = hid_get_item(hd, &hi) &&
-	    hi.kind == hid_collection &&
-	    hi.usage == usage;
+	while ((err = hid_get_item(hd, &hi))) {
+		 if (hi.kind == hid_collection &&
+		     hi.usage == usage)
+			break;
+	}
 	hid_end_parse(hd);
 	return (err);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905131806.n4DI6rDs063574>