Message ID | 20221222-hid-v1-2-f4a6c35487a5@weissschuh.net |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp141956wrn; Wed, 21 Dec 2022 21:12:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXtJPTn7bsaKLHPGcReUFZbojV8Uw3xGRgF/G2EwoFiN63Rup7tPTxw+BRiSipEr1qsVl0YL X-Received: by 2002:a05:6402:2a04:b0:47a:f54c:1ba4 with SMTP id ey4-20020a0564022a0400b0047af54c1ba4mr4047996edb.25.1671685975649; Wed, 21 Dec 2022 21:12:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671685975; cv=none; d=google.com; s=arc-20160816; b=BPE6tFtQjEsvI/SgTjfn1hTPwgoES9PBmTz2i7flHTrsJdbJMWkxWRTZ5OlyFhjjxS oXJaRVOWHzNv5VtptCFglB4vjYB2UjWXyosKoNjJrOMpqpPWHOgSAPwgtp8osJ6BLWUg 8F9zf1GuQWScVd6z8oCYQgq0ArNR/Vf4YkEbD6i3LMOdyJPmUgEKeEmBvVVRWhJK0WE1 w5TKlYee62NSDQCiJurKfa289SVQJl9EptMXeECOF7xHZbvzvXLA2RJIiSpsOfH1v+fl /Xzcw6K1cYm+eLT8vkMqA5/1V2D+mq3h3nyLQIvvMe6oKA2lo2hyWClXRF0fnHcrHxqZ S79A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:dkim-signature :from; bh=V/oBVH86SRkjWKao6wJd2l1gzjxrx/eI5q8XGZzGRCk=; b=0zb5Sh6NPtzVOa3iJlGc8WEIYWs8m21SAQ9UumpY7QjfLRo7Z5LGq1H/toBJv+WKb2 ZDl1oGPwNlMggY2vJHW1VtKo9B2k9SnVEuRLEO23P91om7uXXm3gK9zCnIGx3YTB5Xhe 3RmB7Wirog9aG7W7Xoy6+L2bQnHtj2p7QbUsCxqyCOQ/E8DiyW8BN+RDquj/y/WtOb9N B2+0zQFekRFqBKFPU2tLTZsfcEvv/V9mK3vdI2PEof9HXYJT3BkHWwB9rN7lrwgJ7MKk kp3dwPXmO2p8zf5FL7JZT72MLePRHNa2sS7LOrS93ChS3JYrs+rgFCQJvQ5Xv7rLmrBs E9wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@weissschuh.net header.s=mail header.b=YHzejwL7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i29-20020a0564020f1d00b00479526794c6si2607766eda.15.2022.12.21.21.12.32; Wed, 21 Dec 2022 21:12:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@weissschuh.net header.s=mail header.b=YHzejwL7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235015AbiLVFL3 (ORCPT <rfc822;pacteraone@gmail.com> + 99 others); Thu, 22 Dec 2022 00:11:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234973AbiLVFK5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 22 Dec 2022 00:10:57 -0500 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E42F178A5; Wed, 21 Dec 2022 21:10:55 -0800 (PST) From: Thomas =?utf-8?q?Wei=C3=9Fschuh?= <linux@weissschuh.net> DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=weissschuh.net; s=mail; t=1671685848; bh=FtucXeOqhf/uwSmZUOmwGhFgKFDCA9qaKfFhVklXs0M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=YHzejwL7SuWZwjrhLR4DKptcjvIT0orp+tF+YwprS6dypbmp5pN0ErmSymXZ8rHaq b8qEunKXylgKdVCial+uCfm7rLoNo7q8xzz45BIpWTtgePfpw4VyOgJVJvCkOwN+9g yQ/FHPfOZM2uuJfFqb6bSYCIuDa3BOIqIjvhYnd4= Date: Thu, 22 Dec 2022 05:10:45 +0000 Subject: [PATCH 2/8] HID: usbhid: Make hid_is_usb() non-inline MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-Id: <20221222-hid-v1-2-f4a6c35487a5@weissschuh.net> References: <20221222-hid-v1-0-f4a6c35487a5@weissschuh.net> In-Reply-To: <20221222-hid-v1-0-f4a6c35487a5@weissschuh.net> To: Hans de Goede <hdegoede@redhat.com>, Jiri Kosina <jikos@kernel.org>, Benjamin Tissoires <benjamin.tissoires@redhat.com>, David Rheinsberg <david.rheinsberg@gmail.com>, Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, Luiz Augusto von Dentz <luiz.dentz@gmail.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, Thomas =?utf-8?q?Wei=C3=9Fschuh?= <linux@weissschuh.net> X-Mailer: b4 0.11.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1671685845; l=1506; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=FtucXeOqhf/uwSmZUOmwGhFgKFDCA9qaKfFhVklXs0M=; b=UB9Y4WcNg/MqRsY8fH/mjN2XW796kfEfNDKTuo1LtScaZE8nN1kABWW19n6EWmxAjQoUxpyFCdsW iDklWEpCCfNE5urMvYanl8sjuNuTpr5lCp+bnHJVX94T5Pje9X+N X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752889793723384966?= X-GMAIL-MSGID: =?utf-8?q?1752889793723384966?= |
Series |
HID: remove some unneeded exported symbols from hid.h
|
|
Commit Message
Thomas Weißschuh
Dec. 22, 2022, 5:10 a.m. UTC
By making hid_is_usb() a non-inline function the lowlevel usbhid driver
does not have to be exported anymore.
Also mark the argument as const as it is not modified.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
drivers/hid/usbhid/hid-core.c | 6 ++++++
include/linux/hid.h | 5 +----
2 files changed, 7 insertions(+), 4 deletions(-)
Comments
On Thu, Dec 22, 2022 at 6:16 AM Thomas Weißschuh <linux@weissschuh.net> wrote: > > By making hid_is_usb() a non-inline function the lowlevel usbhid driver > does not have to be exported anymore. > > Also mark the argument as const as it is not modified. > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> > --- > drivers/hid/usbhid/hid-core.c | 6 ++++++ > include/linux/hid.h | 5 +---- > 2 files changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c > index be4c731aaa65..54b0280d0073 100644 > --- a/drivers/hid/usbhid/hid-core.c > +++ b/drivers/hid/usbhid/hid-core.c > @@ -1334,6 +1334,12 @@ struct hid_ll_driver usb_hid_driver = { > }; > EXPORT_SYMBOL_GPL(usb_hid_driver); > > +bool hid_is_usb(const struct hid_device *hdev) > +{ > + return hdev->ll_driver == &usb_hid_driver; > +} > +EXPORT_SYMBOL_GPL(hid_is_usb); > + > static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *id) > { > struct usb_host_interface *interface = intf->cur_altsetting; > diff --git a/include/linux/hid.h b/include/linux/hid.h > index 8677ae38599e..e8400aa78522 100644 > --- a/include/linux/hid.h > +++ b/include/linux/hid.h > @@ -864,10 +864,7 @@ static inline bool hid_is_using_ll_driver(struct hid_device *hdev, > return hdev->ll_driver == driver; > } > > -static inline bool hid_is_usb(struct hid_device *hdev) > -{ > - return hid_is_using_ll_driver(hdev, &usb_hid_driver); > -} > +extern bool hid_is_usb(const struct hid_device *hdev); The problem here is that CONFIG_USB_HID can be set to either m or n. In the n case, you'll end up with an undefined symbol, in the m case, it won't link too if CONFIG_HID is set to Y (and it'll be quite a mess to call it if the module is not loaded yet). Cheers, Benjamin > > > #define PM_HINT_FULLON 1<<5 > #define PM_HINT_NORMAL 1<<1 > > -- > 2.39.0 >
Dec 22, 2022 16:13:06 Benjamin Tissoires <benjamin.tissoires@redhat.com>: > On Thu, Dec 22, 2022 at 6:16 AM Thomas Weißschuh <linux@weissschuh.net> wrote: >> >> By making hid_is_usb() a non-inline function the lowlevel usbhid driver >> does not have to be exported anymore. >> >> Also mark the argument as const as it is not modified. >> >> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> >> --- >> drivers/hid/usbhid/hid-core.c | 6 ++++++ >> include/linux/hid.h | 5 +---- >> 2 files changed, 7 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c >> index be4c731aaa65..54b0280d0073 100644 >> --- a/drivers/hid/usbhid/hid-core.c >> +++ b/drivers/hid/usbhid/hid-core.c >> @@ -1334,6 +1334,12 @@ struct hid_ll_driver usb_hid_driver = { >> }; >> EXPORT_SYMBOL_GPL(usb_hid_driver); >> >> +bool hid_is_usb(const struct hid_device *hdev) >> +{ >> + return hdev->ll_driver == &usb_hid_driver; >> +} >> +EXPORT_SYMBOL_GPL(hid_is_usb); >> + >> static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *id) >> { >> struct usb_host_interface *interface = intf->cur_altsetting; >> diff --git a/include/linux/hid.h b/include/linux/hid.h >> index 8677ae38599e..e8400aa78522 100644 >> --- a/include/linux/hid.h >> +++ b/include/linux/hid.h >> @@ -864,10 +864,7 @@ static inline bool hid_is_using_ll_driver(struct hid_device *hdev, >> return hdev->ll_driver == driver; >> } >> >> -static inline bool hid_is_usb(struct hid_device *hdev) >> -{ >> - return hid_is_using_ll_driver(hdev, &usb_hid_driver); >> -} >> +extern bool hid_is_usb(const struct hid_device *hdev); > > The problem here is that CONFIG_USB_HID can be set to either m or n. > In the n case, you'll end up with an undefined symbol, in the m case, > it won't link too if CONFIG_HID is set to Y (and it'll be quite a mess > to call it if the module is not loaded yet). Shouldn't we already have the same problem with the symbol usb_hid_driver itself that is defined right next to the new hid_is_usb()? Thomas >> >> #define PM_HINT_FULLON 1<<5 >> #define PM_HINT_NORMAL 1<<1 >> >> -- >> 2.39.0 >>
On Thu, Dec 22, 2022 at 10:46 PM Thomas Weißschuh <thomas@t-8ch.de> wrote: > > > Dec 22, 2022 16:13:06 Benjamin Tissoires <benjamin.tissoires@redhat.com>: > > > On Thu, Dec 22, 2022 at 6:16 AM Thomas Weißschuh <linux@weissschuh.net> wrote: > >> > >> By making hid_is_usb() a non-inline function the lowlevel usbhid driver > >> does not have to be exported anymore. > >> > >> Also mark the argument as const as it is not modified. > >> > >> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> > >> --- > >> drivers/hid/usbhid/hid-core.c | 6 ++++++ > >> include/linux/hid.h | 5 +---- > >> 2 files changed, 7 insertions(+), 4 deletions(-) > >> > >> diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c > >> index be4c731aaa65..54b0280d0073 100644 > >> --- a/drivers/hid/usbhid/hid-core.c > >> +++ b/drivers/hid/usbhid/hid-core.c > >> @@ -1334,6 +1334,12 @@ struct hid_ll_driver usb_hid_driver = { > >> }; > >> EXPORT_SYMBOL_GPL(usb_hid_driver); > >> > >> +bool hid_is_usb(const struct hid_device *hdev) > >> +{ > >> + return hdev->ll_driver == &usb_hid_driver; > >> +} > >> +EXPORT_SYMBOL_GPL(hid_is_usb); > >> + > >> static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *id) > >> { > >> struct usb_host_interface *interface = intf->cur_altsetting; > >> diff --git a/include/linux/hid.h b/include/linux/hid.h > >> index 8677ae38599e..e8400aa78522 100644 > >> --- a/include/linux/hid.h > >> +++ b/include/linux/hid.h > >> @@ -864,10 +864,7 @@ static inline bool hid_is_using_ll_driver(struct hid_device *hdev, > >> return hdev->ll_driver == driver; > >> } > >> > >> -static inline bool hid_is_usb(struct hid_device *hdev) > >> -{ > >> - return hid_is_using_ll_driver(hdev, &usb_hid_driver); > >> -} > >> +extern bool hid_is_usb(const struct hid_device *hdev); > > > > The problem here is that CONFIG_USB_HID can be set to either m or n. > > In the n case, you'll end up with an undefined symbol, in the m case, > > it won't link too if CONFIG_HID is set to Y (and it'll be quite a mess > > to call it if the module is not loaded yet). > > Shouldn't we already have the same problem with > the symbol usb_hid_driver itself that is defined > right next to the new hid_is_usb()? Yeah, sorry, my bad. All of the callers of this function are modules which depend on CONFIG_USB_HID in the Kconfig, so we should be good. Sorry for the noise. I shouldn't do reviews at 10pm :( Cheers, Benjamin > > Thomas > > >> > >> #define PM_HINT_FULLON 1<<5 > >> #define PM_HINT_NORMAL 1<<1 > >> > >> -- > >> 2.39.0 > >> >
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index be4c731aaa65..54b0280d0073 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -1334,6 +1334,12 @@ struct hid_ll_driver usb_hid_driver = { }; EXPORT_SYMBOL_GPL(usb_hid_driver); +bool hid_is_usb(const struct hid_device *hdev) +{ + return hdev->ll_driver == &usb_hid_driver; +} +EXPORT_SYMBOL_GPL(hid_is_usb); + static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_host_interface *interface = intf->cur_altsetting; diff --git a/include/linux/hid.h b/include/linux/hid.h index 8677ae38599e..e8400aa78522 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -864,10 +864,7 @@ static inline bool hid_is_using_ll_driver(struct hid_device *hdev, return hdev->ll_driver == driver; } -static inline bool hid_is_usb(struct hid_device *hdev) -{ - return hid_is_using_ll_driver(hdev, &usb_hid_driver); -} +extern bool hid_is_usb(const struct hid_device *hdev); #define PM_HINT_FULLON 1<<5 #define PM_HINT_NORMAL 1<<1