From patchwork Mon Oct 9 22:34:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9994437 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E747E60216 for ; Mon, 9 Oct 2017 22:34:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9B7728823 for ; Mon, 9 Oct 2017 22:34:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9C632881E; Mon, 9 Oct 2017 22:34:38 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 6DFBC2881E for ; Mon, 9 Oct 2017 22:34:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755568AbdJIWeP (ORCPT ); Mon, 9 Oct 2017 18:34:15 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:34591 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754644AbdJIWeN (ORCPT ); Mon, 9 Oct 2017 18:34:13 -0400 Received: by mail-pf0-f196.google.com with SMTP id b85so10508843pfj.1; Mon, 09 Oct 2017 15:34:13 -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; bh=/XlB+h/WF4e0U+S1xviyV2G423JoJTSErDs1o698Bxo=; b=C+a8zWoFqVzrmmRPe3o/eKf8HUsq/beuaPzczLC2KupTuDWNXRB4mw2bFaTEdvw16w tm7awnVi4ccQgCmBmkYDfDFeYPDK1vvR10W0ulkJtzL8iQPjzz8VbbvG7Dm+GAmw8kZF r5T9hjgIDrMfeuOVpJWlSvnCeqlCLsPHf6gg+b0MXfsUtFOt1A9TxhF8kyqHVLVqaFc/ EEgpJ1dONH1x+GefWSR6HpIoWVsr8YDNh2aUya8XUAe5x5y4vc4mGC0Y3tJZqrG4nX12 lIVYe38e8uEsZuibXMKN7SPiPa5M+U1xyW/6dpmkSBx4IBxfLyp2D4LZNiRDyHXKFcsC VMiw== 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; bh=/XlB+h/WF4e0U+S1xviyV2G423JoJTSErDs1o698Bxo=; b=XbNnMWpcXBsarXOedqUVTQaAVaxPcILT8ttnV3q1Jy12IgjeUIJE2wbCJ1gaUkwZtu KuyqNXM45EvjWrIp35mWJ3c3Ravj+iaRHzvtN1npbL6EEjssXiouOKWR2RSaMtyRpkX0 2GFIWP4radf70Jo0qEt7VmJZyjWRv/cIDwKvE791m6KyXLybFibFVydRfIrvukt0WKsP SUIHxe1oSXXTKqehbXW8kR5Kz1WaRRwDPeViSQf792W04JCVFTwQthxycRFUJbSvwZUI CP60E0sv5/qR2xujJe57an53UJuA5DTNuNE2JVJUddn5IGUFyZbl2BKbZh60s+pA4n/1 ogfA== X-Gm-Message-State: AMCzsaUY1Dj6LlnsQLqwVmdDQ187LviOUsFrxOBTSKKbdt5Vku4B+yvz tUg/IJX/O48RffezjZZqy7L9/9I6 X-Google-Smtp-Source: AOwi7QDMZ5j8hki3OW3o29FrFub8qpDdcybJb/ITW4Ie1koVzvM3zZ5tEDtsloT67nKzojDdyy09KQ== X-Received: by 10.159.253.148 with SMTP id q20mr10156247pls.308.1507588452211; Mon, 09 Oct 2017 15:34:12 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([100.98.112.21]) by smtp.gmail.com with ESMTPSA id t73sm7984345pfg.94.2017.10.09.15.34.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Oct 2017 15:34:11 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Benjamin Tissoires , Jiri Kosina , Roderick Colenbrander , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] Input: factor out and export input_device_id matching code Date: Mon, 9 Oct 2017 15:34:08 -0700 Message-Id: <20171009223410.17164-1-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.14.2.920.gcf0c67979c-goog 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 Factor out and export input_match_device_id() so that modules may use it. It will be needed by joydev to blacklist accelerometers in composite devices. Signed-off-by: Dmitry Torokhov --- drivers/input/input.c | 83 +++++++++++++++++++++++---------------------------- include/linux/input.h | 3 ++ 2 files changed, 41 insertions(+), 45 deletions(-) diff --git a/drivers/input/input.c b/drivers/input/input.c index f157ad5784a1..a8d4f1653588 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -938,58 +938,51 @@ int input_set_keycode(struct input_dev *dev, } EXPORT_SYMBOL(input_set_keycode); +bool input_match_device_id(const struct input_dev *dev, + const struct input_device_id *id) +{ + if (id->flags & INPUT_DEVICE_ID_MATCH_BUS) + if (id->bustype != dev->id.bustype) + return false; + + if (id->flags & INPUT_DEVICE_ID_MATCH_VENDOR) + if (id->vendor != dev->id.vendor) + return false; + + if (id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT) + if (id->product != dev->id.product) + return false; + + if (id->flags & INPUT_DEVICE_ID_MATCH_VERSION) + if (id->version != dev->id.version) + return false; + + if (!bitmap_subset(id->evbit, dev->evbit, EV_MAX) || + !bitmap_subset(id->keybit, dev->keybit, KEY_MAX) || + !bitmap_subset(id->relbit, dev->relbit, REL_MAX) || + !bitmap_subset(id->absbit, dev->absbit, ABS_MAX) || + !bitmap_subset(id->mscbit, dev->mscbit, MSC_MAX) || + !bitmap_subset(id->ledbit, dev->ledbit, LED_MAX) || + !bitmap_subset(id->sndbit, dev->sndbit, SND_MAX) || + !bitmap_subset(id->ffbit, dev->ffbit, FF_MAX) || + !bitmap_subset(id->swbit, dev->swbit, SW_MAX)) { + return false; + } + + return true; +} +EXPORT_SYMBOL(input_match_device_id); + static const struct input_device_id *input_match_device(struct input_handler *handler, struct input_dev *dev) { const struct input_device_id *id; for (id = handler->id_table; id->flags || id->driver_info; id++) { - - if (id->flags & INPUT_DEVICE_ID_MATCH_BUS) - if (id->bustype != dev->id.bustype) - continue; - - if (id->flags & INPUT_DEVICE_ID_MATCH_VENDOR) - if (id->vendor != dev->id.vendor) - continue; - - if (id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT) - if (id->product != dev->id.product) - continue; - - if (id->flags & INPUT_DEVICE_ID_MATCH_VERSION) - if (id->version != dev->id.version) - continue; - - if (!bitmap_subset(id->evbit, dev->evbit, EV_MAX)) - continue; - - if (!bitmap_subset(id->keybit, dev->keybit, KEY_MAX)) - continue; - - if (!bitmap_subset(id->relbit, dev->relbit, REL_MAX)) - continue; - - if (!bitmap_subset(id->absbit, dev->absbit, ABS_MAX)) - continue; - - if (!bitmap_subset(id->mscbit, dev->mscbit, MSC_MAX)) - continue; - - if (!bitmap_subset(id->ledbit, dev->ledbit, LED_MAX)) - continue; - - if (!bitmap_subset(id->sndbit, dev->sndbit, SND_MAX)) - continue; - - if (!bitmap_subset(id->ffbit, dev->ffbit, FF_MAX)) - continue; - - if (!bitmap_subset(id->swbit, dev->swbit, SW_MAX)) - continue; - - if (!handler->match || handler->match(handler, dev)) + if (input_match_device_id(dev, id) && + (!handler->match || handler->match(handler, dev))) { return id; + } } return NULL; diff --git a/include/linux/input.h b/include/linux/input.h index 9b03f34807a7..066093fb8b3c 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -477,6 +477,9 @@ int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke); int input_set_keycode(struct input_dev *dev, const struct input_keymap_entry *ke); +bool input_match_device_id(const struct input_dev *dev, + const struct input_device_id *id); + void input_enable_softrepeat(struct input_dev *dev, int delay, int period); extern struct class input_class;