Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c1cd894b authored by Lukasz Luba's avatar Lukasz Luba Committed by Will McVicker
Browse files

FROMLIST: thermal: Make cooling device trip point writable from sysfs



Make it possible to change trip point for the cooling device instance
in the thermal zone. It would be helpful in case when cooling devices can
by bind to thermal zones using sysfs interface.

A proper trip point can be chosen for a cooling device by:
echo 2 > /sys/class/thermal/thermal_zoneX/cdev_Z_trip_point

It is also possible to unpin cooling device from trip point:
echo -1 > /sys/class/thermal/thermal_zoneX/cdev_Z_trip_point

Change-Id: I69e7a592b7d76cabafb422311b6dea74c19924ea
Signed-off-by: default avatarLukasz Luba <lukasz.luba@arm.com>
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20191216140622.25467-3-lukasz.luba@arm.com


Bug: 132152924
Signed-off-by: default avatarTeYuan Wang <kamewang@google.com>
Bug: 155322354
(cherry picked from commit dba49f7921d207625ed979d9d0da3302195a0170)
Signed-off-by: default avatarSaravana Kannan <saravanak@google.com>
Signed-off-by: default avatarWill McVicker <willmcvicker@google.com>
parent b71b0c1c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -769,8 +769,9 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
	sprintf(dev->attr_name, "cdev%d_trip_point", dev->id);
	sysfs_attr_init(&dev->attr.attr);
	dev->attr.attr.name = dev->attr_name;
	dev->attr.attr.mode = 0444;
	dev->attr.attr.mode = 0644;
	dev->attr.show = trip_point_show;
	dev->attr.store = trip_point_store;
	result = device_create_file(&tz->device, &dev->attr);
	if (result)
		goto remove_symbol_link;
+2 −0
Original line number Diff line number Diff line
@@ -61,6 +61,8 @@ void thermal_cooling_device_setup_sysfs(struct thermal_cooling_device *);
void thermal_cooling_device_destroy_sysfs(struct thermal_cooling_device *cdev);
/* used only at binding time */
ssize_t trip_point_show(struct device *, struct device_attribute *, char *);
ssize_t trip_point_store(struct device *, struct device_attribute *,
			 const char *, size_t);
ssize_t weight_show(struct device *, struct device_attribute *, char *);
ssize_t weight_store(struct device *, struct device_attribute *, const char *,
		     size_t);
+20 −0
Original line number Diff line number Diff line
@@ -977,6 +977,26 @@ trip_point_show(struct device *dev, struct device_attribute *attr, char *buf)
		return sprintf(buf, "%d\n", instance->trip);
}

ssize_t trip_point_store(struct device *dev, struct device_attribute *attr,
			 const char *buf, size_t count)
{
	struct thermal_instance *instance;
	int ret, trip;

	ret = kstrtoint(buf, 0, &trip);
	if (ret)
		return ret;

	instance = container_of(attr, struct thermal_instance, attr);

	if (trip >= instance->tz->trips || trip < THERMAL_TRIPS_NONE)
		return -EINVAL;

	instance->trip = trip;

	return count;
}

ssize_t
weight_show(struct device *dev, struct device_attribute *attr, char *buf)
{