Skip to contentSkip to conversation

ACPI-Thermal: Make Thermal trip points writeable

PATCH Superseded Durgadoss R 2 participants 3 messages Apr 6, 2012 – Apr 9, 2012

Subsystems (4)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ACPI-Thermal: Make Thermal trip points writeable

Some of the thermal drivers using the Generic Thermal Framework require (all/some) trip points to be writeable. This patch makes the trip point temperatures writeable on a per-trip point basis, and modifies the required function call in thermal.c. This patch also updates the Documentation to reflect the new change.

---
v1
* patch1/2: Code for making trip points writeable
* patch2/2: Change the callee in thermal.c
v2
* Make both the changes in a single patch
* Update Documentation/thermal/sysfs-api.txt v3
* Re-submitting, on top of the latest mainline kernel

---
 Documentation/thermal/sysfs-api.txt |    4 +-
 drivers/acpi/thermal.c              |    4 +-
 drivers/thermal/thermal_sys.c       |  112 +++++++++++++++++++++++------------
 include/linux/thermal.h             |   10 ++-
 4 files changed, 87 insertions(+), 43 deletions(-)
Documentation/thermal/sysfs-api.txt +3 -1
index 1733ab9..0c7c423 100644
@@ -32,7 +32,8 @@ temperature) and throttle appropriate devices.
 
 1.1 thermal zone device interface
 1.1.1 struct thermal_zone_device *thermal_zone_device_register(char *name,
-		int trips, void *devdata, struct thermal_zone_device_ops *ops)
+		int trips, int flag, void *devdata,
+		struct thermal_zone_device_ops *ops)
 
     This interface function adds a new thermal zone device (sensor) to
     /sys/class/thermal folder as thermal_zone[0-*]. It tries to bind all the
@@ -40,6 +41,7 @@ temperature) and throttle appropriate devices.
 
     name: the thermal zone name.
     trips: the total number of trip points this thermal zone supports.
+    flag: Bit string: If 'n'th bit is set, then trip point 'n' is writeable.
     devdata: device private data
     ops: thermal zone device call-backs.
 	.bind: bind the thermal zone device with a thermal cooling device.
drivers/acpi/thermal.c +2 -2
index 7dbebea..2107d1b 100644
@@ -845,7 +845,7 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
 
 	if (tz->trips.passive.flags.valid)
 		tz->thermal_zone =
