Re: [PATCH 5/7] mfd: max8925: support dt for regulator

2012-11-07 Thread Qing Xu

On 11/06/2012 05:01 PM, Mark Brown wrote:

On Tue, Nov 06, 2012 at 03:44:52PM +0800, Qing Xu wrote:

From: Qing Xu 

Signed-off-by: Qing Xu 
---
  drivers/regulator/max8925-regulator.c |   35 -
  1 files changed, 34 insertions(+), 1 deletions(-)

There is no binding document here, documentation is required for all new
bindings.


+   nproot = of_find_node_by_name(nproot, "regulators");
+   if (!nproot) {
+   dev_err(>dev, "failed to find regulators node\n");
+   return -ENODEV;
+   }
+   for_each_child_of_node(nproot, np) {
+   if (!of_node_cmp(np->name, info->desc.name)) {
+   config->init_data =
+   of_get_regulator_init_data(>dev, np);
+   config->of_node = np;
+   break;
+   }
+   }

You appear to be open coding something like the standard helpers in
of_regulator.h, you should use those helpers.
Mark, thanks for your so quick response! I updated the patch in v2, 
please help me review it again.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 5/7] mfd: max8925: support dt for regulator

2012-11-07 Thread Qing Xu

On 11/06/2012 05:01 PM, Mark Brown wrote:

On Tue, Nov 06, 2012 at 03:44:52PM +0800, Qing Xu wrote:

From: Qing Xu qi...@marvell.com

Signed-off-by: Qing Xu qi...@marvell.com
---
  drivers/regulator/max8925-regulator.c |   35 -
  1 files changed, 34 insertions(+), 1 deletions(-)

There is no binding document here, documentation is required for all new
bindings.


+   nproot = of_find_node_by_name(nproot, regulators);
+   if (!nproot) {
+   dev_err(pdev-dev, failed to find regulators node\n);
+   return -ENODEV;
+   }
+   for_each_child_of_node(nproot, np) {
+   if (!of_node_cmp(np-name, info-desc.name)) {
+   config-init_data =
+   of_get_regulator_init_data(pdev-dev, np);
+   config-of_node = np;
+   break;
+   }
+   }

You appear to be open coding something like the standard helpers in
of_regulator.h, you should use those helpers.
Mark, thanks for your so quick response! I updated the patch in v2, 
please help me review it again.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 5/7] mfd: max8925: support dt for regulator

2012-11-06 Thread Mark Brown
On Tue, Nov 06, 2012 at 03:44:52PM +0800, Qing Xu wrote:
> From: Qing Xu 
> 
> Signed-off-by: Qing Xu 
> ---
>  drivers/regulator/max8925-regulator.c |   35 
> -
>  1 files changed, 34 insertions(+), 1 deletions(-)

There is no binding document here, documentation is required for all new
bindings.

> + nproot = of_find_node_by_name(nproot, "regulators");
> + if (!nproot) {
> + dev_err(>dev, "failed to find regulators node\n");
> + return -ENODEV;
> + }
> + for_each_child_of_node(nproot, np) {
> + if (!of_node_cmp(np->name, info->desc.name)) {
> + config->init_data =
> + of_get_regulator_init_data(>dev, np);
> + config->of_node = np;
> + break;
> + }
> + }

You appear to be open coding something like the standard helpers in
of_regulator.h, you should use those helpers.


signature.asc
Description: Digital signature


Re: [PATCH 5/7] mfd: max8925: support dt for regulator

2012-11-06 Thread Mark Brown
On Tue, Nov 06, 2012 at 03:44:52PM +0800, Qing Xu wrote:
 From: Qing Xu qi...@marvell.com
 
 Signed-off-by: Qing Xu qi...@marvell.com
 ---
  drivers/regulator/max8925-regulator.c |   35 
 -
  1 files changed, 34 insertions(+), 1 deletions(-)

There is no binding document here, documentation is required for all new
bindings.

 + nproot = of_find_node_by_name(nproot, regulators);
 + if (!nproot) {
 + dev_err(pdev-dev, failed to find regulators node\n);
 + return -ENODEV;
 + }
 + for_each_child_of_node(nproot, np) {
 + if (!of_node_cmp(np-name, info-desc.name)) {
 + config-init_data =
 + of_get_regulator_init_data(pdev-dev, np);
 + config-of_node = np;
 + break;
 + }
 + }

You appear to be open coding something like the standard helpers in
of_regulator.h, you should use those helpers.


signature.asc
Description: Digital signature


[PATCH 5/7] mfd: max8925: support dt for regulator

2012-11-05 Thread Qing Xu
From: Qing Xu 

Signed-off-by: Qing Xu 
---
 drivers/regulator/max8925-regulator.c |   35 -
 1 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/max8925-regulator.c 
b/drivers/regulator/max8925-regulator.c
index 9bb0be3..16d9457 100644
--- a/drivers/regulator/max8925-regulator.c
+++ b/drivers/regulator/max8925-regulator.c
@@ -17,6 +17,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define SD1_DVM_VMIN   85
 #define SD1_DVM_VMAX   100
@@ -214,6 +216,34 @@ static struct max8925_regulator_info 
max8925_regulator_info[] = {
MAX8925_LDO(20, 750, 3900, 50),
 };
 
+#ifdef CONFIG_OF
+static int max8925_regulator_dt_init(struct platform_device *pdev,
+   struct max8925_regulator_info *info,
+   struct regulator_config *config)
+{
+   struct device_node *nproot, *np;
+   nproot = pdev->dev.parent->of_node;
+   if (!nproot)
+   return -ENODEV;
+   nproot = of_find_node_by_name(nproot, "regulators");
+   if (!nproot) {
+   dev_err(>dev, "failed to find regulators node\n");
+   return -ENODEV;
+   }
+   for_each_child_of_node(nproot, np) {
+   if (!of_node_cmp(np->name, info->desc.name)) {
+   config->init_data =
+   of_get_regulator_init_data(>dev, np);
+   config->of_node = np;
+   break;
+   }
+   }
+   return 0;
+}
+#else
+#define max8925_regulator_dt_init(x, y, z) (-1)
+#endif
+
 static int __devinit max8925_regulator_probe(struct platform_device *pdev)
 {
struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
@@ -243,9 +273,12 @@ static int __devinit max8925_regulator_probe(struct 
platform_device *pdev)
ri->chip = chip;
 
config.dev = >dev;
-   config.init_data = pdata;
config.driver_data = ri;
 
+   if (max8925_regulator_dt_init(pdev, ri, ))
+   if (pdata)
+   config.init_data = pdata;
+
rdev = regulator_register(>desc, );
if (IS_ERR(rdev)) {
dev_err(>dev, "failed to register regulator %s\n",
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/7] mfd: max8925: support dt for regulator

2012-11-05 Thread Qing Xu
From: Qing Xu qi...@marvell.com

Signed-off-by: Qing Xu qi...@marvell.com
---
 drivers/regulator/max8925-regulator.c |   35 -
 1 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/max8925-regulator.c 
b/drivers/regulator/max8925-regulator.c
index 9bb0be3..16d9457 100644
--- a/drivers/regulator/max8925-regulator.c
+++ b/drivers/regulator/max8925-regulator.c
@@ -17,6 +17,8 @@
 #include linux/regulator/driver.h
 #include linux/regulator/machine.h
 #include linux/mfd/max8925.h
+#include linux/of.h
+#include linux/regulator/of_regulator.h
 
 #define SD1_DVM_VMIN   85
 #define SD1_DVM_VMAX   100
@@ -214,6 +216,34 @@ static struct max8925_regulator_info 
max8925_regulator_info[] = {
MAX8925_LDO(20, 750, 3900, 50),
 };
 
+#ifdef CONFIG_OF
+static int max8925_regulator_dt_init(struct platform_device *pdev,
+   struct max8925_regulator_info *info,
+   struct regulator_config *config)
+{
+   struct device_node *nproot, *np;
+   nproot = pdev-dev.parent-of_node;
+   if (!nproot)
+   return -ENODEV;
+   nproot = of_find_node_by_name(nproot, regulators);
+   if (!nproot) {
+   dev_err(pdev-dev, failed to find regulators node\n);
+   return -ENODEV;
+   }
+   for_each_child_of_node(nproot, np) {
+   if (!of_node_cmp(np-name, info-desc.name)) {
+   config-init_data =
+   of_get_regulator_init_data(pdev-dev, np);
+   config-of_node = np;
+   break;
+   }
+   }
+   return 0;
+}
+#else
+#define max8925_regulator_dt_init(x, y, z) (-1)
+#endif
+
 static int __devinit max8925_regulator_probe(struct platform_device *pdev)
 {
struct max8925_chip *chip = dev_get_drvdata(pdev-dev.parent);
@@ -243,9 +273,12 @@ static int __devinit max8925_regulator_probe(struct 
platform_device *pdev)
ri-chip = chip;
 
config.dev = pdev-dev;
-   config.init_data = pdata;
config.driver_data = ri;
 
+   if (max8925_regulator_dt_init(pdev, ri, config))
+   if (pdata)
+   config.init_data = pdata;
+
rdev = regulator_register(ri-desc, config);
if (IS_ERR(rdev)) {
dev_err(pdev-dev, failed to register regulator %s\n,
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/