From: wni@nvidia.com
To: khali@linux-fr.org, guenter.roeck@ericsson.com
Cc: lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org,
olofj@chromium.org, achew@nvidia.com, Wei Ni <wni@nvidia.com>
Subject: [lm-sensors] [PATCH 1/3] hwmon: (lm90) Add suspend/resume support
Date: Fri, 15 Apr 2011 11:00:26 +0000 [thread overview]
Message-ID: <1302865228-7185-2-git-send-email-wni@nvidia.com> (raw)
In-Reply-To: <1302865228-7185-1-git-send-email-wni@nvidia.com>
From: Wei Ni <wni@nvidia.com>
This patch adds suspend/resume support.
Stop lm90 in suspend, and run it in resume.
Signed-off-by: Wei Ni <wni@nvidia.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
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
WARNING: multiple messages have this Message-ID (diff)
From: wni@nvidia.com
To: khali@linux-fr.org, guenter.roeck@ericsson.com
Cc: lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org,
olofj@chromium.org, achew@nvidia.com, Wei Ni <wni@nvidia.com>
Subject: [PATCH 1/3] hwmon: (lm90) Add suspend/resume support
Date: Fri, 15 Apr 2011 19:00:26 +0800 [thread overview]
Message-ID: <1302865228-7185-2-git-send-email-wni@nvidia.com> (raw)
In-Reply-To: <1302865228-7185-1-git-send-email-wni@nvidia.com>
From: Wei Ni <wni@nvidia.com>
This patch adds suspend/resume support.
Stop lm90 in suspend, and run it in resume.
Signed-off-by: Wei Ni <wni@nvidia.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
next prev parent reply other threads:[~2011-04-15 11:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-15 11:00 [lm-sensors] [PATCH 0/3] hwmon (lm90) add some function for lm90 wni
2011-04-15 11:00 ` wni
2011-04-15 11:00 ` wni [this message]
2011-04-15 11:00 ` [PATCH 1/3] hwmon: (lm90) Add suspend/resume support wni
2011-04-15 11:00 ` [lm-sensors] [PATCH 2/3] hwmon (lm90) Support to configure nct1008 wni
2011-04-15 11:00 ` [PATCH 2/3] hwmon (lm90) Support to configure nct1008 from platform data wni
2011-04-15 15:46 ` [lm-sensors] [PATCH 2/3] hwmon (lm90) Support to configure Guenter Roeck
2011-04-15 15:46 ` [PATCH 2/3] hwmon (lm90) Support to configure nct1008 from platform data Guenter Roeck
2011-04-15 11:00 ` [lm-sensors] [PATCH 3/3] hwmon (lm90) Add alarm function for nct1008 wni
2011-04-15 11:00 ` wni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1302865228-7185-2-git-send-email-wni@nvidia.com \
--to=wni@nvidia.com \
--cc=achew@nvidia.com \
--cc=guenter.roeck@ericsson.com \
--cc=khali@linux-fr.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lm-sensors@lm-sensors.org \
--cc=olofj@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.