@@ -459,6 +459,29 @@ int platform_profile_cycle(void)
}
EXPORT_SYMBOL_GPL(platform_profile_cycle);
+int platform_profile_refresh_choices(struct platform_profile_handler *pprof)
+{
+ unsigned long backup[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)];
+ int err;
+
+ scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
+ bitmap_copy(backup, pprof->choices, PLATFORM_PROFILE_LAST);
+
+ err = pprof->ops->choices(pprof);
+ if (err) {
+ bitmap_copy(pprof->choices, backup, PLATFORM_PROFILE_LAST);
+ return err;
+ }
+
+ _notify_class_profile(pprof->class_dev, NULL);
+ }
+
+ sysfs_notify(acpi_kobj, NULL, "platform_profile");
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(platform_profile_refresh_choices);
+
int platform_profile_register(struct platform_profile_handler *pprof)
{
int err;
@@ -50,6 +50,7 @@ int platform_profile_register(struct platform_profile_handler *pprof);
int platform_profile_remove(struct platform_profile_handler *pprof);
int devm_platform_profile_register(struct platform_profile_handler *pprof);
int platform_profile_cycle(void);
+int platform_profile_refresh_choices(struct platform_profile_handler *pprof);
void platform_profile_notify(struct platform_profile_handler *pprof);
#endif /*_PLATFORM_PROFILE_H_*/
Let drivers dynamically refresh selected choices safely, while holding `profile_lock`. Signed-off-by: Kurt Borja <kuurtb@gmail.com> --- drivers/acpi/platform_profile.c | 23 +++++++++++++++++++++++ include/linux/platform_profile.h | 1 + 2 files changed, 24 insertions(+)