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


Groups > linux.kernel > #1409872 > unrolled thread

[PATCH 10/15] thermal: sysfs: lock tz when access tzp 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 10/15] thermal: sysfs: lock tz when access tzp properties Eduardo Valentin <edubezval@gmail.com> - 2016-05-31 08:40 +0200

#1409872 — [PATCH 10/15] thermal: sysfs: lock tz when access tzp properties

FromEduardo Valentin <edubezval@gmail.com>
Date2016-05-31 08:40 +0200
Subject[PATCH 10/15] thermal: sysfs: lock tz when access tzp properties
Message-ID<rELvj-7hB-11@gated-at.bofh.it>
Lock tz when in user facing sysfs handlers to expose
tzp properties. This includes changing the macro
create_s32_tzp_attr(), which is used  in the
tzp properties:
k_po, k_pu, k_i, k_d, integral_cutoff, slope, offset.

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 | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
index 5b08d64..86a77cd 100644
--- a/drivers/thermal/thermal_sysfs.c
+++ b/drivers/thermal/thermal_sysfs.c
@@ -398,11 +398,16 @@ sustainable_power_store(struct device *dev, struct device_attribute *devattr,
 		char *buf)						\
 	{								\
 	struct thermal_zone_device *tz = to_thermal_zone(dev);		\
+	int value;							\
 									\
-	if (tz->tzp)							\
-		return sprintf(buf, "%d\n", tz->tzp->name);		\
-	else								\
+	if (!tz->tzp)							\
 		return -EIO;						\
+									\
+	mutex_lock(&tz->lock);						\
+	value = tz->tzp->name;						\
+	mutex_unlock(&tz->lock);					\
+									\
+	return sprintf(buf, "%d\n", value);				\
 	}								\
 									\
 	static ssize_t							\
@@ -418,7 +423,9 @@ sustainable_power_store(struct device *dev, struct device_attribute *devattr,
 		if (kstrtos32(buf, 10, &value))				\
 			return -EINVAL;					\
 									\
+		mutex_lock(&tz->lock);					\
 		tz->tzp->name = value;					\
+		mutex_unlock(&tz->lock);				\
 									\
 		return count;						\
 	}								\
-- 
2.1.4

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web