hwmon: (tmp108) Add basic regulator support
PATCH 1/1 hwmon: (tmp108) Add basic regulator support
TMP108/P3T1085 are powered by the V+/VCC regulator, add support for it.
--- drivers/hwmon/tmp108.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/hwmon/tmp108.c +5 -0
@@ -17,6 +17,7 @@#include <linux/init.h> #include <linux/jiffies.h> #include <linux/regmap.h> +#include <linux/regulator/consumer.h> #include <linux/slab.h> #define DRIVER_NAME "tmp108"
@@ -331,6 +332,10 @@ static int tmp108_common_probe(struct device *dev, struct regmap *regmap, char *u32 config;int err; + err =devm_regulator_get_enable (dev,"vcc" ); +if (err) +return dev_err_probe (dev, err,"Failed to enable regulator\n" ); + tmp108 =devm_kzalloc (dev,sizeof (*tmp108),GFP_KERNEL );if (!tmp108)return -ENOMEM ;
Signature · 1 line
2.43.0
Guenter Roeck
maintainerQuoted 20 lines · Stanislav Jakubek
TMP108/P3T1085 are powered by the V+/VCC regulator, add support for it.
Signed-off-by Stanislav Jakubek <[email protected]>--- drivers/hwmon/tmp108.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/hwmon/tmp108.c +1
-0@@ -17,6 +17,7 @@#include <linux/init.h> #include <linux/jiffies.h> #include <linux/regmap.h> +#include <linux/regulator/consumer.h> #include <linux/slab.h> #define DRIVER_NAME "tmp108"
drivers/hwmon/tmp108.c static int tmp108_common_probe(struct device *dev, struct regmap *regmap, char * · line 338
Quoted 7 lines
drivers/hwmon/tmp108.c +4
-0@@ -331,6 +332,10 @@ static int tmp108_common_probe(struct device *dev, struct regmap *regmap, char *u32 config;int err; + err =devm_regulator_get_enable (dev,"vcc" ); +if (err) +return dev_err_probe (dev, err,"Failed to enable regulator\n" ); +
Problem with this is that existing devicetree bindings do not provide a reference to the regulator. Those would now fail to instantiate, which would be unacceptable. I think you'll need something like
err = devm_regulator_get_enable_optional(dev, "vcc"); if (err && err != -ENODEV) return dev_err_probe(dev, err, "Failed to enable regulator\n");
Even though the regulator is now mandatory, existing devicetree bindings don't know that.
Guenter
Quoted 22 lines · Guenter Roeck
Quoted 21 lines · Stanislav Jakubek
TMP108/P3T1085 are powered by the V+/VCC regulator, add support for it.
Signed-off-by Stanislav Jakubek <[email protected]>--- drivers/hwmon/tmp108.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/hwmon/tmp108.c +1
-0@@ -17,6 +17,7 @@#include <linux/init.h> #include <linux/jiffies.h> #include <linux/regmap.h> +#include <linux/regulator/consumer.h> #include <linux/slab.h> #define DRIVER_NAME "tmp108"@@ -331,6 +332,10 @@ static int tmp108_common_probe(struct device *dev, struct regmap *regmap, char *u32 config;int err;
Quoted 8 lines
drivers/hwmon/tmp108.c static int tmp108_common_probe(struct device *dev, struct regmap *regmap, char * · line 338
Quoted 4 lines
drivers/hwmon/tmp108.c +4
-0+ err =devm_regulator_get_enable (dev,"vcc" ); +if (err) +return dev_err_probe (dev, err,"Failed to enable regulator\n" ); +Problem with this is that existing devicetree bindings do not provide a reference to the regulator. Those would now fail to instantiate, which would be unacceptable. I think you'll need something like
Doesn't devm_regulator_get_enable fallback to a dummy regulator when a reference to the regulator isn't provided?
lm90 does it this way too.
Regards,
Stanislav
Quoted 10 lines
err = devm_regulator_get_enable_optional(dev, "vcc"); if (err && err != -ENODEV) return dev_err_probe(dev, err, "Failed to enable regulator\n");Even though the regulator is now mandatory, existing devicetree bindings don't know that.
Guenter
Guenter Roeck
maintainerQuoted 32 lines · Stanislav Jakubek
Quoted 22 lines · Guenter Roeck
Quoted 21 lines · Stanislav Jakubek
TMP108/P3T1085 are powered by the V+/VCC regulator, add support for it.
Signed-off-by Stanislav Jakubek <[email protected]>--- drivers/hwmon/tmp108.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/hwmon/tmp108.c +1
-0@@ -17,6 +17,7 @@#include <linux/init.h> #include <linux/jiffies.h> #include <linux/regmap.h> +#include <linux/regulator/consumer.h> #include <linux/slab.h> #define DRIVER_NAME "tmp108"@@ -331,6 +332,10 @@ static int tmp108_common_probe(struct device *dev, struct regmap *regmap, char *u32 config;int err;Quoted 8 lines
drivers/hwmon/tmp108.c static int tmp108_common_probe(struct device *dev, struct regmap *regmap, char * · line 338
Quoted 4 lines
drivers/hwmon/tmp108.c +4
-0+ err =devm_regulator_get_enable (dev,"vcc" ); +if (err) +return dev_err_probe (dev, err,"Failed to enable regulator\n" ); +Problem with this is that existing devicetree bindings do not provide a reference to the regulator. Those would now fail to instantiate, which would be unacceptable. I think you'll need something like
Quoted 5 lines
Doesn't
devm_regulator_get_enablefallback to a dummy regulator when a reference to the regulator isn't provided?lm90 does it this way too.
Ah yes, you are correct. I misinterpreted the code. I'll apply the patch.
Thanks,
Guenter
Quoted 13 lines
Regards,
StanislavQuoted 10 lines
err = devm_regulator_get_enable_optional(dev, "vcc"); if (err && err != -ENODEV) return dev_err_probe(dev, err, "Failed to enable regulator\n");Even though the regulator is now mandatory, existing devicetree bindings don't know that.
Guenter
Quoted 3 lines · Stanislav Jakubek
TMP108/P3T1085 are powered by the V+/VCC regulator, add support for it.
Signed-off-by Stanislav Jakubek <[email protected]>
Applied.
Thanks,
Guenter