public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Remove HID_LENOVO's dependency on ACPI
@ 2025-05-18 10:18 Janne Grunau via B4 Relay
  2025-05-18 10:18 ` [PATCH 1/2] ACPI: platform_profile: Stub platform_profile_cycle Janne Grunau via B4 Relay
  2025-05-18 10:18 ` [PATCH 2/2] HID: lenovo: Remove CONFIG_ACPI dependency Janne Grunau via B4 Relay
  0 siblings, 2 replies; 7+ messages in thread
From: Janne Grunau via B4 Relay @ 2025-05-18 10:18 UTC (permalink / raw)
  To: Arnd Bergmann, Jiri Kosina, Benjamin Tissoires, Rafael J. Wysocki,
	Len Brown
  Cc: linux-kernel, linux-input, linux-acpi, Janne Grunau

hid-lenovo supports external generic USB and Bluetooth devices and
should be buildable and usable on non-ACPI kernels and systems. Commit
84c9d2a968c82 ("HID: lenovo: Support for ThinkPad-X12-TAB-1/2 Kbd Fn
keys") added a hot key to cycle through power profiles using ACPI's
platform_profile. This resulted in adding a dependency on ACPI and
selecting CONFIG_ACPI_PLATFORM_PROFILE to fix build an link errors in
commit 52572cde8b4a ("HID: lenovo: select
CONFIG_ACPI_PLATFORM_PROFILE"). This is undesirable for HID drivers
supporting generic USB and Bluetooth devices. So instead stub the only
used function platform_profile_cycle() and relax the dependency.

Signed-off-by: Janne Grunau <j@jannau.net>
---
Janne Grunau (2):
      ACPI: platform_profile: Stub platform_profile_cycle
      HID: lenovo: Remove CONFIG_ACPI dependency

 drivers/hid/Kconfig              |  4 ++--
 include/linux/platform_profile.h | 11 +++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
---
base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
change-id: 20250518-hid_lenovo_acpi_dependency-0ea78a6bd740

Best regards,
-- 
Janne Grunau <j@jannau.net>



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] ACPI: platform_profile: Stub platform_profile_cycle
  2025-05-18 10:18 [PATCH 0/2] Remove HID_LENOVO's dependency on ACPI Janne Grunau via B4 Relay
@ 2025-05-18 10:18 ` Janne Grunau via B4 Relay
  2025-05-18 10:42   ` Arnd Bergmann
  2025-05-18 12:38   ` kernel test robot
  2025-05-18 10:18 ` [PATCH 2/2] HID: lenovo: Remove CONFIG_ACPI dependency Janne Grunau via B4 Relay
  1 sibling, 2 replies; 7+ messages in thread
From: Janne Grunau via B4 Relay @ 2025-05-18 10:18 UTC (permalink / raw)
  To: Arnd Bergmann, Jiri Kosina, Benjamin Tissoires, Rafael J. Wysocki,
	Len Brown
  Cc: linux-kernel, linux-input, linux-acpi, Janne Grunau

From: Janne Grunau <j@jannau.net>

This is required to allow USB/Bluetooth HID devices to cycle through
platform profiles without depending on ACPI. Commit 52572cde8b4a4
("HID: lenovo: select CONFIG_ACPI_PLATFORM_PROFILE") added this
dependency for hid-lenovo which is used for external USB and Bluetooth
devices.

Fixes: 52572cde8b4a4 ("HID: lenovo: select CONFIG_ACPI_PLATFORM_PROFILE")
Signed-off-by: Janne Grunau <j@jannau.net>
---
 include/linux/platform_profile.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
index a299225ab92e78ce2e978b1774cdfc95cc688e8f..05a6749991601fd373683c3d498c6e9cc4f97882 100644
--- a/include/linux/platform_profile.h
+++ b/include/linux/platform_profile.h
@@ -54,7 +54,18 @@ void platform_profile_remove(struct device *dev);
 struct device *devm_platform_profile_register(struct device *dev, const char *name,
 					      void *drvdata,
 					      const struct platform_profile_ops *ops);
+#ifdef CONFIG_ACPI_PLATFORM_PROFILE
 int platform_profile_cycle(void);
+#else
+/*
+ * This stub is needed to allow USB/Bluetooth HID drivers to cycle through
+ * platform profiles.
+ */
+static inline int platform_profile_cycle(void)
+{
+	return 0;
+}
+#endif /* CONFIG_ACPI_PLATFORM_PROFILE */
 void platform_profile_notify(struct device *dev);
 
 #endif  /*_PLATFORM_PROFILE_H_*/

-- 
2.49.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] HID: lenovo: Remove CONFIG_ACPI dependency
  2025-05-18 10:18 [PATCH 0/2] Remove HID_LENOVO's dependency on ACPI Janne Grunau via B4 Relay
  2025-05-18 10:18 ` [PATCH 1/2] ACPI: platform_profile: Stub platform_profile_cycle Janne Grunau via B4 Relay
@ 2025-05-18 10:18 ` Janne Grunau via B4 Relay
  2025-05-18 10:36   ` Arnd Bergmann
  1 sibling, 1 reply; 7+ messages in thread
From: Janne Grunau via B4 Relay @ 2025-05-18 10:18 UTC (permalink / raw)
  To: Arnd Bergmann, Jiri Kosina, Benjamin Tissoires, Rafael J. Wysocki,
	Len Brown
  Cc: linux-kernel, linux-input, linux-acpi, Janne Grunau

From: Janne Grunau <j@jannau.net>

With platform_profile_cycle() stubbed the dependency on CONFIG_ACPI can
be relaxed to `ACPI || !ACPI` and CONFIG_ACPI_PLATFORM_PROFILE is only
selected if ACPI is enabled.
Cycling through platform profiles is only functional with ACPI but that
should not be an issue as it only used on a detachable keyboard of a x86
tablet with a special connector.

Fixes: 52572cde8b4a4 ("HID: lenovo: select CONFIG_ACPI_PLATFORM_PROFILE")
Signed-off-by: Janne Grunau <j@jannau.net>
---
 drivers/hid/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index a503252702b7b43c332a12b14bc8b23b83e9f028..984f7bd235141f21e018b51f97546ec9d00324e8 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -595,8 +595,8 @@ config HID_LED
 
 config HID_LENOVO
 	tristate "Lenovo / Thinkpad devices"
-	depends on ACPI
-	select ACPI_PLATFORM_PROFILE
+	depends on ACPI || !ACPI
+	select ACPI_PLATFORM_PROFILE if ACPI
 	select NEW_LEDS
 	select LEDS_CLASS
 	help

-- 
2.49.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] HID: lenovo: Remove CONFIG_ACPI dependency
  2025-05-18 10:18 ` [PATCH 2/2] HID: lenovo: Remove CONFIG_ACPI dependency Janne Grunau via B4 Relay
