Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1409878 > unrolled thread

[PATCH 09/15] thermal: sysfs: lock tz when access sustainable power properties

Started byEduardo Valentin <edubezval@gmail.com>
First post2016-05-31 08:40 +0200
Last post2016-05-31 08:40 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 09/15] thermal: sysfs: lock tz when access sustainable power properties Eduardo Valentin <edubezval@gmail.com> - 2016-05-31 08:40 +0200

#1409878 — [PATCH 09/15] thermal: sysfs: lock tz when access sustainable power properties

FromEduardo Valentin <edubezval@gmail.com>
Date2016-05-31 08:40 +0200
Subject[PATCH 09/15] thermal: sysfs: lock tz when access sustainable power properties
Message-ID<rELvk-7hB-33@gated-at.bofh.it>
Lock tz when in user facing sysfs handlers to expose
sustainable power properties. This includes:
sustainable_power_show()
sustainable_power_store()

Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/thermal/thermal_sysfs.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
index 32ffadf..5b08d64 100644
--- a/drivers/thermal/thermal_sysfs.c
+++ b/drivers/thermal/thermal_sysfs.c
@@ -360,9 +360,14 @@ sustainable_power_show(struct device *dev, struct device_attribute *devattr,
 		       char *buf)
 {
 	struct thermal_zone_device *tz = to_thermal_zone(dev);
+	unsigned int sustainable_power;
+
+	mutex_lock(&tz->lock);
+	sustainable_power = tz->tzp->sustainable_power;
+	mutex_unlock(&tz->lock);
 
 	if (tz->tzp)
-		return sprintf(buf, "%u\n", tz->tzp->sustainable_power);
+		return sprintf(buf, "%u\n", sustainable_power);
 	else
 		return -EIO;
 }
@@ -380,7 +385,9 @@ sustainable_power_store(struct device *dev, struct device_attribute *devattr,
 	if (kstrtou32(buf, 10, &sustainable_power))
 		return -EINVAL;
 
+	mutex_lock(&tz->lock);
 	tz->tzp->sustainable_power = sustainable_power;
+	mutex_unlock(&tz->lock);
 
 	return count;
 }
-- 
2.1.4

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web