Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8904397imu; Tue, 4 Dec 2018 16:46:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/Uzlzfp2RUQBh1pt7aS0yjJeTMmXfBc5TwwGgVmmxMa6EZjiA8WfYAE0RYot8Kp0vXtTu0Y X-Received: by 2002:a63:1d59:: with SMTP id d25mr18973790pgm.180.1543970781110; Tue, 04 Dec 2018 16:46:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543970781; cv=none; d=google.com; s=arc-20160816; b=F/Hj15H0ElXq01yi0OI7lw7HFLzwmg3SE7K3VtNIXdz5mnzm4D/W0w3DQppBpBTjGR /9l+Qs+LfkP5X5U6oAn60OnlZO/hay3HmnNGTMfseeLksQUMGmGD/MjeulV/Sf5cvrow w7WUrqM0cuApcGJm8gBQ8WkCWklpGrX8ylzEl8om8WZ4gtsnP1H5LpOVjVF0ixLU13mx 8CcpmxYhmLGGc2H/bgccmiYlF4gJvz3ao4JL+sHE4swzZzdaNiXZ7J5ABXpmemsHmifS Zd39098z+NU+UUvWaJH/KYCIyB7ie+1MVchoXlImfZtJP5V2qpdYVKVfPfTX6G5NeV1D q4tw== 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=k0SRJk9N+O36Mb6BBb8a+KFCArA/YJkSqsoiZZ63uUo=; b=X1W0mxz72dbTeUYVEgf7ONV5VTd1LaQBGD0X1YDPyMYYZIY5AfJLS1+SFCEfLJxVfR cDC5zykyNVdjGEoADOCYFP7Me+SZG/6WmvHrueaCtLp63y3Q0twToZIj9/KqYwRTjwRt sGbiQ1wQzFlzKZdUb1s8HU5MPT8SW7YUJvnOcQldor76wS7nzk+AL57XjduWoUjILAQq iKzhByb5l/Uc/LDfTO9mAS2Qx/4HwLyQ8OPFTZcyI5apIDw+x2B93H6tNPF5cqIPBeib 6kGaXmBROml8YrM0Sere95lRcOXswVEPofTA1pgr0TuPWqHva4BsgOmc7wLA28OJ/SES 1AzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@who-t.net header.s=fm1 header.b=mQTx0HGG; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=kbfDlyq8; 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 i39si18865562plb.256.2018.12.04.16.46.05; Tue, 04 Dec 2018 16:46:21 -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=mQTx0HGG; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=kbfDlyq8; 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 S1726923AbeLEAnh (ORCPT + 99 others); Tue, 4 Dec 2018 19:43:37 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:52729 "EHLO wout2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726715AbeLEAm5 (ORCPT ); Tue, 4 Dec 2018 19:42:57 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id D9CAAF53; Tue, 4 Dec 2018 19:42:55 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 04 Dec 2018 19:42: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=k0SRJk9N+O36M b6BBb8a+KFCArA/YJkSqsoiZZ63uUo=; b=mQTx0HGG38qmF8JpsSklhhOZ8yghv zLgaQfcCXHdONW7ZyA9zaEqlA5CGE4RlnVBx9zrmBOG483QsPtMbUd8G/5Pmgtl7 pR2PHk2c/dSATOwseZOEsblPz6rWeJ2TQYRJC4bOSdSyVaMmuQ5XvQJ87RKW6lMk GcCm04s8XbfenGRX44uoT3feZLOiK6KVp/KGFzvpXQ47cafjPCPQBUc6Ps4A7bxf IL3hOBwZFZXFN3es2ntOqSoA0wqWIlnSNW5JiICtOHlAzaIpspWx0MxslsyPkltp ZFlOBEzng0eDhLqEG9P5w4YB5qgskAMZUXYPHZq03vUV6B0R5Ji8/0pdA== 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=k0SRJk9N+O36Mb6BBb8a+KFCArA/YJkSqsoiZZ63uUo=; b=kbfDlyq8 O5bcKWogQ2ttWIQQ72S47C0JNp+U4k802xRO4/iNlvznGmvusSbi+LtY2MxERtex lKwF+VSUZK4NL9wVqyj0Gh7stgAA0MjBji2XYfFSMiuD3LFsf7o+x89AOZSI3uOx kZMdcwqbCn5sEIKWWsx9i7eSrTAlBRCdMO31xjm3r9O2bbDYxabO7N0GOLl2Kjtw UXkKS91w0t4poYM+VYrXznjjrfIWoJD0zd7PYxaiWBHPiGFNcY4EI82HWp1zJbYd axnGuNYLrLZTf/j35T5emuDrzfz1YZGAvsfSaRmYyFwCkscDxoJTXrIlwMrfiCw2 ZsX3JFg/5j6jPQ== 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 70194E4750; Tue, 4 Dec 2018 19:42:52 -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 v3 2/8] HID: core: store the collections as a basic tree Date: Wed, 5 Dec 2018 10:42:22 +1000 Message-Id: <20181205004228.10714-3-peter.hutterer@who-t.net> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205004228.10714-1-peter.hutterer@who-t.net> References: <20181205004228.10714-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 --- No changes since v1 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.2