From owner-freebsd-current@FreeBSD.ORG Tue Feb 17 18:55:44 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CD11E10656E0; Tue, 17 Feb 2009 18:55:44 +0000 (UTC) (envelope-from keramida@freebsd.org) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id 595C88FC17; Tue, 17 Feb 2009 18:55:44 +0000 (UTC) (envelope-from keramida@freebsd.org) Received: from kobe.laptop (adsl126-61.kln.forthnet.gr [77.49.245.61]) (authenticated bits=128) by igloo.linux.gr (8.14.3/8.14.3/Debian-6) with ESMTP id n1HItWRo006048 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 17 Feb 2009 20:55:37 +0200 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.3/8.14.3) with ESMTP id n1HItVbG019633; Tue, 17 Feb 2009 20:55:31 +0200 (EET) (envelope-from keramida@freebsd.org) Received: (from keramida@localhost) by kobe.laptop (8.14.3/8.14.3/Submit) id n1HItVdN019632; Tue, 17 Feb 2009 20:55:31 +0200 (EET) (envelope-from keramida@freebsd.org) From: Giorgos Keramidas To: Hans Petter Selasky References: <87mycme9wc.fsf@kobe.laptop> <200902170848.28659.hselasky@freebsd.org> <87eixxpgya.fsf@kobe.laptop> <200902171436.58658.hselasky@freebsd.org> Date: Tue, 17 Feb 2009 20:55:30 +0200 In-Reply-To: <200902171436.58658.hselasky@freebsd.org> (Hans Petter Selasky's message of "Tue, 17 Feb 2009 14:36:57 +0100") Message-ID: <87tz6sdhb1.fsf@kobe.laptop> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.90 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Hellug-MailScanner-ID: n1HItWRo006048 X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-4.485, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL -0.09, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@freebsd.org X-Spam-Status: No Cc: freebsd-current@freebsd.org, Andrew Thompson Subject: Re: usb2 moused issue (Microsoft Wireless Optical) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Feb 2009 18:55:45 -0000 On Tue, 17 Feb 2009 14:36:57 +0100, Hans Petter Selasky wrote: > Can you send me the patched file "sys/dev/usb2/core/usb2_hid.c" ? I > cannot see that "size=2" has changed. It's wrong size information that > causes your mouse problem. It is usb2_hid.c from /head at svn rev 188665, plus the changes you sent me before. Script started on Tue Feb 17 20:25:31 2009 keramida@kobe:/home/keramida/svn/head$ svn diff sys/dev/usb2/core Index: sys/dev/usb2/core/usb2_hid.c =================================================================== --- sys/dev/usb2/core/usb2_hid.c (revision 188665) +++ sys/dev/usb2/core/usb2_hid.c (working copy) @@ -392,22 +392,38 @@ { struct hid_data *d; struct hid_item h; - int hi, lo, size, id; + uint32_t size; + uint32_t hi; + uint32_t lo; + uint8_t id; id = 0; - hi = lo = -1; + hi = 0; + lo = (uint32_t)(0-1); for (d = hid_start_parse(buf, len, 1 << k); hid_get_item(d, &h);) if (h.kind == k) { if (h.report_ID != 0 && !id) id = h.report_ID; if (h.report_ID == id) { - if (lo < 0) + /* check if "lo" is greater than "pos" */ + if (lo > h.loc.pos) lo = h.loc.pos; - hi = h.loc.pos + h.loc.size * h.loc.count; + /* compute end position */ + size = h.loc.pos + (h.loc.size * h.loc.count); + /* check if "size" wrapped */ + /* check if "hi" is less than "size" */ + if (size < h.loc.pos) + hi = (uint32_t)(0-1); + else if (hi < size) + hi = size; } } hid_end_parse(d); - size = hi - lo; + if (lo > hi) + size = 0; + else + size = hi - lo; + if (id != 0) { size += 8; *idp = id; /* XXX wrong */ keramida@kobe:/home/keramida/svn/head$ exit exit Script done on Tue Feb 17 20:25:39 2009 The code of hid_report_size() is similar in old usb and the new usb stack, but I am not sure about all the differences I see. The calculation of `size' is done correctly with old usb code, so I am testing the patch attached below now. It essentially pulls in the hid_report_size() from the old usb code, with the if (h.kind == k) check reversed to remove one spurious indentation level: %%% diff --git a/sys/dev/usb2/core/usb2_hid.c b/sys/dev/usb2/core/usb2_hid.c --- a/sys/dev/usb2/core/usb2_hid.c +++ b/sys/dev/usb2/core/usb2_hid.c @@ -392,41 +392,26 @@ { struct hid_data *d; struct hid_item h; - uint32_t size; - uint32_t hi; - uint32_t lo; - uint8_t id; + int hi, lo, size, id; id = 0; - hi = 0; - lo = (uint32_t)(0-1); - for (d = hid_start_parse(buf, len, 1 << k); hid_get_item(d, &h);) - if (h.kind == k) { - if (h.report_ID != 0 && !id) - id = h.report_ID; - if (h.report_ID == id) { - /* check if "lo" is greater than "pos" */ - if (lo > h.loc.pos) - lo = h.loc.pos; - /* compute end position */ - size = h.loc.pos + (h.loc.size * h.loc.count); - /* check if "size" wrapped */ - /* check if "hi" is less than "size" */ - if (size < h.loc.pos) - hi = (uint32_t)(0-1); - else if (hi < size) - hi = size; - } + hi = lo = -1; + for (d = hid_start_parse(buf, len, 1< hi) - size = 0; - else - size = hi - lo; - + size = hi - lo; if (id != 0) { size += 8; - *idp = id; /* XXX wrong */ + *idp = id; /* XXX wrong */ } else *idp = 0; return ((size + 7) / 8); %%% I'll report back later ;)