[hid,v11,01/14] HID: Kconfig: split HID support and hid-core compilation

Message ID 20221025093458.457089-2-benjamin.tissoires@redhat.com
State New
Headers
Series Introduce eBPF support for HID devices |

Commit Message

Benjamin Tissoires Oct. 25, 2022, 9:34 a.m. UTC
  Currently, we step into drivers/hid/ based on the value of
CONFIG_HID.

However, that value is a tristate, meaning that it can be a module.

As per the documentation, if we jump into the subdirectory by
following an obj-m, we can not compile anything inside that
subdirectory in vmlinux. It is considered as a bug.

To make things more friendly to HID-BPF, split HID (the HID core
parameter) from HID_SUPPORT (do we want any kind of HID support in the
system?), and make this new config a boolean.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

---

no changes in v11

no changes in v10

no changes in v9

no changes in v8

new in v7
---
 drivers/Makefile    |  2 +-
 drivers/hid/Kconfig | 20 +++++++++++---------
 2 files changed, 12 insertions(+), 10 deletions(-)
  

Comments

kernel test robot Oct. 29, 2022, 1:55 p.m. UTC | #1
Hi Benjamin,

I love your patch! Yet something to improve:

[auto build test ERROR on hid/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Benjamin-Tissoires/Introduce-eBPF-support-for-HID-devices/20221025-173852
base:   https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git master
patch link:    https://lore.kernel.org/r/20221025093458.457089-2-benjamin.tissoires%40redhat.com
patch subject: [PATCH hid v11 01/14] HID: Kconfig: split HID support and hid-core compilation
config: s390-zfcpdump_defconfig
compiler: s390-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/b6e78c340cbaf82c96ab3148db0b13f737abe8d7
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Benjamin-Tissoires/Introduce-eBPF-support-for-HID-devices/20221025-173852
        git checkout b6e78c340cbaf82c96ab3148db0b13f737abe8d7
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=s390 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   s390-linux-ld: drivers/hid/hid-a4tech.o: in function `hid_parse':
>> include/linux/hid.h:1094: undefined reference to `hid_open_report'
   s390-linux-ld: drivers/hid/hid-a4tech.o: in function `a4_probe':
>> drivers/hid/hid-a4tech.c:134: undefined reference to `hid_hw_start'
   s390-linux-ld: drivers/hid/hid-a4tech.o: in function `a4_driver_init':
>> drivers/hid/hid-a4tech.c:164: undefined reference to `__hid_register_driver'
   s390-linux-ld: drivers/hid/hid-a4tech.o: in function `a4_driver_exit':
>> drivers/hid/hid-a4tech.c:164: undefined reference to `hid_unregister_driver'
   s390-linux-ld: drivers/hid/hid-belkin.o: in function `hid_parse':
>> include/linux/hid.h:1094: undefined reference to `hid_open_report'
   s390-linux-ld: drivers/hid/hid-belkin.o: in function `belkin_probe':
>> drivers/hid/hid-belkin.c:59: undefined reference to `hid_hw_start'
   s390-linux-ld: drivers/hid/hid-belkin.o: in function `belkin_driver_init':
>> drivers/hid/hid-belkin.c:86: undefined reference to `__hid_register_driver'
   s390-linux-ld: drivers/hid/hid-belkin.o: in function `belkin_driver_exit':
>> drivers/hid/hid-belkin.c:86: undefined reference to `hid_unregister_driver'
   s390-linux-ld: drivers/hid/hid-cherry.o: in function `ch_driver_init':
>> drivers/hid/hid-cherry.c:69: undefined reference to `__hid_register_driver'
   s390-linux-ld: drivers/hid/hid-cherry.o: in function `ch_driver_exit':
>> drivers/hid/hid-cherry.c:69: undefined reference to `hid_unregister_driver'
   s390-linux-ld: drivers/hid/hid-cypress.o: in function `hid_parse':
>> include/linux/hid.h:1094: undefined reference to `hid_open_report'
   s390-linux-ld: drivers/hid/hid-cypress.o: in function `cp_probe':
>> drivers/hid/hid-cypress.c:141: undefined reference to `hid_hw_start'
   s390-linux-ld: drivers/hid/hid-cypress.o: in function `cp_driver_init':
>> drivers/hid/hid-cypress.c:177: undefined reference to `__hid_register_driver'
   s390-linux-ld: drivers/hid/hid-cypress.o: in function `cp_driver_exit':
>> drivers/hid/hid-cypress.c:177: undefined reference to `hid_unregister_driver'
   s390-linux-ld: drivers/hid/hid-ezkey.o: in function `ez_driver_init':
>> drivers/hid/hid-ezkey.c:76: undefined reference to `__hid_register_driver'
   s390-linux-ld: drivers/hid/hid-ezkey.o: in function `ez_driver_exit':
>> drivers/hid/hid-ezkey.c:76: undefined reference to `hid_unregister_driver'
   s390-linux-ld: drivers/hid/hid-ite.o: in function `ite_probe':
>> drivers/hid/hid-ite.c:99: undefined reference to `hid_open_report'
>> s390-linux-ld: drivers/hid/hid-ite.c:103: undefined reference to `hid_hw_start'
   s390-linux-ld: drivers/hid/hid-ite.o: in function `ite_driver_init':
>> drivers/hid/hid-ite.c:136: undefined reference to `__hid_register_driver'
   s390-linux-ld: drivers/hid/hid-ite.o: in function `ite_driver_exit':
>> drivers/hid/hid-ite.c:136: undefined reference to `hid_unregister_driver'
   s390-linux-ld: drivers/hid/hid-kensington.o: in function `ks_driver_init':
   drivers/hid/hid-kensington.c:47: undefined reference to `__hid_register_driver'
   s390-linux-ld: drivers/hid/hid-kensington.o: in function `ks_driver_exit':
   drivers/hid/hid-kensington.c:47: undefined reference to `hid_unregister_driver'
   s390-linux-ld: drivers/hid/hid-microsoft.o: in function `ms_remove':
   drivers/hid/hid-microsoft.c:409: undefined reference to `hid_hw_stop'
   s390-linux-ld: drivers/hid/hid-microsoft.o: in function `hid_parse':
   include/linux/hid.h:1094: undefined reference to `hid_open_report'
   s390-linux-ld: drivers/hid/hid-microsoft.o: in function `ms_probe':
   drivers/hid/hid-microsoft.c:391: undefined reference to `hid_hw_start'
   s390-linux-ld: drivers/hid/hid-microsoft.o: in function `ms_ff_worker':
   drivers/hid/hid-microsoft.c:302: undefined reference to `hid_hw_output_report'
   s390-linux-ld: drivers/hid/hid-microsoft.o: in function `ms_driver_init':
   drivers/hid/hid-microsoft.c:467: undefined reference to `__hid_register_driver'
   s390-linux-ld: drivers/hid/hid-microsoft.o: in function `ms_driver_exit':
   drivers/hid/hid-microsoft.c:467: undefined reference to `hid_unregister_driver'
   s390-linux-ld: drivers/hid/hid-monterey.o: in function `mr_driver_init':
   drivers/hid/hid-monterey.c:63: undefined reference to `__hid_register_driver'
   s390-linux-ld: drivers/hid/hid-monterey.o: in function `mr_driver_exit':
   drivers/hid/hid-monterey.c:63: undefined reference to `hid_unregister_driver'
   s390-linux-ld: drivers/hid/hid-redragon.o: in function `redragon_driver_init':
   drivers/hid/hid-redragon.c:60: undefined reference to `__hid_register_driver'
   s390-linux-ld: drivers/hid/hid-redragon.o: in function `redragon_driver_exit':
   drivers/hid/hid-redragon.c:60: undefined reference to `hid_unregister_driver'
   pahole: .tmp_vmlinux.btf: No such file or directory
   .btf.vmlinux.bin.o: file not recognized: file format not recognized


vim +1094 include/linux/hid.h

022e8c4d08b3b0 Jiri Slaby     2008-05-16  1082  
c500c9714011ed Jiri Slaby     2008-05-16  1083  /**
c500c9714011ed Jiri Slaby     2008-05-16  1084   * hid_parse - parse HW reports
c500c9714011ed Jiri Slaby     2008-05-16  1085   *
c500c9714011ed Jiri Slaby     2008-05-16  1086   * @hdev: hid device
c500c9714011ed Jiri Slaby     2008-05-16  1087   *
c500c9714011ed Jiri Slaby     2008-05-16  1088   * Call this from probe after you set up the device (if needed). Your
c500c9714011ed Jiri Slaby     2008-05-16  1089   * report_fixup will be called (if non-NULL) after reading raw report from
c500c9714011ed Jiri Slaby     2008-05-16  1090   * device before passing it to hid layer for real parsing.
c500c9714011ed Jiri Slaby     2008-05-16  1091   */
c500c9714011ed Jiri Slaby     2008-05-16  1092  static inline int __must_check hid_parse(struct hid_device *hdev)
c500c9714011ed Jiri Slaby     2008-05-16  1093  {
a7197c2e4120ce Henrik Rydberg 2012-04-22 @1094  	return hid_open_report(hdev);
c500c9714011ed Jiri Slaby     2008-05-16  1095  }
c500c9714011ed Jiri Slaby     2008-05-16  1096
  
kernel test robot Oct. 29, 2022, 5:57 p.m. UTC | #2
Hi Benjamin,

I love your patch! Yet something to improve:

[auto build test ERROR on hid/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Benjamin-Tissoires/Introduce-eBPF-support-for-HID-devices/20221025-173852
base:   https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git master
patch link:    https://lore.kernel.org/r/20221025093458.457089-2-benjamin.tissoires%40redhat.com
patch subject: [PATCH hid v11 01/14] HID: Kconfig: split HID support and hid-core compilation
config: i386-randconfig-a004-20221003
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/b6e78c340cbaf82c96ab3148db0b13f737abe8d7
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Benjamin-Tissoires/Introduce-eBPF-support-for-HID-devices/20221025-173852
        git checkout b6e78c340cbaf82c96ab3148db0b13f737abe8d7
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   ld: drivers/hid/hid-a4tech.o: in function `hid_parse':
   include/linux/hid.h:1094: undefined reference to `hid_open_report'
   ld: drivers/hid/hid-a4tech.o: in function `a4_probe':
   drivers/hid/hid-a4tech.c:134: undefined reference to `hid_hw_start'
   ld: drivers/hid/hid-a4tech.o: in function `a4_driver_init':
   drivers/hid/hid-a4tech.c:164: undefined reference to `__hid_register_driver'
   ld: drivers/hid/hid-a4tech.o: in function `a4_driver_exit':
   drivers/hid/hid-a4tech.c:164: undefined reference to `hid_unregister_driver'
   ld: drivers/hid/hid-apple.o: in function `apple_remove':
>> drivers/hid/hid-apple.c:851: undefined reference to `hid_hw_stop'
   ld: drivers/hid/hid-apple.o: in function `apple_backlight_set':
>> drivers/hid/hid-apple.c:736: undefined reference to `hid_hw_raw_request'
   ld: drivers/hid/hid-apple.o: in function `apple_backlight_init':
   drivers/hid/hid-apple.c:765: undefined reference to `hid_hw_raw_request'
   ld: drivers/hid/hid-apple.o: in function `hid_parse':
   include/linux/hid.h:1094: undefined reference to `hid_open_report'
   ld: drivers/hid/hid-apple.o: in function `apple_probe':
>> drivers/hid/hid-apple.c:828: undefined reference to `hid_hw_start'
   ld: drivers/hid/hid-apple.o: in function `apple_driver_init':
>> drivers/hid/hid-apple.c:1068: undefined reference to `__hid_register_driver'
   ld: drivers/hid/hid-apple.o: in function `apple_driver_exit':
>> drivers/hid/hid-apple.c:1068: undefined reference to `hid_unregister_driver'
   ld: drivers/hid/hid-belkin.o: in function `hid_parse':
   include/linux/hid.h:1094: undefined reference to `hid_open_report'
   ld: drivers/hid/hid-belkin.o: in function `belkin_probe':
   drivers/hid/hid-belkin.c:59: undefined reference to `hid_hw_start'
   ld: drivers/hid/hid-belkin.o: in function `belkin_driver_init':
   drivers/hid/hid-belkin.c:86: undefined reference to `__hid_register_driver'
   ld: drivers/hid/hid-belkin.o: in function `belkin_driver_exit':
   drivers/hid/hid-belkin.c:86: undefined reference to `hid_unregister_driver'
   ld: drivers/hid/hid-cherry.o: in function `ch_driver_init':
   drivers/hid/hid-cherry.c:69: undefined reference to `__hid_register_driver'
   ld: drivers/hid/hid-cherry.o: in function `ch_driver_exit':
   drivers/hid/hid-cherry.c:69: undefined reference to `hid_unregister_driver'
   ld: drivers/hid/hid-cypress.o: in function `hid_parse':
   include/linux/hid.h:1094: undefined reference to `hid_open_report'
   ld: drivers/hid/hid-cypress.o: in function `cp_probe':
   drivers/hid/hid-cypress.c:141: undefined reference to `hid_hw_start'
   ld: drivers/hid/hid-cypress.o: in function `cp_driver_init':
   drivers/hid/hid-cypress.c:177: undefined reference to `__hid_register_driver'
   ld: drivers/hid/hid-cypress.o: in function `cp_driver_exit':
   drivers/hid/hid-cypress.c:177: undefined reference to `hid_unregister_driver'
   ld: drivers/hid/hid-ezkey.o: in function `ez_driver_init':
   drivers/hid/hid-ezkey.c:76: undefined reference to `__hid_register_driver'
   ld: drivers/hid/hid-ezkey.o: in function `ez_driver_exit':
   drivers/hid/hid-ezkey.c:76: undefined reference to `hid_unregister_driver'
   ld: drivers/hid/hid-ite.o: in function `ite_probe':
   drivers/hid/hid-ite.c:99: undefined reference to `hid_open_report'
>> ld: drivers/hid/hid-ite.c:103: undefined reference to `hid_hw_start'
   ld: drivers/hid/hid-ite.o: in function `ite_driver_init':
   drivers/hid/hid-ite.c:136: undefined reference to `__hid_register_driver'
   ld: drivers/hid/hid-ite.o: in function `ite_driver_exit':
   drivers/hid/hid-ite.c:136: undefined reference to `hid_unregister_driver'
   ld: drivers/hid/hid-kensington.o: in function `ks_driver_init':
   drivers/hid/hid-kensington.c:47: undefined reference to `__hid_register_driver'
   ld: drivers/hid/hid-kensington.o: in function `ks_driver_exit':
   drivers/hid/hid-kensington.c:47: undefined reference to `hid_unregister_driver'
   ld: drivers/hid/hid-microsoft.o: in function `ms_remove':
   drivers/hid/hid-microsoft.c:409: undefined reference to `hid_hw_stop'
   ld: drivers/hid/hid-microsoft.o: in function `ms_ff_worker':
   drivers/hid/hid-microsoft.c:302: undefined reference to `hid_hw_output_report'
   ld: drivers/hid/hid-microsoft.o: in function `hid_parse':
   include/linux/hid.h:1094: undefined reference to `hid_open_report'
   ld: drivers/hid/hid-microsoft.o: in function `ms_probe':
   drivers/hid/hid-microsoft.c:391: undefined reference to `hid_hw_start'
   ld: drivers/hid/hid-microsoft.o: in function `ms_driver_init':
   drivers/hid/hid-microsoft.c:467: undefined reference to `__hid_register_driver'
   ld: drivers/hid/hid-microsoft.o: in function `ms_driver_exit':
   drivers/hid/hid-microsoft.c:467: undefined reference to `hid_unregister_driver'
   ld: drivers/hid/hid-monterey.o: in function `mr_driver_init':
   drivers/hid/hid-monterey.c:63: undefined reference to `__hid_register_driver'
   ld: drivers/hid/hid-monterey.o: in function `mr_driver_exit':
   drivers/hid/hid-monterey.c:63: undefined reference to `hid_unregister_driver'
   ld: drivers/hid/hid-redragon.o: in function `redragon_driver_init':
   drivers/hid/hid-redragon.c:60: undefined reference to `__hid_register_driver'
   ld: drivers/hid/hid-redragon.o: in function `redragon_driver_exit':
   drivers/hid/hid-redragon.c:60: undefined reference to `hid_unregister_driver'
   pahole: .tmp_vmlinux.btf: No such file or directory
   .btf.vmlinux.bin.o: file not recognized: file format not recognized


vim +851 drivers/hid/hid-apple.c

9018eacbe623b2 Paul Pawlowski     2022-02-03  721  
9018eacbe623b2 Paul Pawlowski     2022-02-03  722  static int apple_backlight_set(struct hid_device *hdev, u16 value, u16 rate)
9018eacbe623b2 Paul Pawlowski     2022-02-03  723  {
9018eacbe623b2 Paul Pawlowski     2022-02-03  724  	int ret = 0;
9018eacbe623b2 Paul Pawlowski     2022-02-03  725  	struct apple_backlight_set_report *rep;
9018eacbe623b2 Paul Pawlowski     2022-02-03  726  
9018eacbe623b2 Paul Pawlowski     2022-02-03  727  	rep = kmalloc(sizeof(*rep), GFP_KERNEL);
9018eacbe623b2 Paul Pawlowski     2022-02-03  728  	if (rep == NULL)
9018eacbe623b2 Paul Pawlowski     2022-02-03  729  		return -ENOMEM;
9018eacbe623b2 Paul Pawlowski     2022-02-03  730  
9018eacbe623b2 Paul Pawlowski     2022-02-03  731  	rep->report_id = 0xB0;
9018eacbe623b2 Paul Pawlowski     2022-02-03  732  	rep->version = 1;
9018eacbe623b2 Paul Pawlowski     2022-02-03  733  	rep->backlight = value;
9018eacbe623b2 Paul Pawlowski     2022-02-03  734  	rep->rate = rate;
9018eacbe623b2 Paul Pawlowski     2022-02-03  735  
9018eacbe623b2 Paul Pawlowski     2022-02-03 @736  	ret = hid_hw_raw_request(hdev, 0xB0u, (u8 *) rep, sizeof(*rep),
9018eacbe623b2 Paul Pawlowski     2022-02-03  737  				 HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
9018eacbe623b2 Paul Pawlowski     2022-02-03  738  
9018eacbe623b2 Paul Pawlowski     2022-02-03  739  	kfree(rep);
9018eacbe623b2 Paul Pawlowski     2022-02-03  740  	return ret;
9018eacbe623b2 Paul Pawlowski     2022-02-03  741  }
9018eacbe623b2 Paul Pawlowski     2022-02-03  742  
9018eacbe623b2 Paul Pawlowski     2022-02-03  743  static int apple_backlight_led_set(struct led_classdev *led_cdev,
9018eacbe623b2 Paul Pawlowski     2022-02-03  744  	enum led_brightness brightness)
9018eacbe623b2 Paul Pawlowski     2022-02-03  745  {
9018eacbe623b2 Paul Pawlowski     2022-02-03  746  	struct apple_sc_backlight *backlight = container_of(led_cdev,
9018eacbe623b2 Paul Pawlowski     2022-02-03  747  							    struct apple_sc_backlight, cdev);
9018eacbe623b2 Paul Pawlowski     2022-02-03  748  
9018eacbe623b2 Paul Pawlowski     2022-02-03  749  	return apple_backlight_set(backlight->hdev, brightness, 0);
9018eacbe623b2 Paul Pawlowski     2022-02-03  750  }
9018eacbe623b2 Paul Pawlowski     2022-02-03  751  
9018eacbe623b2 Paul Pawlowski     2022-02-03  752  static int apple_backlight_init(struct hid_device *hdev)
9018eacbe623b2 Paul Pawlowski     2022-02-03  753  {
9018eacbe623b2 Paul Pawlowski     2022-02-03  754  	int ret;
9018eacbe623b2 Paul Pawlowski     2022-02-03  755  	struct apple_sc *asc = hid_get_drvdata(hdev);
9018eacbe623b2 Paul Pawlowski     2022-02-03  756  	struct apple_backlight_config_report *rep;
9018eacbe623b2 Paul Pawlowski     2022-02-03  757  
9018eacbe623b2 Paul Pawlowski     2022-02-03  758  	if (!apple_backlight_check_support(hdev))
9018eacbe623b2 Paul Pawlowski     2022-02-03  759  		return -EINVAL;
9018eacbe623b2 Paul Pawlowski     2022-02-03  760  
9018eacbe623b2 Paul Pawlowski     2022-02-03  761  	rep = kmalloc(0x200, GFP_KERNEL);
9018eacbe623b2 Paul Pawlowski     2022-02-03  762  	if (rep == NULL)
9018eacbe623b2 Paul Pawlowski     2022-02-03  763  		return -ENOMEM;
9018eacbe623b2 Paul Pawlowski     2022-02-03  764  
9018eacbe623b2 Paul Pawlowski     2022-02-03  765  	ret = hid_hw_raw_request(hdev, 0xBFu, (u8 *) rep, sizeof(*rep),
9018eacbe623b2 Paul Pawlowski     2022-02-03  766  				 HID_FEATURE_REPORT, HID_REQ_GET_REPORT);
9018eacbe623b2 Paul Pawlowski     2022-02-03  767  	if (ret < 0) {
9018eacbe623b2 Paul Pawlowski     2022-02-03  768  		hid_err(hdev, "backlight request failed: %d\n", ret);
9018eacbe623b2 Paul Pawlowski     2022-02-03  769  		goto cleanup_and_exit;
9018eacbe623b2 Paul Pawlowski     2022-02-03  770  	}
9018eacbe623b2 Paul Pawlowski     2022-02-03  771  	if (ret < 8 || rep->version != 1) {
9018eacbe623b2 Paul Pawlowski     2022-02-03  772  		hid_err(hdev, "backlight config struct: bad version %i\n", rep->version);
9018eacbe623b2 Paul Pawlowski     2022-02-03  773  		ret = -EINVAL;
9018eacbe623b2 Paul Pawlowski     2022-02-03  774  		goto cleanup_and_exit;
9018eacbe623b2 Paul Pawlowski     2022-02-03  775  	}
9018eacbe623b2 Paul Pawlowski     2022-02-03  776  
9018eacbe623b2 Paul Pawlowski     2022-02-03  777  	hid_dbg(hdev, "backlight config: off=%u, on_min=%u, on_max=%u\n",
9018eacbe623b2 Paul Pawlowski     2022-02-03  778  		rep->backlight_off, rep->backlight_on_min, rep->backlight_on_max);
9018eacbe623b2 Paul Pawlowski     2022-02-03  779  
9018eacbe623b2 Paul Pawlowski     2022-02-03  780  	asc->backlight = devm_kzalloc(&hdev->dev, sizeof(*asc->backlight), GFP_KERNEL);
9018eacbe623b2 Paul Pawlowski     2022-02-03  781  	if (!asc->backlight) {
9018eacbe623b2 Paul Pawlowski     2022-02-03  782  		ret = -ENOMEM;
9018eacbe623b2 Paul Pawlowski     2022-02-03  783  		goto cleanup_and_exit;
9018eacbe623b2 Paul Pawlowski     2022-02-03  784  	}
9018eacbe623b2 Paul Pawlowski     2022-02-03  785  
9018eacbe623b2 Paul Pawlowski     2022-02-03  786  	asc->backlight->hdev = hdev;
9018eacbe623b2 Paul Pawlowski     2022-02-03  787  	asc->backlight->cdev.name = "apple::kbd_backlight";
9018eacbe623b2 Paul Pawlowski     2022-02-03  788  	asc->backlight->cdev.max_brightness = rep->backlight_on_max;
9018eacbe623b2 Paul Pawlowski     2022-02-03  789  	asc->backlight->cdev.brightness_set_blocking = apple_backlight_led_set;
9018eacbe623b2 Paul Pawlowski     2022-02-03  790  
9018eacbe623b2 Paul Pawlowski     2022-02-03  791  	ret = apple_backlight_set(hdev, 0, 0);
9018eacbe623b2 Paul Pawlowski     2022-02-03  792  	if (ret < 0) {
9018eacbe623b2 Paul Pawlowski     2022-02-03  793  		hid_err(hdev, "backlight set request failed: %d\n", ret);
9018eacbe623b2 Paul Pawlowski     2022-02-03  794  		goto cleanup_and_exit;
9018eacbe623b2 Paul Pawlowski     2022-02-03  795  	}
9018eacbe623b2 Paul Pawlowski     2022-02-03  796  
9018eacbe623b2 Paul Pawlowski     2022-02-03  797  	ret = devm_led_classdev_register(&hdev->dev, &asc->backlight->cdev);
9018eacbe623b2 Paul Pawlowski     2022-02-03  798  
9018eacbe623b2 Paul Pawlowski     2022-02-03  799  cleanup_and_exit:
9018eacbe623b2 Paul Pawlowski     2022-02-03  800  	kfree(rep);
9018eacbe623b2 Paul Pawlowski     2022-02-03  801  	return ret;
9018eacbe623b2 Paul Pawlowski     2022-02-03  802  }
9018eacbe623b2 Paul Pawlowski     2022-02-03  803  
8c19a51591d06f Jiri Slaby         2008-06-18  804  static int apple_probe(struct hid_device *hdev,
8c19a51591d06f Jiri Slaby         2008-06-18  805  		const struct hid_device_id *id)
8c19a51591d06f Jiri Slaby         2008-06-18  806  {
8c19a51591d06f Jiri Slaby         2008-06-18  807  	unsigned long quirks = id->driver_data;
8c19a51591d06f Jiri Slaby         2008-06-18  808  	struct apple_sc *asc;
8c19a51591d06f Jiri Slaby         2008-06-18  809  	int ret;
8c19a51591d06f Jiri Slaby         2008-06-18  810  
abf832bfc349b5 Benjamin Tissoires 2013-07-24  811  	asc = devm_kzalloc(&hdev->dev, sizeof(*asc), GFP_KERNEL);
8c19a51591d06f Jiri Slaby         2008-06-18  812  	if (asc == NULL) {
4291ee305e9bb0 Joe Perches        2010-12-09  813  		hid_err(hdev, "can't alloc apple descriptor\n");
8c19a51591d06f Jiri Slaby         2008-06-18  814  		return -ENOMEM;
8c19a51591d06f Jiri Slaby         2008-06-18  815  	}
8c19a51591d06f Jiri Slaby         2008-06-18  816  
6e143293e17a73 José Expósito      2021-11-18  817  	asc->hdev = hdev;
8c19a51591d06f Jiri Slaby         2008-06-18  818  	asc->quirks = quirks;
8c19a51591d06f Jiri Slaby         2008-06-18  819  
8c19a51591d06f Jiri Slaby         2008-06-18  820  	hid_set_drvdata(hdev, asc);
8c19a51591d06f Jiri Slaby         2008-06-18  821  
8c19a51591d06f Jiri Slaby         2008-06-18  822  	ret = hid_parse(hdev);
8c19a51591d06f Jiri Slaby         2008-06-18  823  	if (ret) {
4291ee305e9bb0 Joe Perches        2010-12-09  824  		hid_err(hdev, "parse failed\n");
abf832bfc349b5 Benjamin Tissoires 2013-07-24  825  		return ret;
8c19a51591d06f Jiri Slaby         2008-06-18  826  	}
8c19a51591d06f Jiri Slaby         2008-06-18  827  
cc84094218a732 Alexander F. Lent  2021-09-16 @828  	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
8c19a51591d06f Jiri Slaby         2008-06-18  829  	if (ret) {
4291ee305e9bb0 Joe Perches        2010-12-09  830  		hid_err(hdev, "hw start failed\n");
8c19a51591d06f Jiri Slaby         2008-06-18  831  		return ret;
8c19a51591d06f Jiri Slaby         2008-06-18  832  	}
8c19a51591d06f Jiri Slaby         2008-06-18  833  
6e143293e17a73 José Expósito      2021-11-18  834  	timer_setup(&asc->battery_timer, apple_battery_timer_tick, 0);
6e143293e17a73 José Expósito      2021-11-18  835  	mod_timer(&asc->battery_timer,
6e143293e17a73 José Expósito      2021-11-18  836  		  jiffies + msecs_to_jiffies(APPLE_BATTERY_TIMEOUT_MS));
6e143293e17a73 José Expósito      2021-11-18  837  	apple_fetch_battery(hdev);
6e143293e17a73 José Expósito      2021-11-18  838  
9018eacbe623b2 Paul Pawlowski     2022-02-03  839  	if (quirks & APPLE_BACKLIGHT_CTL)
9018eacbe623b2 Paul Pawlowski     2022-02-03  840  		apple_backlight_init(hdev);
9018eacbe623b2 Paul Pawlowski     2022-02-03  841  
abf832bfc349b5 Benjamin Tissoires 2013-07-24  842  	return 0;
8c19a51591d06f Jiri Slaby         2008-06-18  843  }
8c19a51591d06f Jiri Slaby         2008-06-18  844  
6e143293e17a73 José Expósito      2021-11-18  845  static void apple_remove(struct hid_device *hdev)
6e143293e17a73 José Expósito      2021-11-18  846  {
6e143293e17a73 José Expósito      2021-11-18  847  	struct apple_sc *asc = hid_get_drvdata(hdev);
6e143293e17a73 José Expósito      2021-11-18  848  
6e143293e17a73 José Expósito      2021-11-18  849  	del_timer_sync(&asc->battery_timer);
6e143293e17a73 José Expósito      2021-11-18  850  
6e143293e17a73 José Expósito      2021-11-18 @851  	hid_hw_stop(hdev);
6e143293e17a73 José Expósito      2021-11-18  852  }
6e143293e17a73 José Expósito      2021-11-18  853
  

Patch

diff --git a/drivers/Makefile b/drivers/Makefile
index bdf1c66141c9..cf5d8b86da8f 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -137,7 +137,7 @@  obj-$(CONFIG_CRYPTO)		+= crypto/
 obj-$(CONFIG_SUPERH)		+= sh/
 obj-y				+= clocksource/
 obj-$(CONFIG_DCA)		+= dca/
-obj-$(CONFIG_HID)		+= hid/
+obj-$(CONFIG_HID_SUPPORT)	+= hid/
 obj-$(CONFIG_PPC_PS3)		+= ps3/
 obj-$(CONFIG_OF)		+= of/
 obj-$(CONFIG_SSB)		+= ssb/
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 185a077d59cd..ad767955ee62 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -2,12 +2,18 @@ 
 #
 # HID driver configuration
 #
-menu "HID support"
-     depends on INPUT
+menuconfig HID_SUPPORT
+	bool "HID bus support"
+	default y
+	depends on INPUT
+	help
+	  This option adds core support for human interface device (HID).
+	  You will also need drivers from the following menu to make use of it.
+
+if HID_SUPPORT
 
 config HID
-	tristate "HID bus support"
-	depends on INPUT
+	tristate "HID bus core support"
 	default y
 	help
 	  A human interface device (HID) is a type of computer device that
@@ -24,8 +30,6 @@  config HID
 
 	  If unsure, say Y.
 
-if HID
-
 config HID_BATTERY_STRENGTH
 	bool "Battery level reporting for HID devices"
 	select POWER_SUPPLY
@@ -1278,8 +1282,6 @@  config HID_KUNIT_TEST
 
 endmenu
 
-endif # HID
-
 source "drivers/hid/usbhid/Kconfig"
 
 source "drivers/hid/i2c-hid/Kconfig"
@@ -1290,4 +1292,4 @@  source "drivers/hid/amd-sfh-hid/Kconfig"
 
 source "drivers/hid/surface-hid/Kconfig"
 
-endmenu
+endif # HID_SUPPORT