lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <87a8q28wsv.wl%kuninori.morimoto.gx@renesas.com>
Date:	Wed, 25 Nov 2015 05:42:27 +0000
From:	Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>
To:	Zhang Rui <rui.zhang@...el.com>,
	Eduardo Valentin <edubezval@...il.com>,
	Rob Herring <robh+dt@...nel.org>,
	Pawel Moll <pawel.moll@....com>,
	"Mark Rutland" <mark.rutland@....com>,
	Ian Campbell <ijc+devicetree@...lion.org.uk>,
	Kumar Gala <galak@...eaurora.org>
CC:	<devicetree@...r.kernel.org>, <linux-sh@...r.kernel.org>,
	<linux-pm@...r.kernel.org>,
	Ryusuke Sakato <ryusuke.sakato.bx@...esas.com>,
	<linux-kernel@...r.kernel.org>,
	"osd2@...renesas.com" <osd2@...renesas.com>
Subject: [PATCH] thermal: rcar: add .set_trip_temp support


From: Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>

You can set trip temp if your kernel has CONFIG_THERMAL_WRITABLE_TRIPS

echo $temp > /sys/class/thermal/thermal_zone0/trip_point_0_temp

-45000 < $temp < 125000 is supported
Default is 90000

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>
---
  This patch is v2 of "[PATCH] thermal: rcar: enable to set tripN-temp via DT"
  I think it will be full-DT feature if it uses of-thermal, but this driver is used
  from non-DT SoC too. We would like to keep non-DT support.
  And we would like to do is only exchange trip temp.
  .set_trip_temp is very enouth for it at this point.
  But, it can use of-thermal feature in the future.

 drivers/thermal/rcar_thermal.c | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 5d4ae7d..1eaa1be 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -63,6 +63,7 @@ struct rcar_thermal_priv {
 	struct mutex lock;
 	struct list_head list;
 	int id;
+	int trip_temp;
 	u32 ctemp;
 };
 
@@ -222,7 +223,7 @@ static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone,
 
 	/* see rcar_thermal_get_temp() */
 	switch (trip) {
-	case 0: /* +90 <= temp */
+	case 0:
 		*type = THERMAL_TRIP_CRITICAL;
 		break;
 	default:
@@ -241,8 +242,8 @@ static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
 
 	/* see rcar_thermal_get_temp() */
 	switch (trip) {
-	case 0: /* +90 <= temp */
-		*temp = MCELSIUS(90);
+	case 0:
+		*temp = priv->trip_temp;
 		break;
 	default:
 		dev_err(dev, "rcar driver trip error\n");
@@ -270,10 +271,27 @@ static int rcar_thermal_notify(struct thermal_zone_device *zone,
 	return 0;
 }
 
+static int rcar_thermal_set_trip_temp(struct thermal_zone_device *zone,
+				    int trip, int temp)
+{
+	struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
+
+	if (trip != 0)
+		return -EINVAL;
+
+	if (temp < -45000 || temp > 125000)
+		return -EINVAL;
+
+	priv->trip_temp = temp;
+
+	return 0;
+}
+
 static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
 	.get_temp	= rcar_thermal_get_temp,
 	.get_trip_type	= rcar_thermal_get_trip_type,
 	.get_trip_temp	= rcar_thermal_get_trip_temp,
+	.set_trip_temp	= rcar_thermal_set_trip_temp,
 	.notify		= rcar_thermal_notify,
 };
 
@@ -418,13 +436,14 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 
 		priv->common = common;
 		priv->id = i;
+		priv->trip_temp = MCELSIUS(90); /* default*/
 		mutex_init(&priv->lock);
 		INIT_LIST_HEAD(&priv->list);
 		INIT_DELAYED_WORK(&priv->work, rcar_thermal_work);
 		rcar_thermal_update_temp(priv);
 
 		priv->zone = thermal_zone_device_register("rcar_thermal",
-						1, 0, priv,
+						1, 1, priv,
 						&rcar_thermal_zone_ops, NULL, 0,
 						idle);
 		if (IS_ERR(priv->zone)) {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