From patchwork Mon Jan 14 07:19:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Zabel X-Patchwork-Id: 10761687 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 071E491E for ; Mon, 14 Jan 2019 07:19:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E35622891C for ; Mon, 14 Jan 2019 07:19:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4D9C28922; Mon, 14 Jan 2019 07:19:34 +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 796E02891C for ; Mon, 14 Jan 2019 07:19:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726519AbfANHTe (ORCPT ); Mon, 14 Jan 2019 02:19:34 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33921 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726449AbfANHTd (ORCPT ); Mon, 14 Jan 2019 02:19:33 -0500 Received: by mail-wr1-f65.google.com with SMTP id j2so21637353wrw.1 for ; Sun, 13 Jan 2019 23:19:32 -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:mime-version :content-transfer-encoding; bh=BY3kN8TZhJVOdXSl7b4/j5ko00pAsl9uwRFFZV5cHds=; b=Z0M586AF3Ivg5q5ugm1O3vwxj9RZDPxkzfShy8ND/RNlrTDYI87Edt4IFq+6/oRVDv AS/NwGN6vWdGQvgITshRb69O4hxhprm85AbZlrH9ytIVwR8Mx3UuV707QSZCtsFKUjOD dyq2TJhriJrT32fkeE7Ktruj4VWJNAHNp0Nzh6FKbgRJtplZU02iDPH71hbmhOvqpo73 HwkrmMpTHqTdNfNIkjligtjj1dAK1LIO+ZWLOSpvhSgN81M24y3A/oMaTTHzhhwNZuBw 6KrnHSq/r2awJFdndoPFUYkwUAjA38gq925tTCDIwNPkp04H115xz7VHiCIZqGBH7JwJ LxmA== 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:mime-version :content-transfer-encoding; bh=BY3kN8TZhJVOdXSl7b4/j5ko00pAsl9uwRFFZV5cHds=; b=JN/FQFF4VBa3LG9BIUResTzTkOpv192c2mwdgmO4dbVzP/E7nFP8DeM6BVhaQVvK0H f9H5kPUod0zXEvJEo2MLY1T/J5SM/WuH+jIMDAMRDOywik/qL9y7wTVimQtAaJp5Gljc dnTXk+XxQm665Xu6tunJvcNrf/LicsWGvD9e2rj14DU7Conp8eBrB6HgIv7kSwZsgDDa dpuJ/ouXMp4YxAm8pjCGVZmcB9OSLt8jt/3tds3bejTdymvcgzqCS1LWq5oNJkqHpkBx 0j3M8eVNDki9De2MXlGLuwNjwKUSzOWcSjw0UxHFyn7uIsqKUieIcO5x4rylURyHkZXu l0OQ== X-Gm-Message-State: AJcUukcsnC/56nG+G2Q7LQolc6WrDVzS3xizenWfo01MdqvR7gYjoaQ2 gHW0fUAUJ2XA3CXT55FUEPwN4/YM X-Google-Smtp-Source: ALg8bN408+gFskQuYUBJuqVQSr7YO5azWoimmHB/kYZQ/hyMRrZLdA5cByNaxi1rQIPHLwrRA6l87w== X-Received: by 2002:adf:9123:: with SMTP id j32mr24200977wrj.122.1547450371693; Sun, 13 Jan 2019 23:19:31 -0800 (PST) Received: from ped.lan (ip5f5acfa6.dynamic.kabel-deutschland.de. [95.90.207.166]) by smtp.googlemail.com with ESMTPSA id k128sm35774653wmd.37.2019.01.13.23.19.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Jan 2019 23:19:30 -0800 (PST) From: Philipp Zabel To: linux-input@vger.kernel.org Cc: Jiri Kosina , Benjamin Tissoires , Peter Hutterer , Philipp Zabel Subject: [PATCH v2] HID: core: simplify active collection tracking Date: Mon, 14 Jan 2019 08:19:22 +0100 Message-Id: <20190114071922.25957-1-philipp.zabel@gmail.com> X-Mailer: git-send-email 2.20.1 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 Reviewed-by: Peter Hutterer --- Changes since v1: - Rebased onto commit ee46967fc6e ("HID: core: replace the collection tree pointers with indices"). --- drivers/hid/hid-core.c | 13 ++----------- include/linux/hid.h | 1 - 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index f9093dedf647..9993b692598f 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -173,8 +173,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_idx = parser->active_collection_idx; - parser->active_collection_idx = collection_index; + collection->parent_idx = (collection->level == 0) ? -1 : + parser->collection_stack[collection->level - 1]; if (type == HID_COLLECTION_APPLICATION) parser->device->maxapplication++; @@ -193,13 +193,6 @@ static int close_collection(struct hid_parser *parser) return -EINVAL; } parser->collection_stack_ptr--; - if (parser->active_collection_idx != -1) { - struct hid_device *device = parser->device; - struct hid_collection *c; - - c = &device->collection[parser->active_collection_idx]; - parser->active_collection_idx = c->parent_idx; - } return 0; } @@ -825,7 +818,6 @@ static int hid_scan_report(struct hid_device *hid) return -ENOMEM; parser->device = hid; - parser->active_collection_idx = -1; hid->group = HID_GROUP_GENERIC; /* @@ -1179,7 +1171,6 @@ int hid_open_report(struct hid_device *device) } parser->device = device; - parser->active_collection_idx = -1; end = start + size; diff --git a/include/linux/hid.h b/include/linux/hid.h index 992bbb7196df..f9707d1dcb58 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; - int active_collection_idx; /* device->collection */ struct hid_device *device; unsigned int scan_flags; };