From patchwork Fri Dec 10 03:29:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 397172 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBA3UrxP032694 for ; Fri, 10 Dec 2010 03:30:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754939Ab0LJD32 (ORCPT ); Thu, 9 Dec 2010 22:29:28 -0500 Received: from mail.perches.com ([173.55.12.10]:2473 "EHLO mail.perches.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754757Ab0LJD3Y (ORCPT ); Thu, 9 Dec 2010 22:29:24 -0500 Received: from localhost.home (unknown [192.168.1.153]) by mail.perches.com (Postfix) with ESMTP id 3AE172436F; Thu, 9 Dec 2010 19:29:16 -0800 (PST) From: Joe Perches To: Jiri Kosina Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] hid: simplify an index check in hid_lookup_collection Date: Thu, 9 Dec 2010 19:29:08 -0800 Message-Id: X-Mailer: git-send-email 1.7.3.3.464.gf80b6 In-Reply-To: References: In-Reply-To: References: Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 10 Dec 2010 03:30:53 +0000 (UTC) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 796012e..ee05170 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -178,10 +178,14 @@ static int close_collection(struct hid_parser *parser) static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type) { + struct hid_collection *collection = parser->device->collection; int n; - for (n = parser->collection_stack_ptr - 1; n >= 0; n--) - if (parser->device->collection[parser->collection_stack[n]].type == type) - return parser->device->collection[parser->collection_stack[n]].usage; + + for (n = parser->collection_stack_ptr - 1; n >= 0; n--) { + unsigned index = parser->collection_stack[n]; + if (collection[index].type == type) + return collection[index].usage; + } return 0; /* we know nothing about this usage type */ }