Merge tag 'platform-drivers-x86-v6.10-1' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-block.git] / drivers / acpi / platform_profile.c
index d418462ab7919210f95e6092ff860a3dd8263371..4a9704730224ad3623795fd337817cb89bf23c91 100644 (file)
@@ -136,6 +136,45 @@ void platform_profile_notify(void)
 }
 EXPORT_SYMBOL_GPL(platform_profile_notify);
 
+int platform_profile_cycle(void)
+{
+       enum platform_profile_option profile;
+       enum platform_profile_option next;
+       int err;
+
+       err = mutex_lock_interruptible(&profile_lock);
+       if (err)
+               return err;
+
+       if (!cur_profile) {
+               mutex_unlock(&profile_lock);
+               return -ENODEV;
+       }
+
+       err = cur_profile->profile_get(cur_profile, &profile);
+       if (err) {
+               mutex_unlock(&profile_lock);
+               return err;
+       }
+
+       next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST,
+                                 profile + 1);
+
+       if (WARN_ON(next == PLATFORM_PROFILE_LAST)) {
+               mutex_unlock(&profile_lock);
+               return -EINVAL;
+       }
+
+       err = cur_profile->profile_set(cur_profile, next);
+       mutex_unlock(&profile_lock);
+
+       if (!err)
+               sysfs_notify(acpi_kobj, NULL, "platform_profile");
+
+       return err;
+}
+EXPORT_SYMBOL_GPL(platform_profile_cycle);
+
 int platform_profile_register(struct platform_profile_handler *pprof)
 {
        int err;