public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Wei Ni <wni@nvidia.com>
To: Mark Brown <broonie@kernel.org>
Cc: "khali@linux-fr.org" <khali@linux-fr.org>,
	"linux@roeck-us.net" <linux@roeck-us.net>,
	"swarren@wwwdotorg.org" <swarren@wwwdotorg.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"lm-sensors@lm-sensors.org" <lm-sensors@lm-sensors.org>,
	Matthew Longnecker <MLongnecker@nvidia.com>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v2 1/3] hwmon: (lm90) Add power control
Date: Fri, 9 Aug 2013 15:23:31 +0800	[thread overview]
Message-ID: <520498F3.8030101@nvidia.com> (raw)
In-Reply-To: <20130808110136.GA6427@sirena.org.uk>

On 08/08/2013 07:01 PM, Mark Brown wrote:
> * PGP Signed by an unknown key
> 
> On Thu, Aug 08, 2013 at 02:56:29PM +0800, Wei Ni wrote:
> 
>> +	mutex_lock(&data->update_lock);
>> +
>> +	if (is_enable)
>> +		ret = regulator_enable(data->lm90_reg);
>> +	else
>> +		ret = regulator_disable(data->lm90_reg);
>> +
>> +	if (ret < 0)
>> +		dev_err(&client->dev,
>> +			"Error in %s rail vdd, error %d\n",
>> +			(is_enable) ? "enabling" : "disabling", ret);
>> +	else
>> +		dev_info(&client->dev, "success in %s rail vdd\n",
>> +			 (is_enable) ? "enabling" : "disabling");
>> +
>> +	mutex_unlock(&data->update_lock);
> 
> Two things here.  One is that it's not clear what this lokc is
> protecting since the only thing in the locked region is the regulator
> operation and that is thread safe.  The other thing is that I'm not
> seeing anthing that ensures that enables and disables are matched -
> regulators are reference counted so two enables need two disables.
> 
>> +	data->lm90_reg = regulator_get(&client->dev, "vdd");
>> +	if (IS_ERR_OR_NULL(data->lm90_reg)) {
> 
> NULL is a valid regulator, use IS_ERR().
> 
>> +		if (PTR_ERR(data->lm90_reg) == -ENODEV)
>> +			dev_info(&client->dev,
>> +				 "No regulator found for vdd. Assuming vdd is always powered.");
>> +		else
>> +			dev_warn(&client->dev,
>> +				 "Error [%ld] in getting the regulator handle for vdd.\n",
>> +				 PTR_ERR(data->lm90_reg));
> 
> You shouldn't just be ignoring errors here, though there are deployment
> difficulties with making sure a stub regulator is provided.  These
> should be getting easier after the next merge window, the stubs will be
> being tweaked slightly to have an "assume it's there" option even when

Oh, really, could you show me the patch, I wish to take a look :)

Wei.

> regulators are used.  Especially in cases with device tree you should be
> paying attention to -EPROBE_DEFER, that will accurately reflect if a
> regulator is present but not loaded yet.
> 
> That said if you *are* going to do this you should request the
> regulator using devm_regulator_get_optional(), this is intended to
> support things that don't need regulators (though that's not the case
> here).
> 
> * Unknown Key
> * 0x7EA229BD
> 


  parent reply	other threads:[~2013-08-09  7:23 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-08  6:56 [PATCH v2 0/3] Add power control for lm90 Wei Ni
2013-08-08  6:56 ` [PATCH v2 1/3] hwmon: (lm90) Add power control Wei Ni
2013-08-08  7:13   ` Alexander Shiyan
2013-08-08  9:26     ` Wei Ni
2013-08-08  8:42   ` Guenter Roeck
2013-08-08  9:47     ` Wei Ni
2013-08-08  9:57       ` Alexander Shiyan
2013-08-08  9:59         ` Wei Ni
2013-08-08 10:07         ` Wei Ni
2013-08-08 11:23       ` Guenter Roeck
2013-08-08 17:33         ` Stephen Warren
2013-08-08 17:59           ` Guenter Roeck
2013-08-08 18:45             ` Stephen Warren
2013-08-08 17:30     ` Stephen Warren
2013-08-08 17:59       ` Guenter Roeck
2013-08-08 19:27       ` Mark Brown
2013-08-08 11:01   ` Mark Brown
2013-08-08 11:25     ` Guenter Roeck
2013-08-08 13:08       ` Mark Brown
2013-08-08 15:21         ` Guenter Roeck
2013-08-08 17:15           ` Mark Brown
2013-08-08 20:00             ` Guenter Roeck
2013-08-08 21:18               ` Mark Brown
2013-08-08 21:30                 ` Guenter Roeck
2013-08-09  5:57                   ` Proposal: I2C device power (Was: hwmon: (lm90) Add power control) Alexander Shiyan
2013-08-09 10:27                     ` Mark Brown
2013-08-09 10:50                       ` Alexander Shiyan
2013-08-09 11:09                         ` Mark Brown
2013-08-09  7:23     ` Wei Ni [this message]
2013-08-09 10:56       ` [PATCH v2 1/3] hwmon: (lm90) Add power control Mark Brown
2013-08-08  6:56 ` [PATCH v2 2/3] ARM: dt: t114 dalmore: add dt entry for nct1008 Wei Ni
2013-08-08 17:35   ` Stephen Warren
2013-08-09  6:06     ` Wei Ni
2013-08-08 20:36   ` Sergei Shtylyov
2013-08-08 20:40     ` Stephen Warren
2013-08-08 21:33       ` Guenter Roeck
2013-08-09  6:16         ` Wei Ni
2013-08-08  6:56 ` [PATCH v2 3/3] Documentation: dt: hwmon: add OF document for lm90 Wei Ni
2013-08-08 17:37   ` Stephen Warren
2013-08-09  6:10     ` Wei Ni
2013-08-09 16:35       ` Stephen Warren

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=520498F3.8030101@nvidia.com \
    --to=wni@nvidia.com \
    --cc=MLongnecker@nvidia.com \
    --cc=broonie@kernel.org \
    --cc=khali@linux-fr.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=lm-sensors@lm-sensors.org \
    --cc=swarren@wwwdotorg.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