* [PATCH v4 0/3] hwmon: (lm75) Add regulator support @ 2020-10-01 14:57 Alban Bedel 2020-10-01 14:57 ` [PATCH v4 1/3] dt-bindings: hwmon: Convert lm75 bindings to yaml Alban Bedel ` (2 more replies) 0 siblings, 3 replies; 10+ messages in thread From: Alban Bedel @ 2020-10-01 14:57 UTC (permalink / raw) To: linux-hwmon Cc: Jean Delvare, Guenter Roeck, Rob Herring, Liam Girdwood, Mark Brown, devicetree, linux-kernel, Alban Bedel 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 1/3] dt-bindings: hwmon: Convert lm75 bindings to yaml 2020-10-01 14:57 [PATCH v4 0/3] hwmon: (lm75) Add regulator support Alban Bedel @ 2020-10-01 14:57 ` 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 14:57 ` [PATCH v4 3/3] hwmon: (lm75) Add regulator support Alban Bedel 2 siblings, 2 replies; 10+ messages in thread From: Alban Bedel @ 2020-10-01 14:57 UTC (permalink / raw) To: linux-hwmon Cc: Jean Delvare, Guenter Roeck, Rob Herring, Liam Girdwood, Mark Brown, devicetree, linux-kernel, Alban Bedel In order to automate the verification of DT nodes convert lm75.txt to lm75.yaml. Signed-off-by: Alban Bedel <alban.bedel@aerq.com> --- v2: Fix the example to pass `make dt_binding_check` v4: Add the missing additionalProperties: false --- .../devicetree/bindings/hwmon/lm75.txt | 39 ------------ .../devicetree/bindings/hwmon/lm75.yaml | 62 +++++++++++++++++++ 2 files changed, 62 insertions(+), 39 deletions(-) delete mode 100644 Documentation/devicetree/bindings/hwmon/lm75.txt create mode 100644 Documentation/devicetree/bindings/hwmon/lm75.yaml diff --git a/Documentation/devicetree/bindings/hwmon/lm75.txt b/Documentation/devicetree/bindings/hwmon/lm75.txt deleted file mode 100644 index 273616702c51..000000000000 --- a/Documentation/devicetree/bindings/hwmon/lm75.txt +++ /dev/null @@ -1,39 +0,0 @@ -*LM75 hwmon sensor. - -Required properties: -- compatible: manufacturer and chip name, one of - "adi,adt75", - "dallas,ds1775", - "dallas,ds75", - "dallas,ds7505", - "gmt,g751", - "national,lm75", - "national,lm75a", - "national,lm75b", - "maxim,max6625", - "maxim,max6626", - "maxim,max31725", - "maxim,max31726", - "maxim,mcp980x", - "nxp,pct2075", - "st,stds75", - "st,stlm75", - "microchip,tcn75", - "ti,tmp100", - "ti,tmp101", - "ti,tmp105", - "ti,tmp112", - "ti,tmp175", - "ti,tmp275", - "ti,tmp75", - "ti,tmp75b", - "ti,tmp75c", - -- reg: I2C bus address of the device - -Example: - -sensor@48 { - compatible = "st,stlm75"; - reg = <0x48>; -}; diff --git a/Documentation/devicetree/bindings/hwmon/lm75.yaml b/Documentation/devicetree/bindings/hwmon/lm75.yaml new file mode 100644 index 000000000000..c9a001627945 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/lm75.yaml @@ -0,0 +1,62 @@ +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/lm75.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: LM75 hwmon sensor + +maintainers: + - Jean Delvare <jdelvare@suse.com> + - Guenter Roeck <linux@roeck-us.net> + +properties: + compatible: + enum: + - adi,adt75 + - dallas,ds1775 + - dallas,ds75 + - dallas,ds7505 + - gmt,g751 + - national,lm75 + - national,lm75a + - national,lm75b + - maxim,max6625 + - maxim,max6626 + - maxim,max31725 + - maxim,max31726 + - maxim,mcp980x + - nxp,pct2075 + - st,stds75 + - st,stlm75 + - microchip,tcn75 + - ti,tmp100 + - ti,tmp101 + - ti,tmp105 + - ti,tmp112 + - ti,tmp175 + - ti,tmp275 + - ti,tmp75 + - ti,tmp75b + - ti,tmp75c + + reg: + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + sensor@48 { + compatible = "st,stlm75"; + reg = <0x48>; + }; + }; -- 2.25.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v4 1/3] dt-bindings: hwmon: Convert lm75 bindings to yaml 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 1 sibling, 0 replies; 10+ messages in thread From: Rob Herring @ 2020-10-06 20:26 UTC (permalink / raw) To: Alban Bedel Cc: Liam Girdwood, Jean Delvare, Rob Herring, linux-kernel, linux-hwmon, devicetree, Guenter Roeck, Mark Brown On Thu, 01 Oct 2020 16:57:36 +0200, Alban Bedel wrote: > In order to automate the verification of DT nodes convert lm75.txt to > lm75.yaml. > > Signed-off-by: Alban Bedel <alban.bedel@aerq.com> > --- > v2: Fix the example to pass `make dt_binding_check` > v4: Add the missing additionalProperties: false > --- > .../devicetree/bindings/hwmon/lm75.txt | 39 ------------ > .../devicetree/bindings/hwmon/lm75.yaml | 62 +++++++++++++++++++ > 2 files changed, 62 insertions(+), 39 deletions(-) > delete mode 100644 Documentation/devicetree/bindings/hwmon/lm75.txt > create mode 100644 Documentation/devicetree/bindings/hwmon/lm75.yaml > Reviewed-by: Rob Herring <robh@kernel.org> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4 1/3] dt-bindings: hwmon: Convert lm75 bindings to yaml 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 1 sibling, 0 replies; 10+ messages in thread From: Guenter Roeck @ 2020-10-06 20:33 UTC (permalink / raw) To: Alban Bedel Cc: linux-hwmon, Jean Delvare, Rob Herring, Liam Girdwood, Mark Brown, devicetree, linux-kernel On Thu, Oct 01, 2020 at 04:57:36PM +0200, Alban Bedel wrote: > In order to automate the verification of DT nodes convert lm75.txt to > lm75.yaml. > > Signed-off-by: Alban Bedel <alban.bedel@aerq.com> > Reviewed-by: Rob Herring <robh@kernel.org> > --- Applied to hwmon-next. Thanks, Guenter > v2: Fix the example to pass `make dt_binding_check` > v4: Add the missing additionalProperties: false > --- > .../devicetree/bindings/hwmon/lm75.txt | 39 ------------ > .../devicetree/bindings/hwmon/lm75.yaml | 62 +++++++++++++++++++ > 2 files changed, 62 insertions(+), 39 deletions(-) > delete mode 100644 Documentation/devicetree/bindings/hwmon/lm75.txt > create mode 100644 Documentation/devicetree/bindings/hwmon/lm75.yaml > > diff --git a/Documentation/devicetree/bindings/hwmon/lm75.txt b/Documentation/devicetree/bindings/hwmon/lm75.txt > deleted file mode 100644 > index 273616702c51..000000000000 > --- a/Documentation/devicetree/bindings/hwmon/lm75.txt > +++ /dev/null > @@ -1,39 +0,0 @@ > -*LM75 hwmon sensor. > - > -Required properties: > -- compatible: manufacturer and chip name, one of > - "adi,adt75", > - "dallas,ds1775", > - "dallas,ds75", > - "dallas,ds7505", > - "gmt,g751", > - "national,lm75", > - "national,lm75a", > - "national,lm75b", > - "maxim,max6625", > - "maxim,max6626", > - "maxim,max31725", > - "maxim,max31726", > - "maxim,mcp980x", > - "nxp,pct2075", > - "st,stds75", > - "st,stlm75", > - "microchip,tcn75", > - "ti,tmp100", > - "ti,tmp101", > - "ti,tmp105", > - "ti,tmp112", > - "ti,tmp175", > - "ti,tmp275", > - "ti,tmp75", > - "ti,tmp75b", > - "ti,tmp75c", > - > -- reg: I2C bus address of the device > - > -Example: > - > -sensor@48 { > - compatible = "st,stlm75"; > - reg = <0x48>; > -}; > diff --git a/Documentation/devicetree/bindings/hwmon/lm75.yaml b/Documentation/devicetree/bindings/hwmon/lm75.yaml > new file mode 100644 > index 000000000000..c9a001627945 > --- /dev/null > +++ b/Documentation/devicetree/bindings/hwmon/lm75.yaml > @@ -0,0 +1,62 @@ > +# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/hwmon/lm75.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: LM75 hwmon sensor > + > +maintainers: > + - Jean Delvare <jdelvare@suse.com> > + - Guenter Roeck <linux@roeck-us.net> > + > +properties: > + compatible: > + enum: > + - adi,adt75 > + - dallas,ds1775 > + - dallas,ds75 > + - dallas,ds7505 > + - gmt,g751 > + - national,lm75 > + - national,lm75a > + - national,lm75b > + - maxim,max6625 > + - maxim,max6626 > + - maxim,max31725 > + - maxim,max31726 > + - maxim,mcp980x > + - nxp,pct2075 > + - st,stds75 > + - st,stlm75 > + - microchip,tcn75 > + - ti,tmp100 > + - ti,tmp101 > + - ti,tmp105 > + - ti,tmp112 > + - ti,tmp175 > + - ti,tmp275 > + - ti,tmp75 > + - ti,tmp75b > + - ti,tmp75c > + > + reg: > + maxItems: 1 > + > +required: > + - compatible > + - reg > + > +additionalProperties: false > + > +examples: > + - | > + i2c { > + #address-cells = <1>; > + #size-cells = <0>; > + > + sensor@48 { > + compatible = "st,stlm75"; > + reg = <0x48>; > + }; > + }; ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 2/3] dt-bindings: hwmon: Add the +vs supply to the lm75 bindings 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-01 14:57 ` Alban Bedel 2020-10-01 18:08 ` Guenter Roeck 2020-10-06 20:33 ` Guenter Roeck 2020-10-01 14:57 ` [PATCH v4 3/3] hwmon: (lm75) Add regulator support Alban Bedel 2 siblings, 2 replies; 10+ messages in thread From: Alban Bedel @ 2020-10-01 14:57 UTC (permalink / raw) To: linux-hwmon Cc: Jean Delvare, Guenter Roeck, Rob Herring, Liam Girdwood, Mark Brown, devicetree, linux-kernel, Alban Bedel, Rob Herring Some boards might have a regulator that control the +VS supply, add it to the bindings. Signed-off-by: Alban Bedel <alban.bedel@aerq.com> Acked-by: Rob Herring <robh@kernel.org> --- 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 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v4 2/3] dt-bindings: hwmon: Add the +vs supply to the lm75 bindings 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 1 sibling, 1 reply; 10+ messages in thread From: Guenter Roeck @ 2020-10-01 18:08 UTC (permalink / raw) To: Alban Bedel, linux-hwmon Cc: Jean Delvare, Rob Herring, Liam Girdwood, Mark Brown, devicetree, linux-kernel, Rob Herring 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 <alban.bedel@aerq.com> > Acked-by: Rob Herring <robh@kernel.org> 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>; > }; > }; > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4 2/3] dt-bindings: hwmon: Add the +vs supply to the lm75 bindings 2020-10-01 18:08 ` Guenter Roeck @ 2020-10-05 14:38 ` Rob Herring 0 siblings, 0 replies; 10+ messages in thread From: Rob Herring @ 2020-10-05 14:38 UTC (permalink / raw) To: Guenter Roeck Cc: Alban Bedel, Linux HWMON List, Jean Delvare, Liam Girdwood, Mark Brown, devicetree, linux-kernel On Thu, Oct 1, 2020 at 1:08 PM Guenter Roeck <linux@roeck-us.net> 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 <alban.bedel@aerq.com> > > Acked-by: Rob Herring <robh@kernel.org> > > 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4 2/3] dt-bindings: hwmon: Add the +vs supply to the lm75 bindings 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-06 20:33 ` Guenter Roeck 1 sibling, 0 replies; 10+ messages in thread From: Guenter Roeck @ 2020-10-06 20:33 UTC (permalink / raw) To: Alban Bedel Cc: linux-hwmon, Jean Delvare, Rob Herring, Liam Girdwood, Mark Brown, devicetree, linux-kernel, Rob Herring 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 <alban.bedel@aerq.com> > Acked-by: Rob Herring <robh@kernel.org> 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>; > }; > }; ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 3/3] hwmon: (lm75) Add regulator support 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-01 14:57 ` [PATCH v4 2/3] dt-bindings: hwmon: Add the +vs supply to the lm75 bindings Alban Bedel @ 2020-10-01 14:57 ` Alban Bedel 2020-10-01 18:13 ` Guenter Roeck 2 siblings, 1 reply; 10+ messages in thread From: Alban Bedel @ 2020-10-01 14:57 UTC (permalink / raw) To: linux-hwmon Cc: Jean Delvare, Guenter Roeck, Rob Herring, Liam Girdwood, Mark Brown, devicetree, linux-kernel, Alban Bedel 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 --- 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 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v4 3/3] hwmon: (lm75) Add regulator support 2020-10-01 14:57 ` [PATCH v4 3/3] hwmon: (lm75) Add regulator support Alban Bedel @ 2020-10-01 18:13 ` Guenter Roeck 0 siblings, 0 replies; 10+ messages in thread From: Guenter Roeck @ 2020-10-01 18:13 UTC (permalink / raw) To: Alban Bedel, linux-hwmon Cc: Jean Delvare, Rob Herring, Liam Girdwood, Mark Brown, devicetree, linux-kernel 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) { > ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-10-06 20:33 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 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 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).