Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1221708imu; Thu, 22 Nov 2018 12:19:39 -0800 (PST) X-Google-Smtp-Source: AJdET5ft543IzHhfO8AjfgXvw5BPkupT+Zkipybaf0gq1/CB3DBhqdlJrmQELewCAQHWcMURYbCD X-Received: by 2002:a62:3501:: with SMTP id c1-v6mr12715203pfa.173.1542917979656; Thu, 22 Nov 2018 12:19:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542917979; cv=none; d=google.com; s=arc-20160816; b=WnJjNuzK9bAGjEQJRZn7h/Otclq3CMCcO1yBVKfJWYML+SlDEXFdyd+YVZdoD3Z5U3 jY1+bhfy+t8mCdcSL2n6i2jMTSdAoVmsqkgTmFlKrSYAIi+FEHE6sv6xyYkwjvD6ia9G s7zcd2ZhNpk9VeuXbsD8bb+jqO3jYPOYDmW47WcjkB62ypS90+Ns+PHqJ87B22HYL54s 7Ta8mUGZfw+5sia4R/tLA4Er5WbtGbZngnkrDEBJk50M4KlT31eP4onzFR74JnJMvxSu P5P/F/iAdMiUkOFDaHBLA0D7FslBMabcsTg7rTp65PneEyJv0efeDwlQnGheb3e3U+8a QXFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=7YaYxM3zwhxAdS2G9qdRSd9LLkUOArdQ0uT0AOMl/P4=; b=r/oEJeNm5hukeNAzgHO7S366Z30P89XpJmgTxtVyr72Kqbr4N13pjACCxANPRO4+i0 VrYOvsx2jNR6GkgSsM3WDsweWr1b40LNoCih/Vn1U5alGE9TKBvue5muqTm/X28sJluJ jU8aCJMqCMamGi1dh4c9E9+dSVBjNM//aFhXcUFYKiBxae2mSGIXVfNJOGC8F1++gmFK qDOCKnmT+LS0Jb1LIL63MPfk0v1Sl6pnV8pcnbUkzXQrQIHfjboBwhMeHqUQobPeU+uj rT5fsXWCSIEFl0hO+TceECOhWwxsR1m0dRu42SIj95x/RFm+tT4OEkrM009ULf+EBEhh V8TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@who-t.net header.s=fm1 header.b=NQBADYNu; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=VLyj8fyk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q15si51577560pgm.420.2018.11.22.12.19.24; Thu, 22 Nov 2018 12:19:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@who-t.net header.s=fm1 header.b=NQBADYNu; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=VLyj8fyk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404728AbeKVRM4 (ORCPT + 99 others); Thu, 22 Nov 2018 12:12:56 -0500 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:43355 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732955AbeKVRMz (ORCPT ); Thu, 22 Nov 2018 12:12:55 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 57A5021F6E; Thu, 22 Nov 2018 01:34:56 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 22 Nov 2018 01:34:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=who-t.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=7YaYxM3zwhxAd S2G9qdRSd9LLkUOArdQ0uT0AOMl/P4=; b=NQBADYNuq66+bizkD+PsogwK//5XK XaplCH/ogqORUBAT9y0qZlWB1Z1B7O1jc9W8ZAdUnJPaTEqQaZuN5fOqTnBQQYSM dVHW7DHW+UJ8ymg20oxgeG5D1uyu9YzafPFw6kzRbJmasmdvBSOjvIqyy7sch7KO nthmqYIb/v8aEUVoJd/w2vmQNfjkh5/x/Jm4J32HZD7oD9ryO1CP9lq1CHsHnbVD p6caGlG7muwekiKVf/70+o2u89jqz5IJ9mbUBhq2jCG4BB5ZM0JODi37OV6BRCyO qyvyB+TMvxZzLVrIZPRv++dQTOLJTAL1cv/9t45XwldVUr+Fogxl9S3iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=7YaYxM3zwhxAdS2G9qdRSd9LLkUOArdQ0uT0AOMl/P4=; b=VLyj8fyk VN91hNwrmLJMwubdd2dCw+HpDJttioQp2ZUPoofEzO8AL0TUk1PwXeqIdMvPdpaM ZsKsouRfLyfkXNVlYXuJBT/FjPVEaNIatUv4Q2S8f/UwxMsKsi5hCOw2lyGoGk7N uf6oar+cwT0A9KKBz2H7WDeJAykWUG+JvxcDAte2a0iOTzopsSX3S9t5jq/YMuhX 2BzxBl/s8Eh8VQ0vGE4Oj9/J9LDA6JatJ8IpyOEP5qOHYtfBnt6jDOzFQSFtU93j JWxm89pWGUYhQzQYORrK0dy961+aXkb0FI85ufV+uzA1qUsWiE75vzbPSRL45g4o QV383Qt2H5CfTQ== X-ME-Sender: X-ME-Proxy: Received: from jelly.home.gateway (167-179-166-29.a7b3a6.bne.nbn.aussiebb.net [167.179.166.29]) by mail.messagingengine.com (Postfix) with ESMTPA id 6A6E5102EE; Thu, 22 Nov 2018 01:34:53 -0500 (EST) From: Peter Hutterer To: linux-input@vger.kernel.org Cc: Dmitry Torokhov , Jiri Kosina , Harry Cutts , torvalds@linux-foundation.org, Nestor Lopez Casado , linux-kernel@vger.kernel.org, Benjamin Tissoires Subject: [PATCH 2/8] HID: core: store the collections as a basic tree Date: Thu, 22 Nov 2018 16:34:03 +1000 Message-Id: <20181122063409.15816-3-peter.hutterer@who-t.net> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181122063409.15816-1-peter.hutterer@who-t.net> References: <20181122063409.15816-1-peter.hutterer@who-t.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For each collection parsed, store a pointer to the parent collection (if any). This makes it a lot easier to look up which collection(s) any given item is part of Signed-off-by: Peter Hutterer --- drivers/hid/hid-core.c | 4 ++++ include/linux/hid.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 5bec9244c45b..43d488a45120 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -172,6 +172,8 @@ static int open_collection(struct hid_parser *parser, unsigned type) collection->type = type; collection->usage = usage; collection->level = parser->collection_stack_ptr - 1; + collection->parent = parser->active_collection; + parser->active_collection = collection; if (type == HID_COLLECTION_APPLICATION) parser->device->maxapplication++; @@ -190,6 +192,8 @@ static int close_collection(struct hid_parser *parser) return -EINVAL; } parser->collection_stack_ptr--; + if (parser->active_collection) + parser->active_collection = parser->active_collection->parent; return 0; } diff --git a/include/linux/hid.h b/include/linux/hid.h index a355d61940f2..fdfda898656c 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -427,6 +427,7 @@ struct hid_local { */ struct hid_collection { + struct hid_collection *parent; unsigned type; unsigned usage; unsigned level; @@ -650,6 +651,7 @@ struct hid_parser { unsigned int *collection_stack; unsigned int collection_stack_ptr; unsigned int collection_stack_size; + struct hid_collection *active_collection; struct hid_device *device; unsigned int scan_flags; }; -- 2.19.1