Skip to contentSkip to conversation

max8925_power: Use "IS_ENABLED(CONFIG_OF)" for DT code.

PATCH In review Manish Badarkhe 1 participant 3 messages Jan 28, 2014 – May 29, 2014 Arm Samsung Exynos

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 max8925_power: Use "IS_ENABLED(CONFIG_OF)" for DT code.

Instead of "#ifdef CONFIG_OF" use "IS_ENABLED(CONFIG_OF)" option for DT code to avoid if-deffery in code.

---
Changes since V1:
1.Updated code to use "IS_ENABLED" during retrieval
of platform/DT data.

Changes since V2:
1.Updated code as per Dmitry's comment to give preferance to
platform data.

Changes since V3:
1.Updated code to use "IS_ENABLED(CONFIG_OF)" to remove
DT data retrieval function during compilation itself when CONFIG_OF option is not set.

:100644 100644 b4513f2... a7482db... M drivers/power/max8925_power.c

 drivers/power/max8925_power.c |   17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/power/max8925_power.c +5 -12
index b4513f2..a7482db 100644
@@ -427,7 +427,6 @@ static int max8925_deinit_charger(struct max8925_power_info *info)
 	return 0;
 }
 
-#ifdef CONFIG_OF
 static struct max8925_power_pdata *
 max8925_power_dt_init(struct platform_device *pdev)
 {
@@ -440,9 +439,6 @@ max8925_power_dt_init(struct platform_device *pdev)
 	int no_insert_detect;
 	struct max8925_power_pdata *pdata;
 
-	if (!nproot)
-		return pdev->dev.platform_data;
-
 	np = of_find_node_by_name(nproot, "charger");
 	if (!np) {
 		dev_err(&pdev->dev, "failed to find charger node\n");
@@ -468,13 +464,6 @@ max8925_power_dt_init(struct platform_device *pdev)
 
 	return pdata;
 }
-#else
-static struct max8925_power_pdata *
-max8925_power_dt_init(struct platform_device *pdev)
-{
-	return pdev->dev.platform_data;
-}
-#endif
 
 static int max8925_power_probe(struct platform_device *pdev)
 {
@@ -483,7 +472,11 @@ static int max8925_power_probe(struct platform_device *pdev)
 	struct max8925_power_info *info;
 	int ret;
 
-	pdata = max8925_power_dt_init(pdev);
+	pdata = dev_get_platdata(&pdev->dev);
+
+	if (IS_ENABLED(CONFIG_OF) && !pdata && chip->dev->of_node)
+		pdata = max8925_power_dt_init(pdev);
+
 	if (!pdata) {
 		dev_err(&pdev->dev, "platform data isn't assigned to "
 			"power supply\n");
Signature · 1 line
1.7.10.4
#1 lore raw

Hi Dmitry,

Quoted 61 lines · Manish Badarkhe

Instead of "#ifdef CONFIG_OF" use "IS_ENABLED(CONFIG_OF)" option for DT code to avoid if-deffery in code.

---
Changes since V1:
1.Updated code to use "IS_ENABLED" during retrieval
of platform/DT data.

Changes since V2:
1.Updated code as per Dmitry's comment to give preferance to
platform data.

Changes since V3:
1.Updated code to use "IS_ENABLED(CONFIG_OF)" to remove
DT data retrieval function during compilation itself when CONFIG_OF option is not set.

:100644 100644 b4513f2... a7482db... M drivers/power/max8925_power.c

 drivers/power/max8925_power.c |   17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/power/max8925_power.c +0 -11
index b4513f2..a7482db 100644
@@ -427,7 +427,6 @@ static int max8925_deinit_charger(struct max8925_power_info *info)
        return 0;
 }
 
-#ifdef CONFIG_OF
 static struct max8925_power_pdata *
 max8925_power_dt_init(struct platform_device *pdev)
 {
@@ -440,9 +439,6 @@ max8925_power_dt_init(struct platform_device *pdev)
        int no_insert_detect;
        struct max8925_power_pdata *pdata;
 
-       if (!nproot)
-               return pdev->dev.platform_data;
-
        np = of_find_node_by_name(nproot, "charger");
        if (!np) {
                dev_err(&pdev->dev, "failed to find charger node\n");
@@ -468,13 +464,6 @@ max8925_power_dt_init(struct platform_device *pdev)
 
        return pdata;
 }
-#else
-static struct max8925_power_pdata *
-max8925_power_dt_init(struct platform_device *pdev)
-{
-       return pdev->dev.platform_data;
-}
-#endif
 
 static int max8925_power_probe(struct platform_device *pdev)
 {
@@ -483,7 +472,11 @@ static int max8925_power_probe(struct platform_device *pdev)
        struct max8925_power_info *info;
        int ret;

drivers/power/max8925_power.c static int max8925_power_probe(struct platform_device *pdev) · line 482

Quoted 10 lines
drivers/power/max8925_power.c +5 -1
 
-       pdata = max8925_power_dt_init(pdev);
+       pdata = dev_get_platdata(&pdev->dev);
+
+       if (IS_ENABLED(CONFIG_OF) && !pdata && chip->dev->of_node)
+               pdata = max8925_power_dt_init(pdev);
+
        if (!pdata) {
                dev_err(&pdev->dev, "platform data isn't assigned to "
                        "power supply\n");

Gentle ping!!
Please let me know, are there any review comments on this patch?

Thanks
Manish Badarkhe

#2 lore raw

Hi Dmitry,

Quoted 66 lines · Manish Badarkhe

Hi Dmitry,

Quoted 62 lines · Manish Badarkhe

Instead of "#ifdef CONFIG_OF" use "IS_ENABLED(CONFIG_OF)" option for DT code to avoid if-deffery in code.

---
Changes since V1:
1.Updated code to use "IS_ENABLED" during retrieval
of platform/DT data.

Changes since V2:
1.Updated code as per Dmitry's comment to give preferance to
platform data.

Changes since V3:
1.Updated code to use "IS_ENABLED(CONFIG_OF)" to remove
DT data retrieval function during compilation itself when CONFIG_OF option is not set.

:100644 100644 b4513f2... a7482db... M drivers/power/max8925_power.c

 drivers/power/max8925_power.c |   17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/power/max8925_power.c +0 -11
index b4513f2..a7482db 100644
@@ -427,7 +427,6 @@ static int max8925_deinit_charger(struct max8925_power_info *info)
        return 0;
 }
 
-#ifdef CONFIG_OF
 static struct max8925_power_pdata *
 max8925_power_dt_init(struct platform_device *pdev)
 {
@@ -440,9 +439,6 @@ max8925_power_dt_init(struct platform_device *pdev)
        int no_insert_detect;
        struct max8925_power_pdata *pdata;
 
-       if (!nproot)
-               return pdev->dev.platform_data;
-
        np = of_find_node_by_name(nproot, "charger");
        if (!np) {
                dev_err(&pdev->dev, "failed to find charger node\n");
@@ -468,13 +464,6 @@ max8925_power_dt_init(struct platform_device *pdev)
 
        return pdata;
 }
-#else
-static struct max8925_power_pdata *
-max8925_power_dt_init(struct platform_device *pdev)
-{
-       return pdev->dev.platform_data;
-}
-#endif
 
 static int max8925_power_probe(struct platform_device *pdev)
 {
@@ -483,7 +472,11 @@ static int max8925_power_probe(struct platform_device *pdev)
        struct max8925_power_info *info;
        int ret;
 
Quoted 12 lines

drivers/power/max8925_power.c static int max8925_power_probe(struct platform_device *pdev) · line 482

Quoted 9 lines
drivers/power/max8925_power.c +5 -1
-       pdata = max8925_power_dt_init(pdev);
+       pdata = dev_get_platdata(&pdev->dev);
+
+       if (IS_ENABLED(CONFIG_OF) && !pdata && chip->dev->of_node)
+               pdata = max8925_power_dt_init(pdev);
+
        if (!pdata) {
                dev_err(&pdev->dev, "platform data isn't assigned to "
                        "power supply\n");

Gentle ping!!
Please let me know, are there any review comments on this patch?

Gentle ping!!

Thanks
Manish Badarkhe