public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Wei Ni <wni@nvidia.com>
Cc: khali@linux-fr.org, broonie@kernel.org, swarren@wwwdotorg.org,
	lm-sensors@lm-sensors.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 1/3] hwmon: (lm90) Add power control
Date: Thu, 12 Sep 2013 06:31:05 -0700	[thread overview]
Message-ID: <5231C219.8030604@roeck-us.net> (raw)
In-Reply-To: <1378985061-28547-2-git-send-email-wni@nvidia.com>

On 09/12/2013 04:24 AM, Wei Ni wrote:
> 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@nvidia.com>

I still believe that you should update all .dts files referencing this driver
to match the new requirement.

Guenter

> ---
>   drivers/hwmon/lm90.c |   20 ++++++++++++++++++++
>   1 file changed, 20 insertions(+)
>
> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
> index cdff742..f3f66d5 100644
> --- a/drivers/hwmon/lm90.c
> +++ b/drivers/hwmon/lm90.c
> @@ -89,6 +89,8 @@
>   #include <linux/err.h>
>   #include <linux/mutex.h>
>   #include <linux/sysfs.h>
> +#include <linux/regulator/consumer.h>
> +#include <linux/delay.h>
>
>   /*
>    * Addresses to scan
> @@ -302,6 +304,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 +1400,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 +1421,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 +1490,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 +1502,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;
>   }
>


  parent reply	other threads:[~2013-09-12 13:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-12 11:24 [PATCH v4 0/3] Add power control for lm90 Wei Ni
2013-09-12 11:24 ` [PATCH v4 1/3] hwmon: (lm90) Add power control Wei Ni
2013-09-12 11:51   ` Mark Brown
2013-09-16  4:21     ` Wei Ni
2013-09-12 13:31   ` Guenter Roeck [this message]
2013-09-12 11:24 ` [PATCH v4 2/3] of: add vendor prefix for GMT Wei Ni
2013-09-12 14:58   ` Stephen Warren
2013-09-12 11:24 ` [PATCH v4 3/3] Documentation: dt: hwmon: add OF document for LM90 Wei Ni
2013-09-12 15:00   ` Stephen Warren
2013-09-16  4:28     ` Wei Ni
2013-09-16 10:23       ` Mark Brown

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=5231C219.8030604@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=broonie@kernel.org \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.org \
    --cc=swarren@wwwdotorg.org \
    --cc=wni@nvidia.com \
    /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