@ 2025-05-18 10:36   ` Arnd Bergmann
  0 siblings, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2025-05-18 10:36 UTC (permalink / raw)
  To: Janne Grunau, Jiri Kosina, Benjamin Tissoires, Rafael J . Wysocki,
	Len Brown
  Cc: linux-kernel, linux-input, linux-acpi

On Sun, May 18, 2025, at 12:18, Janne Grunau via B4 Relay wrote:
> 
>  config HID_LENOVO
>  	tristate "Lenovo / Thinkpad devices"
> -	depends on ACPI
> -	select ACPI_PLATFORM_PROFILE
> +	depends on ACPI || !ACPI

Since ACPI is a 'bool' symbol, the 'ACPI || !ACPI' dependency
has no actual effect. I don't see any way that ACPI will ever
become a loadable module.

      Arnd

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] ACPI: platform_profile: Stub platform_profile_cycle
  2025-05-18 10:18 ` [PATCH 1/2] ACPI: platform_profile: Stub platform_profile_cycle Janne Grunau via B4 Relay
@ 2025-05-18 10:42   ` Arnd Bergmann
  2025-05-18 14:45     ` Janne Grunau
  2025-05-18 12:38   ` kernel test robot
  1 sibling, 1 reply; 7+ messages in thread
From: Arnd Bergmann @ 2025-05-18 10:42 UTC (permalink / raw)
  To: Janne Grunau, Jiri Kosina, Benjamin Tissoires, Rafael J . Wysocki,
	Len Brown
  Cc: linux-kernel, linux-input, linux-acpi

On Sun, May 18, 2025, at 12:18, Janne Grunau via B4 Relay wrote:
*ops);
> +#ifdef CONFIG_ACPI_PLATFORM_PROFILE
>  int platform_profile_cycle(void);
> +#else

CONFIG_ACPI_PLATFORM_PROFILE is a 'tristate' symbol, so the #ifdef
check is wrong here when both the caller and the platform profile
are in a loadable module.

I think what you want here is

#if IS_ENABLED(CONFIG_ACPI_PLATFORM_PROFILE)

Alternatively, you could move that check into the caller
and do

      if (IS_ENABLED(CONFIG_ACPI_PLATFORM_PROFILE))
              ret = platform_profile_cycle();

which makes it a little easier to catch build failures in
drivers that are missing the 'select ACPI_PLATFORM_PROFILE'.

    Arnd

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] ACPI: platform_profile: Stub platform_profile_cycle
  2025-05-18 10:18 ` [PATCH 1/2] ACPI: platform_profile: Stub platform_profile_cycle Janne Grunau via B4 Relay
  2025-05-18 10:42   ` Arnd Bergmann
@ 2025-05-18 12:38   ` kernel test robot
  1 sibling, 0 replies; 7+ messages in thread
