2020-10-01 15:00:24

by Bedel, Alban

[permalink] [raw]
Subject: [PATCH v4 0/3] hwmon: (lm75) Add regulator support

Hi everybody,

this small series add regulator support to the lm75 driver for boards
that don't always power such a sensor. While at it also convert the
DT bindings to yaml.

v2: - Fixed the DT example while converting to YAML
- Removed the unneeded maxItems from the binding documentation
- Use dummy regulator insted of explicitly handling missing regulator

v3: - Use a devm action to handle disabling the regulator

v4: - Added the missing `additionalProperties: false` when converting
the binding documentation to yaml

Alban Bedel (3):
dt-bindings: hwmon: Convert lm75 bindings to yaml
dt-bindings: hwmon: Add the +vs supply to the lm75 bindings
hwmon: (lm75) Add regulator support

.../devicetree/bindings/hwmon/lm75.txt | 39 -----------
.../devicetree/bindings/hwmon/lm75.yaml | 66 +++++++++++++++++++
drivers/hwmon/lm75.c | 24 +++++++
3 files changed, 90 insertions(+), 39 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/hwmon/lm75.txt
create mode 100644 Documentation/devicetree/bindings/hwmon/lm75.yaml

--
2.25.1


2020-10-01 15:00:38

by Bedel, Alban

[permalink] [raw]
Subject: [PATCH v4 2/3] dt-bindings: hwmon: Add the +vs supply to the lm75 bindings

Some boards might have a regulator that control the +VS supply, add it
to the bindings.

Signed-off-by: Alban Bedel <[email protected]>
Acked-by: Rob Herring <[email protected]>
---
v2: Removed the unneeded `maxItems` attribute
---
Documentation/devicetree/bindings/hwmon/lm75.yaml | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/hwmon/lm75.yaml b/Documentation/devicetree/bindings/hwmon/lm75.yaml
index c9a001627945..96eed5cc7841 100644
--- a/Documentation/devicetree/bindings/hwmon/lm75.yaml
+++ b/Documentation/devicetree/bindings/hwmon/lm75.yaml
@@ -43,6 +43,9 @@ properties:
reg:
maxItems: 1

+ vs-supply:
+ description: phandle to the regulator that provides the +VS supply
+
required:
- compatible
- reg
@@ -58,5 +61,6 @@ examples:
sensor@48 {
compatible = "st,stlm75";
reg = <0x48>;
+ vs-supply = <&vs>;
};
};
--
2.25.1

2020-10-01 15:01:48

by Bedel, Alban

[permalink] [raw]
Subject: [PATCH v4 3/3] hwmon: (lm75) Add regulator support

Add regulator support for boards where the sensor first need to be
powered up before it can be used.

Signed-off-by: Alban Bedel <[email protected]>
---
v2: Rely on dummy regulators instead of explicitly handling missing
regulator
v3: Use a devm action to handle disabling the regulator
---
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) {
--
2.25.1

2020-10-01 18:09:50

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH v4 2/3] dt-bindings: hwmon: Add the +vs supply to the lm75 bindings

Hi,

On 10/1/20 7:57 AM, Alban Bedel wrote:
> Some boards might have a regulator that control the +VS supply, add it
> to the bindings.
>
> Signed-off-by: Alban Bedel <[email protected]>
> Acked-by: Rob Herring <[email protected]>

I have nothing in my records, and nothing in patchwork, that suggests
that Rob gave this patch an Acked-by:. Please point me to the respective
e-mail.

Patch 1/3 is also missing an Acked-by: or Reviewed-by: from a DT
maintainer.

Thanks,
Guenter

> ---
> v2: Removed the unneeded `maxItems` attribute
> ---
> Documentation/devicetree/bindings/hwmon/lm75.yaml | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/hwmon/lm75.yaml b/Documentation/devicetree/bindings/hwmon/lm75.yaml
> index c9a001627945..96eed5cc7841 100644
> --- a/Documentation/devicetree/bindings/hwmon/lm75.yaml
> +++ b/Documentation/devicetree/bindings/hwmon/lm75.yaml
> @@ -43,6 +43,9 @@ properties:
> reg:
> maxItems: 1
>
> + vs-supply:
> + description: phandle to the regulator that provides the +VS supply
> +
> required:
> - compatible
> - reg
> @@ -58,5 +61,6 @@ examples:
> sensor@48 {
> compatible = "st,stlm75";
> reg = <0x48>;
> + vs-supply = <&vs>;
> };
> };
>

2020-10-01 18:14:26

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH v4 3/3] hwmon: (lm75) Add regulator support

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 <[email protected]>
> ---
> 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) {
>

2020-10-05 14:41:36

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH v4 2/3] dt-bindings: hwmon: Add the +vs supply to the lm75 bindings

On Thu, Oct 1, 2020 at 1:08 PM Guenter Roeck <[email protected]> wrote:
>
> Hi,
>
> On 10/1/20 7:57 AM, Alban Bedel wrote:
> > Some boards might have a regulator that control the +VS supply, add it
> > to the bindings.
> >
> > Signed-off-by: Alban Bedel <[email protected]>
> > Acked-by: Rob Herring <[email protected]>
>
> I have nothing in my records, and nothing in patchwork, that suggests
> that Rob gave this patch an Acked-by:. Please point me to the respective
> e-mail.

I did on v2.

> Patch 1/3 is also missing an Acked-by: or Reviewed-by: from a DT
> maintainer.

In my queue.

Rob

2020-10-06 20:36:17

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH v4 2/3] dt-bindings: hwmon: Add the +vs supply to the lm75 bindings

On Thu, Oct 01, 2020 at 04:57:37PM +0200, Alban Bedel wrote:
> Some boards might have a regulator that control the +VS supply, add it
> to the bindings.
>
> Signed-off-by: Alban Bedel <[email protected]>
> Acked-by: Rob Herring <[email protected]>

Applied to hwmon-next.

Thanks,
Guenter

> ---
> v2: Removed the unneeded `maxItems` attribute
> ---
> Documentation/devicetree/bindings/hwmon/lm75.yaml | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/hwmon/lm75.yaml b/Documentation/devicetree/bindings/hwmon/lm75.yaml
> index c9a001627945..96eed5cc7841 100644
> --- a/Documentation/devicetree/bindings/hwmon/lm75.yaml
> +++ b/Documentation/devicetree/bindings/hwmon/lm75.yaml
> @@ -43,6 +43,9 @@ properties:
> reg:
> maxItems: 1
>
> + vs-supply:
> + description: phandle to the regulator that provides the +VS supply
> +
> required:
> - compatible
> - reg
> @@ -58,5 +61,6 @@ examples:
> sensor@48 {
> compatible = "st,stlm75";
> reg = <0x48>;
> + vs-supply = <&vs>;
> };
> };