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
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
© 2016 - 2025 Red Hat, Inc.