From: kernel test robot @ 2025-05-18 12:38 UTC (permalink / raw)
  To: Janne Grunau via B4 Relay, Arnd Bergmann, Jiri Kosina,
	Benjamin Tissoires, Rafael J. Wysocki, Len Brown
  Cc: oe-kbuild-all, linux-kernel, linux-input, linux-acpi,
	Janne Grunau

Hi Janne,

kernel test robot noticed the following build errors:

[auto build test ERROR on 0af2f6be1b4281385b618cb86ad946eded089ac8]

url:    https://github.com/intel-lab-lkp/linux/commits/Janne-Grunau-via-B4-Relay/ACPI-platform_profile-Stub-platform_profile_cycle/20250518-182021
base:   0af2f6be1b4281385b618cb86ad946eded089ac8
patch link:    https://lore.kernel.org/r/20250518-hid_lenovo_acpi_dependency-v1-1-afdb93b5d1a6%40jannau.net
patch subject: [PATCH 1/2] ACPI: platform_profile: Stub platform_profile_cycle
config: x86_64-buildonly-randconfig-005-20250518 (https://download.01.org/0day-ci/archive/20250518/202505182014.8Vkd2piH-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250518/202505182014.8Vkd2piH-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202505182014.8Vkd2piH-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/acpi/platform_profile.c:493:5: error: redefinition of 'platform_profile_cycle'
     493 | int platform_profile_cycle(void)
         |     ^~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers/acpi/platform_profile.c:12:
   include/linux/platform_profile.h:64:19: note: previous definition of 'platform_profile_cycle' with type 'int(void)'
      64 | static inline int platform_profile_cycle(void)
         |                   ^~~~~~~~~~~~~~~~~~~~~~


vim +/platform_profile_cycle +493 drivers/acpi/platform_profile.c

a2ff95e018f1d2 Mark Pearson      2020-12-29  487  
ee7f3e2b4942e3 Kurt Borja        2025-01-15  488  /**
ee7f3e2b4942e3 Kurt Borja        2025-01-15  489   * platform_profile_cycle - Cycles profiles available on all registered class devices
ee7f3e2b4942e3 Kurt Borja        2025-01-15  490   *
ee7f3e2b4942e3 Kurt Borja        2025-01-15  491   * Return: 0 on success, -errno on failure
ee7f3e2b4942e3 Kurt Borja        2025-01-15  492   */
ba95eb44676d68 Gergo Koteles     2024-04-08 @493  int platform_profile_cycle(void)
ba95eb44676d68 Gergo Koteles     2024-04-08  494  {
778b94d7ac17b5 Mario Limonciello 2025-02-28  495  	struct aggregate_choices_data data = {
778b94d7ac17b5 Mario Limonciello 2025-02-28  496  		.aggregate = { [0 ... BITS_TO_LONGS(PLATFORM_PROFILE_LAST) - 1] = ~0UL },
778b94d7ac17b5 Mario Limonciello 2025-02-28  497  		.count = 0,
778b94d7ac17b5 Mario Limonciello 2025-02-28  498  	};
70246f89c55fb1 Mario Limonciello 2024-12-05  499  	enum platform_profile_option next = PLATFORM_PROFILE_LAST;
70246f89c55fb1 Mario Limonciello 2024-12-05  500  	enum platform_profile_option profile = PLATFORM_PROFILE_LAST;
ba95eb44676d68 Gergo Koteles     2024-04-08  501  	int err;
ba95eb44676d68 Gergo Koteles     2024-04-08  502  
1f3ac55c2e65af Mario Limonciello 2024-12-05  503  	scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
70246f89c55fb1 Mario Limonciello 2024-12-05  504  		err = class_for_each_device(&platform_profile_class, NULL,
70246f89c55fb1 Mario Limonciello 2024-12-05  505  					    &profile, _aggregate_profiles);
70246f89c55fb1 Mario Limonciello 2024-12-05  506  		if (err)
70246f89c55fb1 Mario Limonciello 2024-12-05  507  			return err;
ba95eb44676d68 Gergo Koteles     2024-04-08  508  
70246f89c55fb1 Mario Limonciello 2024-12-05  509  		if (profile == PLATFORM_PROFILE_CUSTOM ||
70246f89c55fb1 Mario Limonciello 2024-12-05  510  		    profile == PLATFORM_PROFILE_LAST)
70246f89c55fb1 Mario Limonciello 2024-12-05  511  			return -EINVAL;
70246f89c55fb1 Mario Limonciello 2024-12-05  512  
70246f89c55fb1 Mario Limonciello 2024-12-05  513  		err = class_for_each_device(&platform_profile_class, NULL,
778b94d7ac17b5 Mario Limonciello 2025-02-28  514  					    &data, _aggregate_choices);
1f3ac55c2e65af Mario Limonciello 2024-12-05  515  		if (err)
ba95eb44676d68 Gergo Koteles     2024-04-08  516  			return err;
ba95eb44676d68 Gergo Koteles     2024-04-08  517  
70246f89c55fb1 Mario Limonciello 2024-12-05  518  		/* never iterate into a custom if all drivers supported it */
778b94d7ac17b5 Mario Limonciello 2025-02-28  519  		clear_bit(PLATFORM_PROFILE_CUSTOM, data.aggregate);
70246f89c55fb1 Mario Limonciello 2024-12-05  520  
778b94d7ac17b5 Mario Limonciello 2025-02-28  521  		next = find_next_bit_wrap(data.aggregate,
70246f89c55fb1 Mario Limonciello 2024-12-05  522  					  PLATFORM_PROFILE_LAST,
ba95eb44676d68 Gergo Koteles     2024-04-08  523  					  profile + 1);
ba95eb44676d68 Gergo Koteles     2024-04-08  524  
70246f89c55fb1 Mario Limonciello 2024-12-05  525  		err = class_for_each_device(&platform_profile_class, NULL, &next,
70246f89c55fb1 Mario Limonciello 2024-12-05  526  					    _store_and_notify);
ba95eb44676d68 Gergo Koteles     2024-04-08  527  
1f3ac55c2e65af Mario Limonciello 2024-12-05  528  		if (err)
1f3ac55c2e65af Mario Limonciello 2024-12-05  529  			return err;
1f3ac55c2e65af Mario Limonciello 2024-12-05  530  	}
ba95eb44676d68 Gergo Koteles     2024-04-08  531  
ba95eb44676d68 Gergo Koteles     2024-04-08  532  	sysfs_notify(acpi_kobj, NULL, "platform_profile");
ba95eb44676d68 Gergo Koteles     2024-04-08  533  
1f3ac55c2e65af Mario Limonciello 2024-12-05  534  	return 0;
ba95eb44676d68 Gergo Koteles     2024-04-08  535  }
ba95eb44676d68 Gergo Koteles     2024-04-08  536  EXPORT_SYMBOL_GPL(platform_profile_cycle);
ba95eb44676d68 Gergo Koteles     2024-04-08  537  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] ACPI: platform_profile: Stub platform_profile_cycle
  2025-05-18 10:42   ` Arnd Bergmann
@ 2025-05-18 14:45     ` Janne Grunau
  0 siblings, 0 replies; 7+ messages in thread
