From patchwork Fri Jul 27 20:19:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel M. Lambea" X-Patchwork-Id: 10547697 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 CC2A2139A for ; Fri, 27 Jul 2018 20:19:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD0472C544 for ; Fri, 27 Jul 2018 20:19:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A21962C54A; Fri, 27 Jul 2018 20:19:23 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 3ABFE2C547 for ; Fri, 27 Jul 2018 20:19:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389386AbeG0Vmv (ORCPT ); Fri, 27 Jul 2018 17:42:51 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:51796 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389416AbeG0Vmv (ORCPT ); Fri, 27 Jul 2018 17:42:51 -0400 Received: by mail-wm0-f65.google.com with SMTP id y2-v6so6488938wma.1 for ; Fri, 27 Jul 2018 13:19:21 -0700 (PDT) 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; bh=DJkWf525bU+xPr8bw3i8E+1TS9BtNSEATftTxl1OflM=; b=vfsBKCKiqbK5UNVlO2ZvTJ39JgBypBCE2RZTmSZJzrRrt324zO9COQL5YWoYpj60lK dA+cAh59PWb0tdklw2vyZGB8EltxPzH+F86U4lg7usHjssJMdmv5xASL5guHcTjtABBM mho7dItD1vREc9c7QS6pzLG8xhJY/laVA6wSZklfEJpnYS9vez8JG4/cqfcg3zNOGaZI 0sRqCaPxIsaw/NQvzhjXBJg8XlQprFUNIB2q2PCwDverTQMX9qcYvecowmLaVSeuAZSy dvl5IA+mbmz9aTLDCM0wHM8U3aji9yX/TkQXRqT5k6k9yoi9/CARSHtlzo+d9Pbo30xU BBRg== 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; bh=DJkWf525bU+xPr8bw3i8E+1TS9BtNSEATftTxl1OflM=; b=CJ2svwhVYMyx6HMeTaRyDftucPYsKOAGal/DTQ5M+1LP7M07UkY/g9jhuM6BiFHu8T XZYxhe8JMcmvg/H9ewEUwivysNLSdn5u3ckwWnnEX1v/UeXYHPYEU2Mv+UHegsM2YGCF VPQDIGRFXVZ1WB8wJzz34rTzIWgKQ3OPQiu8coeOYwyGhmum48qPELojFllyMfV6HvWY hvyx3iZrQThQxAPPghBAQKOl1TTWX9DR1VEksF/7F2nhJ/0kPj3wnRwf6FVo6/BfFglX 4BSrFM4S/aHy20iqQb6KAiqDioxc9hzD+Kzzyc+QCbllrUMgRIGNqNof3a+ANFxzFCzB 7/og== X-Gm-Message-State: AOUpUlHwkYQkdAIUpZ/sqLL0kAGUgGNnOyQMunJ4jD8CnDoORSVcepne rhIU7uGSz+uet5qPoWJfoCc= X-Google-Smtp-Source: AAOMgpefXTNZOA9ZG9IWix55zxCtbf/cC5o+1CnGQJbpqYEudJUPwuStgL90V2AAe3hLcjbhXbnHhQ== X-Received: by 2002:a1c:5f56:: with SMTP id t83-v6mr5842502wmb.27.1532722760821; Fri, 27 Jul 2018 13:19:20 -0700 (PDT) Received: from localhost.localdomain (86.red-83-42-60.dynamicip.rima-tde.net. [83.42.60.86]) by smtp.gmail.com with ESMTPSA id z5-v6sm6991296wrv.2.2018.07.27.13.19.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jul 2018 13:19:20 -0700 (PDT) From: "Daniel M. Lambea" To: Jiri Kosina Cc: Benjamin Tissoires , linux-input@vger.kernel.org Subject: [PATCH 2/2] HID: cougar: Stop processing vendor events on hid-core Date: Fri, 27 Jul 2018 21:19:12 +0100 Message-Id: <20180727201912.6752-2-dmlambea@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180727201912.6752-1-dmlambea@gmail.com> References: <20180727201912.6752-1-dmlambea@gmail.com> 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 Special key events received by the custom vendor's hdev are translated to key events on the kbd iface's input device, so their processing must not continue. Return -EPERM from raw_event handler to effectively stop source events from being processed in hid-core. Signed-off-by: Daniel M. Lambea --- This patch series is to be applied on top of branch for-4.19/cougar. drivers/hid/hid-cougar.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/hid/hid-cougar.c b/drivers/hid/hid-cougar.c index 910ef4312157..3f0916b64c60 100644 --- a/drivers/hid/hid-cougar.c +++ b/drivers/hid/hid-cougar.c @@ -261,26 +261,32 @@ static int cougar_raw_event(struct hid_device *hdev, struct hid_report *report, u8 *data, int size) { struct cougar *cougar; + struct cougar_shared *shared; unsigned char code, action; int i; cougar = hid_get_drvdata(hdev); - if (!cougar->special_intf || !cougar->shared || - !cougar->shared->input || !cougar->shared->enabled) + shared = cougar->shared; + if (!cougar->special_intf || !shared) return 0; + if (!shared->enabled || !shared->input) + return -EPERM; + code = data[COUGAR_FIELD_CODE]; action = data[COUGAR_FIELD_ACTION]; for (i = 0; cougar_mapping[i][0]; i++) { if (code == cougar_mapping[i][0]) { - input_event(cougar->shared->input, EV_KEY, + input_event(shared->input, EV_KEY, cougar_mapping[i][1], action); - input_sync(cougar->shared->input); - return 0; + input_sync(shared->input); + return -EPERM; } } - hid_warn(hdev, "unmapped special key code %x: ignoring\n", code); - return 0; + /* Avoid warnings on the same unmapped key twice */ + if (action != 0) + hid_warn(hdev, "unmapped special key code %0x: ignoring\n", code); + return -EPERM; } static void cougar_remove(struct hid_device *hdev)