From: Wei Ni <wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
To: khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org,
linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org,
broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org
Cc: lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Wei Ni <wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH v5 1/3] hwmon: (lm90) Add power control
Date: Mon, 7 Oct 2013 17:25:38 +0800 [thread overview]
Message-ID: <1381137940-22608-2-git-send-email-wni@nvidia.com> (raw)
In-Reply-To: <1381137940-22608-1-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
The device lm90 can be controlled by the vcc rail.
Adding the regulator support to power on/off the vcc rail.
Enable the "vcc" regulator before accessing the device.
Signed-off-by: Wei Ni <wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
drivers/hwmon/lm90.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index cdff742..3f51680 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -89,6 +89,7 @@
#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/sysfs.h>
+#include <linux/regulator/consumer.h>
/*
* Addresses to scan
@@ -302,6 +303,7 @@ static const struct lm90_params lm90_params[] = {
struct lm90_data {
struct device *hwmon_dev;
struct mutex update_lock;
+ struct regulator *lm90_reg;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
int kind;
@@ -1397,8 +1399,20 @@ static int lm90_probe(struct i2c_client *client,
struct device *dev = &client->dev;
struct i2c_adapter *adapter = to_i2c_adapter(dev->parent);
struct lm90_data *data;
+ struct regulator *reg;
int err;
+ reg = devm_regulator_get(dev, "vcc");
+ if (IS_ERR(reg))
+ return PTR_ERR(reg);
+
+ err = regulator_enable(reg);
+ if (err < 0) {
+ dev_err(&client->dev,
+ "Failed to enable regulator: %d\n", err);
+ return err;
+ }
+
data = devm_kzalloc(&client->dev, sizeof(struct lm90_data), GFP_KERNEL);
if (!data)
return -ENOMEM;
@@ -1406,6 +1420,8 @@ static int lm90_probe(struct i2c_client *client,
i2c_set_clientdata(client, data);
mutex_init(&data->update_lock);
+ data->lm90_reg = reg;
+
/* Set the device type */
data->kind = id->driver_data;
if (data->kind == adm1032) {
@@ -1473,6 +1489,8 @@ exit_remove_files:
lm90_remove_files(client, data);
exit_restore:
lm90_restore_conf(client, data);
+ regulator_disable(data->lm90_reg);
+
return err;
}
@@ -1483,6 +1501,7 @@ static int lm90_remove(struct i2c_client *client)
hwmon_device_unregister(data->hwmon_dev);
lm90_remove_files(client, data);
lm90_restore_conf(client, data);
+ regulator_disable(data->lm90_reg);
return 0;
}
--
1.7.9.5
next prev parent reply other threads:[~2013-10-07 9:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-07 9:25 [PATCH v5 0/3] Add power control for lm90 Wei Ni
[not found] ` <1381137940-22608-1-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-10-07 9:25 ` Wei Ni [this message]
[not found] ` <1381137940-22608-2-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-11-14 12:38 ` [PATCH v5 1/3] hwmon: (lm90) Add power control Jean Delvare
2013-10-07 9:25 ` [PATCH v5 2/3] of: add vendor prefix for GMT Wei Ni
[not found] ` <1381137940-22608-3-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-11-12 14:39 ` Jean Delvare
[not found] ` <20131112153934.30543f8d-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-11-13 9:57 ` Wei Ni
2013-10-07 9:25 ` [PATCH v5 3/3] Documentation: dt: hwmon: add OF document for LM90 Wei Ni
[not found] ` <1381137940-22608-4-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-11-14 12:33 ` Jean Delvare
[not found] ` <20131114133320.00ad70c0-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-11-15 1:21 ` Wei Ni
[not found] ` <5285772E.2090700-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-11-15 7:20 ` Jean Delvare
2013-10-08 20:30 ` [PATCH v5 0/3] Add power control for lm90 Stephen Warren
2013-10-16 3:20 ` Wei Ni
[not found] ` <525E05E3.4040708-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-10-18 1:45 ` Wei Ni
[not found] ` <526092A6.4050205-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-10-30 2:38 ` Wei Ni
[not found] ` <52707138.10903-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-10-30 14:55 ` Jean Delvare
[not found] ` <20131030155542.7a09b861-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-10-31 3:30 ` Wei Ni
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=1381137940-22608-2-git-send-email-wni@nvidia.com \
--to=wni-ddmlm1+adcrqt0dzr+alfa@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
--cc=linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org \
--cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox