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:	Fri, 15 Apr 2011 19:00:26 +0800
From:	wni@...dia.com
To:	khali@...ux-fr.org, guenter.roeck@...csson.com
Cc:	lm-sensors@...sensors.org, linux-kernel@...r.kernel.org,
	olofj@...omium.org, achew@...dia.com, Wei Ni <wni@...dia.com>
Subject: [PATCH 1/3] hwmon: (lm90) Add suspend/resume support

From: Wei Ni <wni@...dia.com>

This patch adds suspend/resume support.
Stop lm90 in suspend, and run it in resume.

Signed-off-by: Wei Ni <wni@...dia.com>
---
 drivers/hwmon/lm90.c |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 2f94f95..1c2ee3f 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -1085,6 +1085,24 @@ static DEVICE_ATTR(pec, S_IWUSR | S_IRUGO, show_pec, set_pec);
  * Real code
  */
 
+static void lm90_enable(struct i2c_client *client)
+{
+	u8 value;
+
+	lm90_read_reg(client, LM90_REG_R_CONFIG1, &value);
+	value &= ~0x40;
+	i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, value);
+}
+
+static void lm90_disable(struct i2c_client *client)
+{
+	u8 value;
+
+	lm90_read_reg(client, LM90_REG_R_CONFIG1, &value);
+	value |= 0x40;
+	i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, value);
+}
+
 /* Return 0 if detection is successful, -ENODEV otherwise */
 static int lm90_detect(struct i2c_client *new_client,
 		       struct i2c_board_info *info)
@@ -1482,6 +1500,20 @@ static void lm90_alert(struct i2c_client *client, unsigned int flag)
 	}
 }
 
+#ifdef CONFIG_PM
+static int lm90_suspend(struct i2c_client *client, pm_message_t state)
+{
+	lm90_disable(client);
+	return 0;
+}
+
+static int lm90_resume(struct i2c_client *client)
+{
+	lm90_enable(client);
+	return 0;
+}
+#endif
+
 static struct i2c_driver lm90_driver = {
 	.class		= I2C_CLASS_HWMON,
 	.driver = {
@@ -1493,6 +1525,10 @@ static struct i2c_driver lm90_driver = {
 	.id_table	= lm90_id,
 	.detect		= lm90_detect,
 	.address_list	= normal_i2c,
+#ifdef CONFIG_PM
+	.suspend	= lm90_suspend,
+	.resume		= lm90_resume,
+#endif
 };
 
 static int __init sensors_lm90_init(void)
-- 
1.7.0

--
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