From patchwork Mon Jul 24 16:46:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 9859803 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 51819600F5 for ; Mon, 24 Jul 2017 16:46:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4357028573 for ; Mon, 24 Jul 2017 16:46:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3811128585; Mon, 24 Jul 2017 16:46:35 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 8C2AD28573 for ; Mon, 24 Jul 2017 16:46:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754358AbdGXQqd (ORCPT ); Mon, 24 Jul 2017 12:46:33 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:37173 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753856AbdGXQqc (ORCPT ); Mon, 24 Jul 2017 12:46:32 -0400 Received: by mail-qk0-f193.google.com with SMTP id q130so10409365qka.4 for ; Mon, 24 Jul 2017 09:46:32 -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=+bd6VhwuCPRUZjfyqBxsz4YJsZOi85dzUxtUsLNmR5g=; b=Q03EmNVLc9GNpyZSWLWk87TXY2ZB0PzmhNPfTZ2z0l9Wi/mNK/gkjS8px/zDKkW0Th aGbMxQmTQRS4morZzsJ4B1x8uoDlW86qgB9AskAg+XBRvgcDlYQCn59ezvMTgyMQWHIq u8RMwEAPFLNiASHncjur1I8XjEeB6OsYU8Vl5ytIwnaZuDw+c8MS/4uTwwmpTUqe472q YwZCwFqi1yvLHA+w6dpMTswIF/wzuc40A3WIQOv/HcQrccNfg7bf+2bpz2VZpNzmTO92 zGuedwMFb4WXyQ4zGhhj1Hso0vs0kOO3xnSFxMUUOrrAAOJth0yJeDFYJ6YCAzAwyGR5 qgsA== 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=+bd6VhwuCPRUZjfyqBxsz4YJsZOi85dzUxtUsLNmR5g=; b=aMigup00HkOVbBaugZ6pByBmFoECNkd617W8qweaPXnZwWSzUGfHWbLwYH8WFlnBqy Zlm6D6wh/MFdD7fcmDkUsHFLA4RXaUYthpYjIGjGLlXP7IJ+U5MD93r3roMFqV6CFHPm WKfLWu513xpajYy7eUdMWDvOGMJRL0Ecs99W/TzaOCqkygPfCNdZwZkzH2jnP/4JMwxY WloCgcHgrRGrtqR+mcv4PUYCLyk0VX/chLv17s4yJ1knm8KRF7fG8KLhJYeX2raDjhsm EDGC4etkoJa1fA3euZ6CrZK963lWxWw3zTsH1nYuMpnoBKuIzsd7XhdArot4DkJBxpHF rPFA== X-Gm-Message-State: AIVw112yUqZkP8d9Az/XJQb+AaiYLPtiBsAMrTYJ2CHGYk2aHu9+H7Q4 /11j4PFAIZ1Sx16KMYg= X-Received: by 10.55.151.195 with SMTP id z186mr21994134qkd.100.1500914791534; Mon, 24 Jul 2017 09:46:31 -0700 (PDT) Received: from wacom-arch2.corp.onewacom.com ([50.225.60.4]) by smtp.gmail.com with ESMTPSA id d125sm8244239qkg.43.2017.07.24.09.46.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jul 2017 09:46:30 -0700 (PDT) From: Jason Gerecke To: linux-input@vger.kernel.org, Jiri Kosina Cc: Benjamin Tissoires , Ping Cheng , Aaron Skomra , Jason Gerecke , Jason Gerecke Subject: [PATCH v4 1/2] HID: introduce hid_is_using_ll_driver Date: Mon, 24 Jul 2017 09:46:18 -0700 Message-Id: <20170724164619.29228-1-killertofu@gmail.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: References: 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 Although HID itself is transport-agnostic, occasionally a driver may want to interact with the low-level transport that a device is connected through. To do this, we need to know what kind of bus is in use. The first guess may be to look at the 'bus' field of the 'struct hid_device', but this field may be emulated in some cases (e.g. uhid). More ideally, we can check which ll_driver a device is using. This function introduces a 'hid_is_using_ll_driver' function and makes the 'struct hid_ll_driver' of the four most common transports accessible through hid.h. Signed-off-by: Jason Gerecke --- drivers/hid/i2c-hid/i2c-hid.c | 3 ++- drivers/hid/uhid.c | 3 ++- drivers/hid/usbhid/hid-core.c | 3 ++- include/linux/hid.h | 11 +++++++++++ net/bluetooth/hidp/core.c | 3 ++- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index fb55fb4c39fc..fef2cfafcedd 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c @@ -794,7 +794,7 @@ static int i2c_hid_power(struct hid_device *hid, int lvl) return 0; } -static struct hid_ll_driver i2c_hid_ll_driver = { +struct hid_ll_driver i2c_hid_ll_driver = { .parse = i2c_hid_parse, .start = i2c_hid_start, .stop = i2c_hid_stop, @@ -804,6 +804,7 @@ static struct hid_ll_driver i2c_hid_ll_driver = { .output_report = i2c_hid_output_report, .raw_request = i2c_hid_raw_request, }; +EXPORT_SYMBOL_GPL(i2c_hid_ll_driver); static int i2c_hid_init_irq(struct i2c_client *client) { diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c index 7f8ff39ed44b..6f819f144cb4 100644 --- a/drivers/hid/uhid.c +++ b/drivers/hid/uhid.c @@ -369,7 +369,7 @@ static int uhid_hid_output_report(struct hid_device *hid, __u8 *buf, return uhid_hid_output_raw(hid, buf, count, HID_OUTPUT_REPORT); } -static struct hid_ll_driver uhid_hid_driver = { +struct hid_ll_driver uhid_hid_driver = { .start = uhid_hid_start, .stop = uhid_hid_stop, .open = uhid_hid_open, @@ -378,6 +378,7 @@ static struct hid_ll_driver uhid_hid_driver = { .raw_request = uhid_hid_raw_request, .output_report = uhid_hid_output_report, }; +EXPORT_SYMBOL_GPL(uhid_hid_driver); #ifdef CONFIG_COMPAT diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 83772fa7d92a..9bef8ece135f 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -1256,7 +1256,7 @@ static int usbhid_idle(struct hid_device *hid, int report, int idle, return hid_set_idle(dev, ifnum, report, idle); } -static struct hid_ll_driver usb_hid_driver = { +struct hid_ll_driver usb_hid_driver = { .parse = usbhid_parse, .start = usbhid_start, .stop = usbhid_stop, @@ -1269,6 +1269,7 @@ static struct hid_ll_driver usb_hid_driver = { .output_report = usbhid_output_report, .idle = usbhid_idle, }; +EXPORT_SYMBOL_GPL(usb_hid_driver); static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *id) { diff --git a/include/linux/hid.h b/include/linux/hid.h index 5be325d890d9..a09c5f37dda9 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -765,6 +765,17 @@ struct hid_ll_driver { int (*idle)(struct hid_device *hdev, int report, int idle, int reqtype); }; +extern struct hid_ll_driver i2c_hid_ll_driver; +extern struct hid_ll_driver hidp_hid_driver; +extern struct hid_ll_driver uhid_hid_driver; +extern struct hid_ll_driver usb_hid_driver; + +static inline bool hid_is_using_ll_driver(struct hid_device *hdev, + struct hid_ll_driver *driver) +{ + return hdev->ll_driver == driver; +} + #define PM_HINT_FULLON 1<<5 #define PM_HINT_NORMAL 1<<1 diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 0bec4588c3c8..1c3615636bd0 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -733,7 +733,7 @@ static void hidp_stop(struct hid_device *hid) hid->claimed = 0; } -static struct hid_ll_driver hidp_hid_driver = { +struct hid_ll_driver hidp_hid_driver = { .parse = hidp_parse, .start = hidp_start, .stop = hidp_stop, @@ -742,6 +742,7 @@ static struct hid_ll_driver hidp_hid_driver = { .raw_request = hidp_raw_request, .output_report = hidp_output_report, }; +EXPORT_SYMBOL_GPL(hidp_hid_driver); /* This function sets up the hid device. It does not add it to the HID system. That is done in hidp_add_connection(). */