From: Janne Grunau @ 2025-05-18 14:45 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Jiri Kosina, Benjamin Tissoires, Rafael J . Wysocki, Len Brown,
	linux-kernel, linux-input, linux-acpi

On Sun, May 18, 2025 at 12:42:36PM +0200, Arnd Bergmann wrote:
> On Sun, May 18, 2025, at 12:18, Janne Grunau via B4 Relay wrote:
> *ops);
> > +#ifdef CONFIG_ACPI_PLATFORM_PROFILE
> >  int platform_profile_cycle(void);
> > +#else
> 
> CONFIG_ACPI_PLATFORM_PROFILE is a 'tristate' symbol, so the #ifdef
> check is wrong here when both the caller and the platform profile
> are in a loadable module.
> 
> I think what you want here is
> 
> #if IS_ENABLED(CONFIG_ACPI_PLATFORM_PROFILE)

ack, kernel test robot already complained

> Alternatively, you could move that check into the caller
> and do
> 
>       if (IS_ENABLED(CONFIG_ACPI_PLATFORM_PROFILE))
>               ret = platform_profile_cycle();
> 
> which makes it a little easier to catch build failures in
> drivers that are missing the 'select ACPI_PLATFORM_PROFILE'.

I think I'll go with this for v2 and remove the "ACPI || !ACPI" from
Patch 2.

thanks,

Janne

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-05-18 14:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-18 10:18 [PATCH 0/2] Remove HID_LENOVO's dependency on ACPI Janne Grunau via B4 Relay
2025-05-18 10:18 ` [PATCH 1/2] ACPI: platform_profile: Stub platform_profile_cycle Janne Grunau via B4 Relay
2025-05-18 10:42   ` Arnd Bergmann
2025-05-18 14:45     ` Janne Grunau
2025-05-18 12:38   ` kernel test robot
2025-05-18 10:18 ` [PATCH 2/2] HID: lenovo: Remove CONFIG_ACPI dependency Janne Grunau via B4 Relay
2025-05-18 10:36   ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox