diff mbox

[4/4] regulator: fixed: Properly use input_supply parameter from device tree

Message ID 1352991396-19589-5-git-send-email-rogerq@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Roger Quadros Nov. 15, 2012, 2:56 p.m. UTC
The device tree node will provide the input supply name as
a string. Use that to populate the supply_name parameter of
the regulator descriptor.

Also correct the documentation to reflect the same.

Signed-off-by: Roger Quadros <rogerq@ti.com>
CC: Laxman Dewangan <ldewangan@nvidia.com>
CC: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 .../bindings/regulator/fixed-regulator.txt         |    6 +++---
 drivers/regulator/fixed.c                          |    6 ++++--
 2 files changed, 7 insertions(+), 5 deletions(-)

Comments

Laxman Dewangan Nov. 15, 2012, 7:11 p.m. UTC | #1
On 11/15/2012 09:56 AM, Roger Quadros wrote:
> The device tree node will provide the input supply name as
> a string. Use that to populate the supply_name parameter of
> the regulator descriptor.
>
> Also correct the documentation to reflect the same.
>
> Signed-off-by: Roger Quadros <rogerq@ti.com>
> CC: Laxman Dewangan <ldewangan@nvidia.com>
> CC: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
>   		regulator-boot-on;
>   		gpio-open-drain;
> -		vin-supply = <&parent_reg>;
> +		vin-supply = "input-supply-name";

This is not correct as per the regulator binding. It says
  - <name>-supply: phandle to the parent supply/regulator node

So we need to pass the phandle rather than string.

Just for curiosity, why do you want this change? What is the issue are 
you facing.

This change will creates regression on many platform.


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Roger Quadros Nov. 16, 2012, 10:23 a.m. UTC | #2
On 11/15/2012 09:11 PM, Laxman Dewangan wrote:
> On 11/15/2012 09:56 AM, Roger Quadros wrote:
>> The device tree node will provide the input supply name as
>> a string. Use that to populate the supply_name parameter of
>> the regulator descriptor.
>>
>> Also correct the documentation to reflect the same.
>>
>> Signed-off-by: Roger Quadros <rogerq@ti.com>
>> CC: Laxman Dewangan <ldewangan@nvidia.com>
>> CC: Mark Brown <broonie@opensource.wolfsonmicro.com>
>> ---
>>           regulator-boot-on;
>>           gpio-open-drain;
>> -        vin-supply = <&parent_reg>;
>> +        vin-supply = "input-supply-name";
> 
> This is not correct as per the regulator binding. It says
>  - <name>-supply: phandle to the parent supply/regulator node
> 
> So we need to pass the phandle rather than string.
> 

If you see of_get_fixed_voltage_config() in drivers/regulator/fixed.c,
all it does (without my patch) is

	if (of_find_property(np, "vin-supply", NULL))
		config->input_supply = "vin";

How is this supposed to work? How does phandle supplied in vin-supply
map to config->input_supply?

This config->input_supply is a string which is used in
reg_fixed_voltage_probe() like below

      if (config->input_supply) {
               drvdata->desc.supply_name = kstrdup(config->input_supply,
                                                        GFP_KERNEL);

So I don't understand how supplying phandle would work. Maybe I missed
something?

> Just for curiosity, why do you want this change? What is the issue are
> you facing.
>

Because I could not understood how the original approach would work. But
if you can explain how it works maybe my patch is redundant.

> This change will creates regression on many platform.
> 

Did you test your platform on 3.7-rc5?

regards,
-roger

> 
> -----------------------------------------------------------------------------------
> 
> This email message is for the sole use of the intended recipient(s) and
> may contain
> confidential information.  Any unauthorized review, use, disclosure or
> distribution
> is prohibited.  If you are not the intended recipient, please contact
> the sender by
> reply email and destroy all copies of the original message.
> -----------------------------------------------------------------------------------
> 
> -- 
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mark Brown Dec. 15, 2012, 2:55 p.m. UTC | #3
On Fri, Nov 16, 2012 at 12:23:43PM +0200, Roger Quadros wrote:

> How is this supposed to work? How does phandle supplied in vin-supply
> map to config->input_supply?

You should provide a separate property to name the supply, or just pick
a fixed name in the fixed voltage driver.
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/regulator/fixed-regulator.txt b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt
index 4fae41d..fe34114 100644
--- a/Documentation/devicetree/bindings/regulator/fixed-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt
@@ -7,10 +7,10 @@  Optional properties:
 - gpio: gpio to use for enable control
 - startup-delay-us: startup time in microseconds
 - enable-active-high: Polarity of GPIO is Active high
-If this property is missing, the default assumed is Active low.
+  If this property is missing, the default assumed is Active low.
 - gpio-open-drain: GPIO is open drain type.
   If this property is missing then default assumption is false.
--vin-supply: Input supply name.
+- vin-supply: Input supply name.
 
 Any property defined as part of the core regulator
 binding, defined in regulator.txt, can also be used.
@@ -30,5 +30,5 @@  Example:
 		enable-active-high;
 		regulator-boot-on;
 		gpio-open-drain;
-		vin-supply = <&parent_reg>;
+		vin-supply = "input-supply-name";
 	};
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 185468c..3a6f4ad 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -53,6 +53,7 @@  of_get_fixed_voltage_config(struct device *dev)
 	struct device_node *np = dev->of_node;
 	const __be32 *delay;
 	struct regulator_init_data *init_data;
+	const char *vin_name;
 
 	config = devm_kzalloc(dev, sizeof(struct fixed_voltage_config),
 								 GFP_KERNEL);
@@ -102,8 +103,9 @@  of_get_fixed_voltage_config(struct device *dev)
 	if (of_find_property(np, "gpio-open-drain", NULL))
 		config->gpio_is_open_drain = true;
 
-	if (of_find_property(np, "vin-supply", NULL))
-		config->input_supply = "vin";
+	vin_name = of_get_property(np, "vin-supply", NULL);
+	if (vin_name)
+		config->input_supply = vin_name;
 
 	return config;
 }