devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Alban Bedel <alban.bedel@aerq.com>, linux-hwmon@vger.kernel.org
Cc: Jean Delvare <jdelvare@suse.com>,
	Rob Herring <robh+dt@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 3/3] hwmon: (lm75) Add regulator support
Date: Thu, 1 Oct 2020 11:13:01 -0700	[thread overview]
Message-ID: <8bfad666-10e7-e5d7-c4d8-3877c3f7b449@roeck-us.net> (raw)
In-Reply-To: <20201001145738.17326-4-alban.bedel@aerq.com>

On 10/1/20 7:57 AM, Alban Bedel wrote:
> Add regulator support for boards where the sensor first need to be
> powered up before it can be used.
> 
> Signed-off-by: Alban Bedel <alban.bedel@aerq.com>
> ---
> v2: Rely on dummy regulators instead of explicitly handling missing
>     regulator
> v3: Use a devm action to handle disabling the regulator
> ---

Second '---' is not needed.

I can not apply patches 1 and 2 of the series since I don't have an
Ack from a DT maintainer, but this one looks good. Applied.

Guenter


>  drivers/hwmon/lm75.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
> index ba0be48aeadd..e9c1f55b2706 100644
> --- a/drivers/hwmon/lm75.c
> +++ b/drivers/hwmon/lm75.c
> @@ -17,6 +17,7 @@
>  #include <linux/of.h>
>  #include <linux/regmap.h>
>  #include <linux/util_macros.h>
> +#include <linux/regulator/consumer.h>
>  #include "lm75.h"
>  
>  /*
> @@ -101,6 +102,7 @@ static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
>  struct lm75_data {
>  	struct i2c_client		*client;
>  	struct regmap			*regmap;
> +	struct regulator		*vs;
>  	u8				orig_conf;
>  	u8				current_conf;
>  	u8				resolution;	/* In bits, 9 to 16 */
> @@ -534,6 +536,13 @@ static const struct regmap_config lm75_regmap_config = {
>  	.use_single_write = true,
>  };
>  
> +static void lm75_disable_regulator(void *data)
> +{
> +	struct lm75_data *lm75 = data;
> +
> +	regulator_disable(lm75->vs);
> +}
> +
>  static void lm75_remove(void *data)
>  {
>  	struct lm75_data *lm75 = data;
> @@ -567,6 +576,10 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
>  	data->client = client;
>  	data->kind = kind;
>  
> +	data->vs = devm_regulator_get(dev, "vs");
> +	if (IS_ERR(data->vs))
> +		return PTR_ERR(data->vs);
> +
>  	data->regmap = devm_regmap_init_i2c(client, &lm75_regmap_config);
>  	if (IS_ERR(data->regmap))
>  		return PTR_ERR(data->regmap);
> @@ -581,6 +594,17 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
>  	data->sample_time = data->params->default_sample_time;
>  	data->resolution = data->params->default_resolution;
>  
> +	/* Enable the power */
> +	err = regulator_enable(data->vs);
> +	if (err) {
> +		dev_err(dev, "failed to enable regulator: %d\n", err);
> +		return err;
> +	}
> +
> +	err = devm_add_action_or_reset(dev, lm75_disable_regulator, data);
> +	if (err)
> +		return err;
> +
>  	/* Cache original configuration */
>  	status = i2c_smbus_read_byte_data(client, LM75_REG_CONF);
>  	if (status < 0) {
> 


      reply	other threads:[~2020-10-01 18:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-01 14:57 [PATCH v4 0/3] hwmon: (lm75) Add regulator support Alban Bedel
2020-10-01 14:57 ` [PATCH v4 1/3] dt-bindings: hwmon: Convert lm75 bindings to yaml Alban Bedel
2020-10-06 20:26   ` Rob Herring
2020-10-06 20:33   ` Guenter Roeck
2020-10-01 14:57 ` [PATCH v4 2/3] dt-bindings: hwmon: Add the +vs supply to the lm75 bindings Alban Bedel
2020-10-01 18:08   ` Guenter Roeck
2020-10-05 14:38     ` Rob Herring
2020-10-06 20:33   ` Guenter Roeck
2020-10-01 14:57 ` [PATCH v4 3/3] hwmon: (lm75) Add regulator support Alban Bedel
2020-10-01 18:13   ` Guenter Roeck [this message]

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=8bfad666-10e7-e5d7-c4d8-3877c3f7b449@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=alban.bedel@aerq.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jdelvare@suse.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.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;
as well as URLs for NNTP newsgroup(s).