* [PATCH 0/5] Provide empty functions if OF_NET is not configured
@ 2013-04-02 19:35 Guenter Roeck
2013-04-02 19:35 ` [PATCH 2/5] net/cadence/at91_ether: Simplify OF dependencies Guenter Roeck
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Guenter Roeck @ 2013-04-02 19:35 UTC (permalink / raw)
To: David S. Miller, Nicolas Ferre, Grant Likely
Cc: Rob Herring, David Daney, netdev, linux-kernel,
devicetree-discuss, Guenter Roeck
Provide empty functions for of_get_phy_mode() and of_get_mac_address()
if OF_NET is not configured. Modify affected drivers to rely on the
now available functions.
----------------------------------------------------------------
Guenter Roeck (5):
of_net.h: Provide dummy functions if OF_NET is not configured
net/cadence/at91_ether: Simplify OF dependencies
net/cadence/macb: Simplify OF dependencies
net/freescale/fec: Simplify OF dependencies
net/nxp/lpc_eth: Drop ifdef CONFIG_OF_NET
drivers/net/ethernet/cadence/at91_ether.c | 44 ++++-------------------------
drivers/net/ethernet/cadence/macb.c | 43 ++++------------------------
drivers/net/ethernet/freescale/fec.c | 19 +------------
drivers/net/ethernet/nxp/lpc_eth.c | 2 --
include/linux/of_net.h | 10 +++++++
5 files changed, 23 insertions(+), 95 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/5] of_net.h: Provide empty functions if OF_NET is not configured
[not found] ` <1364931311-30603-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
@ 2013-04-02 19:35 ` Guenter Roeck
2013-04-02 19:35 ` [PATCH 3/5] net/cadence/macb: Simplify OF dependencies Guenter Roeck
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2013-04-02 19:35 UTC (permalink / raw)
To: David S. Miller, Nicolas Ferre, Grant Likely
Cc: David Daney, netdev-u79uwXL29TY76Z2rM5mHXA,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Guenter Roeck
of_get_mac_address() and of_get_phy_mode() are only provided if OF_NET
is configured. While most callers check for the define, not all do, and those
who do require #ifdef around the code. For those who don't, the missing check
can result in errors such as
arch/powerpc/sysdev/tsi108_dev.c:107:3: error: implicit declaration of
function 'of_get_mac_address' [-Werror=implicit-function-declaration]
arch/powerpc/sysdev/mv64x60_dev.c:253:2: error: implicit declaration of
function 'of_get_mac_address' [-Werror=implicit-function-declaration]
Provide empty functions if OF_NET is not configured.
This is safe because all callers do check the return values.
Cc: David Daney <david.daney-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
Signed-off-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
Acked-by: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
---
include/linux/of_net.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/include/linux/of_net.h b/include/linux/of_net.h
index f474641..61bf53b 100644
--- a/include/linux/of_net.h
+++ b/include/linux/of_net.h
@@ -11,6 +11,16 @@
#include <linux/of.h>
extern const int of_get_phy_mode(struct device_node *np);
extern const void *of_get_mac_address(struct device_node *np);
+#else
+static inline const int of_get_phy_mode(struct device_node *np)
+{
+ return -ENODEV;
+}
+
+static inline const void *of_get_mac_address(struct device_node *np)
+{
+ return NULL;
+}
#endif
#endif /* __LINUX_OF_NET_H */
--
1.7.9.7
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/5] net/cadence/at91_ether: Simplify OF dependencies
2013-04-02 19:35 [PATCH 0/5] Provide empty functions if OF_NET is not configured Guenter Roeck
@ 2013-04-02 19:35 ` Guenter Roeck
[not found] ` <1364931311-30603-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-04-02 20:44 ` [PATCH 0/5] Provide empty functions if OF_NET is not configured David Miller
2 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2013-04-02 19:35 UTC (permalink / raw)
To: David S. Miller, Nicolas Ferre, Grant Likely
Cc: Rob Herring, David Daney, netdev, linux-kernel,
devicetree-discuss, Guenter Roeck
With of_get_mac_address() and of_get_phy_mode() now defined as dummy
functions if OF_NET is not configured, it is no longer necessary to
provide OF dependent functions as front-end. Also, the two functions
depend on OF_NET, not on OF, so the conditional code was not correct
anyway.
Drop the front-end functions and call of_get_mac_address() and
of_get_phy_mode() directly instead.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/net/ethernet/cadence/at91_ether.c | 44 ++++-------------------------
1 file changed, 6 insertions(+), 38 deletions(-)
diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c
index 3becdb2..50565cb 100644
--- a/drivers/net/ethernet/cadence/at91_ether.c
+++ b/drivers/net/ethernet/cadence/at91_ether.c
@@ -303,42 +303,7 @@ static const struct of_device_id at91ether_dt_ids[] = {
{ .compatible = "cdns,emac" },
{ /* sentinel */ }
};
-
MODULE_DEVICE_TABLE(of, at91ether_dt_ids);
-
-static int at91ether_get_phy_mode_dt(struct platform_device *pdev)
-{
- struct device_node *np = pdev->dev.of_node;
-
- if (np)
- return of_get_phy_mode(np);
-
- return -ENODEV;
-}
-
-static int at91ether_get_hwaddr_dt(struct macb *bp)
-{
- struct device_node *np = bp->pdev->dev.of_node;
-
- if (np) {
- const char *mac = of_get_mac_address(np);
- if (mac) {
- memcpy(bp->dev->dev_addr, mac, ETH_ALEN);
- return 0;
- }
- }
-
- return -ENODEV;
-}
-#else
-static int at91ether_get_phy_mode_dt(struct platform_device *pdev)
-{
- return -ENODEV;
-}
-static int at91ether_get_hwaddr_dt(struct macb *bp)
-{
- return -ENODEV;
-}
#endif
/* Detect MAC & PHY and perform ethernet interface initialization */
@@ -352,6 +317,7 @@ static int __init at91ether_probe(struct platform_device *pdev)
struct macb *lp;
int res;
u32 reg;
+ const char *mac;
regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!regs)
@@ -403,11 +369,13 @@ static int __init at91ether_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dev);
SET_NETDEV_DEV(dev, &pdev->dev);
- res = at91ether_get_hwaddr_dt(lp);
- if (res < 0)
+ mac = of_get_mac_address(pdev->dev.of_node);
+ if (mac)
+ memcpy(lp->dev->dev_addr, mac, ETH_ALEN);
+ else
macb_get_hwaddr(lp);
- res = at91ether_get_phy_mode_dt(pdev);
+ res = of_get_phy_mode(pdev->dev.of_node);
if (res < 0) {
if (board_data && board_data->is_rmii)
lp->phy_interface = PHY_INTERFACE_MODE_RMII;
--
1.7.9.7
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/5] net/cadence/macb: Simplify OF dependencies
[not found] ` <1364931311-30603-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-04-02 19:35 ` [PATCH 1/5] of_net.h: Provide empty functions if OF_NET is not configured Guenter Roeck
@ 2013-04-02 19:35 ` Guenter Roeck
2013-04-02 19:35 ` [PATCH 4/5] net/freescale/fec: " Guenter Roeck
2013-04-02 19:35 ` [PATCH 5/5] net/nxp/lpc_eth: Drop ifdef CONFIG_OF_NET Guenter Roeck
3 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2013-04-02 19:35 UTC (permalink / raw)
To: David S. Miller, Nicolas Ferre, Grant Likely
Cc: David Daney, netdev-u79uwXL29TY76Z2rM5mHXA,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Guenter Roeck
With of_get_mac_address() and of_get_phy_mode() now defined as dummy
functions if OF_NET is not configured, it is no longer necessary to
provide OF dependent functions as front-end. Also, the two functions
depend on OF_NET, not on OF, so the conditional code was not correct
anyway.
Drop the front-end functions and call of_get_mac_address() and
of_get_phy_mode() directly instead.
Signed-off-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
---
drivers/net/ethernet/cadence/macb.c | 43 +++++------------------------------
1 file changed, 6 insertions(+), 37 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 7903943..b2a9d20 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -1472,41 +1472,7 @@ static const struct of_device_id macb_dt_ids[] = {
{ .compatible = "cdns,gem" },
{ /* sentinel */ }
};
-
MODULE_DEVICE_TABLE(of, macb_dt_ids);
-
-static int macb_get_phy_mode_dt(struct platform_device *pdev)
-{
- struct device_node *np = pdev->dev.of_node;
-
- if (np)
- return of_get_phy_mode(np);
-
- return -ENODEV;
-}
-
-static int macb_get_hwaddr_dt(struct macb *bp)
-{
- struct device_node *np = bp->pdev->dev.of_node;
- if (np) {
- const char *mac = of_get_mac_address(np);
- if (mac) {
- memcpy(bp->dev->dev_addr, mac, ETH_ALEN);
- return 0;
- }
- }
-
- return -ENODEV;
-}
-#else
-static int macb_get_phy_mode_dt(struct platform_device *pdev)
-{
- return -ENODEV;
-}
-static int macb_get_hwaddr_dt(struct macb *bp)
-{
- return -ENODEV;
-}
#endif
static int __init macb_probe(struct platform_device *pdev)
@@ -1519,6 +1485,7 @@ static int __init macb_probe(struct platform_device *pdev)
u32 config;
int err = -ENXIO;
struct pinctrl *pinctrl;
+ const char *mac;
regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!regs) {
@@ -1592,11 +1559,13 @@ static int __init macb_probe(struct platform_device *pdev)
config |= macb_dbw(bp);
macb_writel(bp, NCFGR, config);
- err = macb_get_hwaddr_dt(bp);
- if (err < 0)
+ mac = of_get_mac_address(pdev->dev.of_node);
+ if (mac)
+ memcpy(bp->dev->dev_addr, mac, ETH_ALEN);
+ else
macb_get_hwaddr(bp);
- err = macb_get_phy_mode_dt(pdev);
+ err = of_get_phy_mode(pdev->dev.of_node);
if (err < 0) {
pdata = pdev->dev.platform_data;
if (pdata && pdata->is_rmii)
--
1.7.9.7
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/5] net/freescale/fec: Simplify OF dependencies
[not found] ` <1364931311-30603-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-04-02 19:35 ` [PATCH 1/5] of_net.h: Provide empty functions if OF_NET is not configured Guenter Roeck
2013-04-02 19:35 ` [PATCH 3/5] net/cadence/macb: Simplify OF dependencies Guenter Roeck
@ 2013-04-02 19:35 ` Guenter Roeck
2013-04-02 19:35 ` [PATCH 5/5] net/nxp/lpc_eth: Drop ifdef CONFIG_OF_NET Guenter Roeck
3 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2013-04-02 19:35 UTC (permalink / raw)
To: David S. Miller, Nicolas Ferre, Grant Likely
Cc: David Daney, netdev-u79uwXL29TY76Z2rM5mHXA,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Guenter Roeck
Since of_get_mac_address() is now defined even if CONFIG_OF_NET
is not configured, the ifdef around the code calling it is no longer
necessary and can be removed.
Similar, since of_get_phy_mode() is now defined as dummy function
if OF_NET is not configured, it is no longer necessary to provide
an OF dependent function as front-end. Also, the function depends
on OF_NET, not on OF, so the conditional code was not correct anyway.
Drop the front-end function and call of_get_phy_mode() directly.
Signed-off-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
---
drivers/net/ethernet/freescale/fec.c | 19 +------------------
1 file changed, 1 insertion(+), 18 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index 911d025..d374a94 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -868,7 +868,6 @@ static void fec_get_mac(struct net_device *ndev)
*/
iap = macaddr;
-#ifdef CONFIG_OF
/*
* 2) from device tree data
*/
@@ -880,7 +879,6 @@ static void fec_get_mac(struct net_device *ndev)
iap = (unsigned char *) mac;
}
}
-#endif
/*
* 3) from flash or fuse (via platform data)
@@ -1666,16 +1664,6 @@ static int fec_enet_init(struct net_device *ndev)
}
#ifdef CONFIG_OF
-static int fec_get_phy_mode_dt(struct platform_device *pdev)
-{
- struct device_node *np = pdev->dev.of_node;
-
- if (np)
- return of_get_phy_mode(np);
-
- return -ENODEV;
-}
-
static void fec_reset_phy(struct platform_device *pdev)
{
int err, phy_reset;
@@ -1704,11 +1692,6 @@ static void fec_reset_phy(struct platform_device *pdev)
gpio_set_value(phy_reset, 1);
}
#else /* CONFIG_OF */
-static int fec_get_phy_mode_dt(struct platform_device *pdev)
-{
- return -ENODEV;
-}
-
static void fec_reset_phy(struct platform_device *pdev)
{
/*
@@ -1773,7 +1756,7 @@ fec_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, ndev);
- ret = fec_get_phy_mode_dt(pdev);
+ ret = of_get_phy_mode(pdev->dev.of_node);
if (ret < 0) {
pdata = pdev->dev.platform_data;
if (pdata)
--
1.7.9.7
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/5] net/nxp/lpc_eth: Drop ifdef CONFIG_OF_NET
[not found] ` <1364931311-30603-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
` (2 preceding siblings ...)
2013-04-02 19:35 ` [PATCH 4/5] net/freescale/fec: " Guenter Roeck
@ 2013-04-02 19:35 ` Guenter Roeck
3 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2013-04-02 19:35 UTC (permalink / raw)
To: David S. Miller, Nicolas Ferre, Grant Likely
Cc: David Daney, netdev-u79uwXL29TY76Z2rM5mHXA,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Guenter Roeck
Since of_get_mac_address() is now declared even if CONFIG_OF_NET
is not configured, the ifdef is no longer necessary and can be
removed.
Signed-off-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
---
drivers/net/ethernet/nxp/lpc_eth.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
index efa29b7..99276d7 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -1434,13 +1434,11 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
/* Get MAC address from current HW setting (POR state is all zeros) */
__lpc_get_mac(pldat, ndev->dev_addr);
-#ifdef CONFIG_OF_NET
if (!is_valid_ether_addr(ndev->dev_addr)) {
const char *macaddr = of_get_mac_address(pdev->dev.of_node);
if (macaddr)
memcpy(ndev->dev_addr, macaddr, ETH_ALEN);
}
-#endif
if (!is_valid_ether_addr(ndev->dev_addr))
eth_hw_addr_random(ndev);
--
1.7.9.7
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/5] Provide empty functions if OF_NET is not configured
2013-04-02 19:35 [PATCH 0/5] Provide empty functions if OF_NET is not configured Guenter Roeck
2013-04-02 19:35 ` [PATCH 2/5] net/cadence/at91_ether: Simplify OF dependencies Guenter Roeck
[not found] ` <1364931311-30603-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
@ 2013-04-02 20:44 ` David Miller
2 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2013-04-02 20:44 UTC (permalink / raw)
To: linux
Cc: nicolas.ferre, grant.likely, rob.herring, david.daney, netdev,
linux-kernel, devicetree-discuss
From: Guenter Roeck <linux@roeck-us.net>
Date: Tue, 2 Apr 2013 12:35:06 -0700
> Provide empty functions for of_get_phy_mode() and of_get_mac_address()
> if OF_NET is not configured. Modify affected drivers to rely on the
> now available functions.
All applied, but please post your patches against the appropriate
tree.
In net-next, fec.c has been renamed to fec_main.c so I had to adjust
your patch so that it would apply correctly.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-04-02 20:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-02 19:35 [PATCH 0/5] Provide empty functions if OF_NET is not configured Guenter Roeck
2013-04-02 19:35 ` [PATCH 2/5] net/cadence/at91_ether: Simplify OF dependencies Guenter Roeck
[not found] ` <1364931311-30603-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-04-02 19:35 ` [PATCH 1/5] of_net.h: Provide empty functions if OF_NET is not configured Guenter Roeck
2013-04-02 19:35 ` [PATCH 3/5] net/cadence/macb: Simplify OF dependencies Guenter Roeck
2013-04-02 19:35 ` [PATCH 4/5] net/freescale/fec: " Guenter Roeck
2013-04-02 19:35 ` [PATCH 5/5] net/nxp/lpc_eth: Drop ifdef CONFIG_OF_NET Guenter Roeck
2013-04-02 20:44 ` [PATCH 0/5] Provide empty functions if OF_NET is not configured David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).