-			thermal_zone_device_register("acpitz", trips, tz,
+			thermal_zone_device_register("acpitz", trips, 0, tz,
 						     &acpi_thermal_zone_ops,
 						     tz->trips.passive.tc1,
 						     tz->trips.passive.tc2,
@@ -853,7 +853,7 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
 						     tz->polling_frequency*100);
 	else
 		tz->thermal_zone =
-			thermal_zone_device_register("acpitz", trips, tz,
+			thermal_zone_device_register("acpitz", trips, 0, tz,
 						     &acpi_thermal_zone_ops,
 						     0, 0, 0,
 						     tz->polling_frequency*100);
drivers/thermal/thermal_sys.c +75 -37

154 lines not on this page · raw message

include/linux/thermal.h +7 -3
index 796f1ff..825d4b0 100644
@@ -58,6 +58,8 @@ struct thermal_zone_device_ops {
 		enum thermal_trip_type *);
 	int (*get_trip_temp) (struct thermal_zone_device *, int,
 			      unsigned long *);
+	int (*set_trip_temp) (struct thermal_zone_device *, int,
+			      unsigned long);
 	int (*get_crit_temp) (struct thermal_zone_device *, unsigned long *);
 	int (*notify) (struct thermal_zone_device *, int,
 		       enum thermal_trip_type);
@@ -89,6 +91,8 @@ struct thermal_zone_device {
 	int id;
 	char type[THERMAL_NAME_LENGTH];
 	struct device device;
+	struct device_attribute trip_temp_attrs[THERMAL_MAX_TRIPS];
+	struct device_attribute trip_type_attrs[THERMAL_MAX_TRIPS];
 	void *devdata;
 	int trips;
 	int tc1;
@@ -137,9 +141,9 @@ enum {
 };
 #define THERMAL_GENL_CMD_MAX (__THERMAL_GENL_CMD_MAX - 1)
 
-struct thermal_zone_device *thermal_zone_device_register(char *, int, void *,
-		const struct thermal_zone_device_ops *, int tc1, int tc2,
-		int passive_freq, int polling_freq);
+struct thermal_zone_device *thermal_zone_device_register(char *, int, int,
+		void *, const struct thermal_zone_device_ops *, int tc1,
+		int tc2, int passive_freq, int polling_freq);
 void thermal_zone_device_unregister(struct thermal_zone_device *);
 
 int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int,
Signature · 1 line
1.7.0.4
reviewer Acked-by on v3 1/1
#1 lore raw

Hi, Durga,

Quoted 6 lines · Durgadoss R

Some of the thermal drivers using the Generic Thermal Framework require (all/some) trip points to be writeable. This patch makes the trip point temperatures writeable on a per-trip point basis, and modifies the required function call in thermal.c. This patch also updates the Documentation to reflect the new change.

I'm okay with this patch, except some minor comments.

Quoted 1 line
Quoted 26 lines

---
v1
* patch1/2: Code for making trip points writeable
* patch2/2: Change the callee in thermal.c
v2
* Make both the changes in a single patch
* Update Documentation/thermal/sysfs-api.txt v3
* Re-submitting, on top of the latest mainline kernel

---
 Documentation/thermal/sysfs-api.txt |    4 +-
 drivers/acpi/thermal.c              |    4 +-
 drivers/thermal/thermal_sys.c       |  112 +++++++++++++++++++++++------------
 include/linux/thermal.h             |   10 ++-
 4 files changed, 87 insertions(+), 43 deletions(-)
drivers/thermal/thermal_sys.c +2 -0
+/**
  * thermal_zone_device_register - register a new thermal zone device
  * @type:	the thermal zone device type
  * @trips:	the number of trip points the thermal zone support
+ * @flag:	a bit string indicating the writeablility of trip points
  * @devdata:	private device data
  * @ops:	standard thermal zone device callbacks
  * @tc1:	thermal coefficient 1 for passive calculations

drivers/thermal/thermal_sys.c EXPORT_SYMBOL(thermal_zone_device_update); · line 1153

Quoted 8 lines
drivers/thermal/thermal_sys.c +1 -1
@@ -1107,7 +1147,7 @@ EXPORT_SYMBOL(thermal_zone_device_update);
  * section 11.1.5.1 of the ACPI specification 3.0.
  */
 struct thermal_zone_device *thermal_zone_device_register(char *type,
-	int trips, void *devdata,
+	int trips, int flag, void *devdata,
 	const struct thermal_zone_device_ops *ops,
 	int tc1, int tc2, int passive_delay, int polling_delay)
 {

Do we need a simple check of the "flag" parameter? e.g,
if (flag >> trips)

    return -EINVAL;

BTW, should we introduce some helper function like this THERMAL_SET_TRIP_WRITABLE (trip, flag) flag |= 1 << trip;

thanks,
rui

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw

Hi Rui,

Quoted 8 lines · Durgadoss R
Quoted 6 lines

Some of the thermal drivers using the Generic Thermal Framework require (all/some) trip points to be writeable. This patch makes the trip point temperatures writeable on a per-trip point basis, and modifies the required function call in thermal.c. This patch also updates the Documentation to reflect the new change.

Quoted 5 lines

I'm okay with this patch, except some minor comments.

Quoted 1 line

Thank you..

Quoted 40 lines
Quoted 10 lines

---
v1
* patch1/2: Code for making trip points writeable
* patch2/2: Change the callee in thermal.c
v2
* Make both the changes in a single patch
* Update Documentation/thermal/sysfs-api.txt v3
* Re-submitting, on top of the latest mainline kernel

Quoted 4 lines
---
 Documentation/thermal/sysfs-api.txt |    4 +-
 drivers/acpi/thermal.c              |    4 +-
 drivers/thermal/thermal_sys.c       |  112 +++++++++++++++++++++++----------

--

Quoted 13 lines
 include/linux/thermal.h             |   10 ++-
 4 files changed, 87 insertions(+), 43 deletions(-)
drivers/thermal/thermal_sys.c +2 -0
+/**
  * thermal_zone_device_register - register a new thermal zone device
  * @type:	the thermal zone device type
  * @trips:	the number of trip points the thermal zone support
+ * @flag:	a bit string indicating the writeablility of trip points
  * @devdata:	private device data
  * @ops:	standard thermal zone device callbacks
  * @tc1:	thermal coefficient 1 for passive calculations

drivers/thermal/thermal_sys.c EXPORT_SYMBOL(thermal_zone_device_update); · line 1153

Quoted 8 lines
drivers/thermal/thermal_sys.c +1 -1
@@ -1107,7 +1147,7 @@ EXPORT_SYMBOL(thermal_zone_device_update);
  * section 11.1.5.1 of the ACPI specification 3.0.
  */
 struct thermal_zone_device *thermal_zone_device_register(char *type,
-	int trips, void *devdata,
+	int trips, int flag, void *devdata,
 	const struct thermal_zone_device_ops *ops,
 	int tc1, int tc2, int passive_delay, int polling_delay)
 {

Do we need a simple check of the "flag" parameter? e.g,
if (flag >> trips)

Quoted 1 line
    return -EINVAL;

I agree with you. Will add this check and send v4 of the patch.

Quoted 4 lines

BTW, should we introduce some helper function like this THERMAL_SET_TRIP_WRITABLE (trip, flag) flag |= 1 << trip;

Since the callers of this API pass the flag, I thought they will handle this.

Thanks,
Durga