Skip to contentSkip to conversation

net: davinci: fix building davinci mdio code without CONFIG_OF

PATCH Applied Arnd Bergmann 3 participants 4 messages May 28, 2018 – May 30, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: davinci: fix building davinci mdio code without CONFIG_OF

Test-building this driver on targets without CONFIG_OF revealed a build failure:

drivers/net/ethernet/ti/davinci_mdio.c: In function 'davinci_mdio_probe':
drivers/net/ethernet/ti/davinci_mdio.c:380:9: error: implicit declaration of function 'davinci_mdio_probe_dt'; did you mean 'davinci_mdio_probe'? [-Werror=implicit-function-declaration]

This adjusts the #ifdef logic in the driver to make it build in all configurations.

Fixes 2652113ff043 ("net: ethernet: ti: Allow most drivers with COMPILE_TEST")
---
 drivers/net/ethernet/ti/davinci_mdio.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/ti/davinci_mdio.c +1 -3
index 8ac72831af05..a98aedae1b41 100644
@@ -321,7 +321,6 @@ static int davinci_mdio_write(struct mii_bus *bus, int phy_id,
 	return ret;
 }
 
-#if IS_ENABLED(CONFIG_OF)
 static int davinci_mdio_probe_dt(struct mdio_platform_data *data,
 			 struct platform_device *pdev)
 {
@@ -339,7 +338,6 @@ static int davinci_mdio_probe_dt(struct mdio_platform_data *data,
 
 	return 0;
 }
-#endif
 
 #if IS_ENABLED(CONFIG_OF)
 static const struct davinci_mdio_of_param of_cpsw_mdio_data = {
@@ -374,7 +372,7 @@ static int davinci_mdio_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	if (dev->of_node) {
+	if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
 		const struct of_device_id	*of_id;
 
 		ret = davinci_mdio_probe_dt(&data->pdata, pdev);
Signature · 1 line
2.9.0
Acked-by on v1 1/1
#1 lore raw

Hi Arnd,

Quoted 11 lines · Arnd Bergmann

Test-building this driver on targets without CONFIG_OF revealed a build failure:

drivers/net/ethernet/ti/davinci_mdio.c: In function 'davinci_mdio_probe':
drivers/net/ethernet/ti/davinci_mdio.c:380:9: error: implicit declaration of function 'davinci_mdio_probe_dt'; did you mean 'davinci_mdio_probe'? [-Werror=implicit-function-declaration]

This adjusts the #ifdef logic in the driver to make it build in all configurations.

Fixes 2652113ff043 ("net: ethernet: ti: Allow most drivers with COMPILE_TEST")

Your patch fixes the issue.

One question below:

Quoted 25 lines
---
 drivers/net/ethernet/ti/davinci_mdio.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/ti/davinci_mdio.c +0 -2
index 8ac72831af05..a98aedae1b41 100644
@@ -321,7 +321,6 @@ static int davinci_mdio_write(struct mii_bus *bus, int phy_id,
 	return ret;
 }
 
-#if IS_ENABLED(CONFIG_OF)
 static int davinci_mdio_probe_dt(struct mdio_platform_data *data,
 			 struct platform_device *pdev)
 {
@@ -339,7 +338,6 @@ static int davinci_mdio_probe_dt(struct mdio_platform_data *data,
 
 	return 0;
 }
-#endif
 
 #if IS_ENABLED(CONFIG_OF)
 static const struct davinci_mdio_of_param of_cpsw_mdio_data = {

drivers/net/ethernet/ti/davinci_mdio.c static int davinci_mdio_probe(struct platform_device *pdev) · line 378

Quoted 8 lines
drivers/net/ethernet/ti/davinci_mdio.c +1 -1
@@ -374,7 +372,7 @@ static int davinci_mdio_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	if (dev->of_node) {
+	if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
 		const struct of_device_id	*of_id;
 
 		ret = davinci_mdio_probe_dt(&data->pdata, pdev);

I was expecting this one change to fix the issue since the if() block should be compiled away removing references to davinci_mdio_probe_dt().

The code does get compiled out and there are no references to davinci_mdio_probe_dt() in the final object when !CONFIG_OF.

But the compile error remains if the #ifdefs you removed above are installed back. Not sure why.

Thanks,
Sekhar

#2 lore raw
Quoted 13 lines · Sekhar Nori

drivers/net/ethernet/ti/davinci_mdio.c static int davinci_mdio_probe(struct platform_device *pdev) · line 378

Quoted 9 lines
drivers/net/ethernet/ti/davinci_mdio.c +1 -1
@@ -374,7 +372,7 @@ static int davinci_mdio_probe(struct platform_device *pdev)
              return -ENOMEM;
      }
 
-     if (dev->of_node) {
+     if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
              const struct of_device_id       *of_id;
 
              ret = davinci_mdio_probe_dt(&data->pdata, pdev);

I was expecting this one change to fix the issue since the if() block should be compiled away removing references to davinci_mdio_probe_dt().

Quoted 5 lines

The code does get compiled out and there are no references to davinci_mdio_probe_dt() in the final object when !CONFIG_OF.

But the compile error remains if the #ifdefs you removed above are installed back. Not sure why.

The way that "if (IS_ENABLED())" works, everything gets compiled at first, but then the compiler uses dead code elimination to remove it from the output after verifying that everything builds.

Arnd

maintainer Applied
#3 lore raw
In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>
Date: Mon, 28 May 2018 17:50:20 +0200

Quoted 11 lines

Test-building this driver on targets without CONFIG_OF revealed a build failure:

drivers/net/ethernet/ti/davinci_mdio.c: In function 'davinci_mdio_probe':
drivers/net/ethernet/ti/davinci_mdio.c:380:9: error: implicit declaration of function 'davinci_mdio_probe_dt'; did you mean 'davinci_mdio_probe'? [-Werror=implicit-function-declaration]

This adjusts the #ifdef logic in the driver to make it build in all configurations.

Fixes 2652113ff043 ("net: ethernet: ti: Allow most drivers with COMPILE_TEST")

Applied to net-next.