From patchwork Fri Jan 11 19:13:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Zabel X-Patchwork-Id: 10760579 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19B041390 for ; Fri, 11 Jan 2019 19:14:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B20A2986D for ; Fri, 11 Jan 2019 19:14:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F360D29778; Fri, 11 Jan 2019 19:14:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B03329778 for ; Fri, 11 Jan 2019 19:14:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733099AbfAKTOd (ORCPT ); Fri, 11 Jan 2019 14:14:33 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44547 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390328AbfAKTN5 (ORCPT ); Fri, 11 Jan 2019 14:13:57 -0500 Received: by mail-wr1-f67.google.com with SMTP id z5so16319335wrt.11 for ; Fri, 11 Jan 2019 11:13:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o6a7wgqlacWmNCVubNmGk3OI8SGf39Bs31wK9/vf9jo=; b=Z3vh8/OWnFjfmHHhdJ0XM+4t00xwRcwhdWAnqTdjCEAMNoY/nSJ8hWyDZd+PsvHToJ aEmsYfn6LrUctnCkb3RL2JRmQHeWdYWiZgEoj4s4qRl1MsYo8mOg0laQ4gQB6pAMC2So Jds8Jky+t1xynMLzDX5+FgNkfd92O9upzRZ6E9q+I5NaFioBqJMMaVJ0AaOepf2Xv00L EekEqbAg7c8EAdPO2qBvFKiCt7AzEj3REuYAe3touAflhm5wtg2csO8KDOwVQz2aWfDO 43qPH1fU/GzSJhxD9TlFscMebjp50hiAmK/7pf/2k0MpZpf6cJ66AOyextEH5ADNal+9 v+ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o6a7wgqlacWmNCVubNmGk3OI8SGf39Bs31wK9/vf9jo=; b=r4p9n4Ki+x1cjiSK/06wD+Xjph6xUcRY24FpScI6QdR4f5H3pu+jDqTeUqhmyXVarO RBnU9PbVrkDj2r+8tsgOng4dClTmP/5zy3qUa2at/rQ+HaQmh74kCdmfZR1fAW8p3PQp gtVXsTBwJ4vroPxbPRYykw3b1zSkvKpQjIzzmsccTKtv0MTJIQUEeKtHQGnxFjUYYXDd I9A0VC/tikishDKKP9mLepHi2kyeugZWx/Scp1l+AhblBofYV2ava4tXiUlTudZ599/h /z4Ps5WQR5+CVAVaoQnitGr0K0cGWn0hIHQIetq6ZUTNy4YTZoX55Wh0G+XyE6h7h/zR W1PA== X-Gm-Message-State: AJcUukdw4n+7w1fBBL83DI2tSVLPtSd6cuMaw5yb1SrJLuvHxNAw4vo4 cICNSv8fHS7kh//TLKwSx4Y= X-Google-Smtp-Source: ALg8bN6yXfUY0VB1HHQxoc2RC6sW9HifmSg6PsScoa2tjDnoowsgizi/bVCeF1SPeR6OKz84OGbZlA== X-Received: by 2002:adf:c612:: with SMTP id n18mr14266258wrg.174.1547234034534; Fri, 11 Jan 2019 11:13:54 -0800 (PST) Received: from ped.lan (ip5f5abcd2.dynamic.kabel-deutschland.de. [95.90.188.210]) by smtp.googlemail.com with ESMTPSA id c8sm54743557wrx.42.2019.01.11.11.13.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 11:13:53 -0800 (PST) From: Philipp Zabel To: Jiri Kosina , Benjamin Tissoires , Peter Hutterer Cc: linux-input@vger.kernel.org, Philipp Zabel Subject: [PATCH 2/2] HID: core: simplify active collection tracking Date: Fri, 11 Jan 2019 20:13:32 +0100 Message-Id: <20190111191332.13448-2-philipp.zabel@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190111191332.13448-1-philipp.zabel@gmail.com> References: <20190111191332.13448-1-philipp.zabel@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Manually tracking an active collection to set collection parents is not necessary, we just have to look one step back into the collection stack to find the correct parent. Signed-off-by: Philipp Zabel --- This could be squashed into the previous patch. --- drivers/hid/hid-core.c | 11 +++-------- include/linux/hid.h | 1 - 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 5424f7f59680..ebeb7fc50033 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -168,12 +168,12 @@ static int open_collection(struct hid_parser *parser, unsigned type) parser->device->maxcollection; collection = parser->device->collection + - parser->device->maxcollection; + parser->device->maxcollection++; collection->type = type; collection->usage = usage; collection->level = parser->collection_stack_ptr - 1; - collection->parent = parser->active_collection; - parser->active_collection = parser->device->maxcollection++; + collection->parent = (collection->level == 0) ? UINT_MAX : + parser->collection_stack[collection->level - 1]; if (type == HID_COLLECTION_APPLICATION) parser->device->maxapplication++; @@ -192,9 +192,6 @@ static int close_collection(struct hid_parser *parser) return -EINVAL; } parser->collection_stack_ptr--; - if (parser->active_collection != UINT_MAX) - parser->active_collection = - parser->device->collection[parser->active_collection].parent; return 0; } @@ -820,7 +817,6 @@ static int hid_scan_report(struct hid_device *hid) return -ENOMEM; parser->device = hid; - parser->active_collection = UINT_MAX; hid->group = HID_GROUP_GENERIC; /* @@ -1177,7 +1173,6 @@ int hid_open_report(struct hid_device *device) } parser->device = device; - parser->active_collection = UINT_MAX; end = start + size; diff --git a/include/linux/hid.h b/include/linux/hid.h index e7b1b388a990..3288b06ec6bf 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -658,7 +658,6 @@ struct hid_parser { unsigned int *collection_stack; unsigned int collection_stack_ptr; unsigned int collection_stack_size; - unsigned int active_collection; struct hid_device *device; unsigned int scan_flags; };