[PATCH v1 01/15] ACPI: platform_profile: Add support for notification chains

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Mario Limonciello <mario.limonciello@xxxxxxx>

Allow other drivers to react to determine current active profile
and react to platform profile changes.

Signed-off-by: Mario Limonciello <mario.limonciello@xxxxxxx>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@xxxxxxx>
---
 drivers/acpi/platform_profile.c  | 26 ++++++++++++++++++++++++++
 include/linux/platform_profile.h |  1 +
 2 files changed, 27 insertions(+)

diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index d418462ab791..7e12a1f30f06 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -49,6 +49,32 @@ static ssize_t platform_profile_choices_show(struct device *dev,
 	return len;
 }
 
+int platform_profile_get(enum platform_profile_option *profile)
+{
+	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);
+	mutex_unlock(&profile_lock);
+	if (err)
+		return err;
+
+	/* Check that profile is valid index */
+	if (WARN_ON((*profile < 0) || (*profile >= ARRAY_SIZE(profile_names))))
+		return -EIO;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(platform_profile_get);
+
 static ssize_t platform_profile_show(struct device *dev,
 					struct device_attribute *attr,
 					char *buf)
diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
index e5cbb6841f3a..2395be670dfd 100644
--- a/include/linux/platform_profile.h
+++ b/include/linux/platform_profile.h
@@ -37,5 +37,6 @@ struct platform_profile_handler {
 int platform_profile_register(struct platform_profile_handler *pprof);
 int platform_profile_remove(void);
 void platform_profile_notify(void);
+int platform_profile_get(enum platform_profile_option *profile);
 
 #endif  /*_PLATFORM_PROFILE_H_*/
-- 
2.25.1




[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux