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-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 20 Jun 2021 19:12:23 +0300
From:   Dmitry Osipenko <digetx@...il.com>
To:     Zhang Rui <rui.zhang@...el.com>,
        Daniel Lezcano <daniel.lezcano@...aro.org>,
        Amit Kucheria <amitk@...nel.org>,
        Jean Delvare <jdelvare@...e.com>,
        Guenter Roeck <linux@...ck-us.net>
Cc:     linux-hwmon@...r.kernel.org, linux-pm@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-tegra@...r.kernel.org
Subject: [PATCH v1 2/2] hwmon: (lm90) Implement set_trips() callback

Implement set_trips() callback in order to operatively notify thermal
core about temperature changes. Thermal core will take control over the
LM90 temperature limits only if LM90 is attached to thermal zone in a
device-tree and sensor interrupt is provided, otherwise old behaviour
is unchanged.

Currently only NVIDIA Tegra boards are specifying interrupt for LM90
sensors and only couple of boards use sensor for passive cooling of CPU,
otherwise sensor isn't actively used. Hence this change doesn't bring
any visible effects to userspace, it merely improves thermal device
capabilities of the LM90 driver.

Signed-off-by: Dmitry Osipenko <digetx@...il.com>
---
 drivers/hwmon/lm90.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index b53f17511b05..7180af611dfb 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -1406,6 +1406,35 @@ static int lm90_write(struct device *dev, enum hwmon_sensor_types type,
 	}
 }
 
+static int lm90_set_trips(struct device *dev, int channel, int low, int high)
+{
+	struct lm90_data *data = dev_get_drvdata(dev);
+	struct i2c_client *client = data->client;
+	int err;
+
+	/*
+	 * It makes sense to set temperature trips only if interrupt is
+	 * provided since the whole point of temperature trips is to get
+	 * a quick notification about temperature changes.
+	 */
+	if (!client->irq)
+		return 0;
+
+	/* prevent integer overflow of temperature calculations */
+	low  = max(low, -255000);
+	high = min(high, 255000);
+
+	err = lm90_temp_write(dev, hwmon_temp_min, channel, low);
+	if (err < 0)
+		return err;
+
+	err = lm90_temp_write(dev, hwmon_temp_max, channel, high);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
 static umode_t lm90_is_visible(const void *data, enum hwmon_sensor_types type,
 			       u32 attr, int channel)
 {
@@ -1804,6 +1833,7 @@ static const struct hwmon_ops lm90_ops = {
 	.is_visible = lm90_is_visible,
 	.read = lm90_read,
 	.write = lm90_write,
+	.set_trips = lm90_set_trips,
 };
 
 static int lm90_probe(struct i2c_client *client)
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