linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] enetc: fix build warning
@ 2020-12-03 22:37 Arnd Bergmann
  2020-12-04 12:18 ` Claudiu Manoil
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2020-12-03 22:37 UTC (permalink / raw)
  To: Claudiu Manoil, David S. Miller, Jakub Kicinski, Russell King,
	Ioana Ciornei
  Cc: Arnd Bergmann, Michael Walle, Po Liu, netdev, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

When CONFIG_OF is disabled, there is a harmless warning about
an unused variable:

enetc_pf.c: In function 'enetc_phylink_create':
enetc_pf.c:981:17: error: unused variable 'dev' [-Werror=unused-variable]

Slightly rearrange the code to pass around the of_node as a
function argument, which avoids the problem without hurting
readability.

Fixes: 71b77a7a27a3 ("enetc: Migrate to PHYLINK and PCS_LYNX")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 .../net/ethernet/freescale/enetc/enetc_pf.c   | 21 +++++++++----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
index ecdc2af8c292..e1269ab4f2e4 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
@@ -851,13 +851,12 @@ static bool enetc_port_has_pcs(struct enetc_pf *pf)
 		pf->if_mode == PHY_INTERFACE_MODE_USXGMII);
 }
 
-static int enetc_mdiobus_create(struct enetc_pf *pf)
+static int enetc_mdiobus_create(struct enetc_pf *pf, struct device_node *node)
 {
-	struct device *dev = &pf->si->pdev->dev;
 	struct device_node *mdio_np;
 	int err;
 
-	mdio_np = of_get_child_by_name(dev->of_node, "mdio");
+	mdio_np = of_get_child_by_name(node, "mdio");
 	if (mdio_np) {
 		err = enetc_mdio_probe(pf, mdio_np);
 
@@ -969,18 +968,17 @@ static const struct phylink_mac_ops enetc_mac_phylink_ops = {
 	.mac_link_down = enetc_pl_mac_link_down,
 };
 
-static int enetc_phylink_create(struct enetc_ndev_priv *priv)
+static int enetc_phylink_create(struct enetc_ndev_priv *priv,
+				struct device_node *node)
 {
 	struct enetc_pf *pf = enetc_si_priv(priv->si);
-	struct device *dev = &pf->si->pdev->dev;
 	struct phylink *phylink;
 	int err;
 
 	pf->phylink_config.dev = &priv->ndev->dev;
 	pf->phylink_config.type = PHYLINK_NETDEV;
 
-	phylink = phylink_create(&pf->phylink_config,
-				 of_fwnode_handle(dev->of_node),
+	phylink = phylink_create(&pf->phylink_config, of_fwnode_handle(node),
 				 pf->if_mode, &enetc_mac_phylink_ops);
 	if (IS_ERR(phylink)) {
 		err = PTR_ERR(phylink);
@@ -1005,9 +1003,10 @@ static int enetc_pf_probe(struct pci_dev *pdev,
 	struct net_device *ndev;
 	struct enetc_si *si;
 	struct enetc_pf *pf;
+	struct device_node *node = pdev->dev.of_node;
 	int err;
 
-	if (pdev->dev.of_node && !of_device_is_available(pdev->dev.of_node)) {
+	if (node && !of_device_is_available(node)) {
 		dev_info(&pdev->dev, "device is disabled, skipping\n");
 		return -ENODEV;
 	}
@@ -1058,12 +1057,12 @@ static int enetc_pf_probe(struct pci_dev *pdev,
 		goto err_alloc_msix;
 	}
 
-	if (!of_get_phy_mode(pdev->dev.of_node, &pf->if_mode)) {
-		err = enetc_mdiobus_create(pf);
+	if (!of_get_phy_mode(node, &pf->if_mode)) {
+		err = enetc_mdiobus_create(pf, node);
 		if (err)
 			goto err_mdiobus_create;
 
-		err = enetc_phylink_create(priv);
+		err = enetc_phylink_create(priv, node);
 		if (err)
 			goto err_phylink_create;
 	}
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] enetc: fix build warning
  2020-12-03 22:37 [PATCH] enetc: fix build warning Arnd Bergmann
@ 2020-12-04 12:18 ` Claudiu Manoil
  2020-12-04 16:51   ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Claudiu Manoil @ 2020-12-04 12:18 UTC (permalink / raw)
  To: Arnd Bergmann, David S. Miller, Jakub Kicinski, Russell King,
	Ioana Ciornei
  Cc: Arnd Bergmann, Michael Walle, Po Liu, netdev, linux-kernel

>-----Original Message-----
>From: Arnd Bergmann <arnd@kernel.org>
>Sent: Friday, December 4, 2020 12:37 AM
[...]
>Subject: [PATCH] enetc: fix build warning
>
>From: Arnd Bergmann <arnd@arndb.de>
>
>When CONFIG_OF is disabled, there is a harmless warning about
>an unused variable:
>
>enetc_pf.c: In function 'enetc_phylink_create':
>enetc_pf.c:981:17: error: unused variable 'dev' [-Werror=unused-variable]
>
>Slightly rearrange the code to pass around the of_node as a
>function argument, which avoids the problem without hurting
>readability.
>
>Fixes: 71b77a7a27a3 ("enetc: Migrate to PHYLINK and PCS_LYNX")
>Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Very nice cleanup, the code looks much better like this.
For some reason this patch is marked as "Not applicable" in patchwork.
So I took the patch, made a small cosmetic change (see nit below), added a more
verbose subject line, tested and resent it, patchwork link here:
https://patchwork.ozlabs.org/project/netdev/patch/20201204120800.17193-1-claudiu.manoil@nxp.com/

Thanks.

>---
> .../net/ethernet/freescale/enetc/enetc_pf.c   | 21 +++++++++----------
>@@ -1005,9 +1003,10 @@ static int enetc_pf_probe(struct pci_dev *pdev,
> 	struct net_device *ndev;
> 	struct enetc_si *si;
> 	struct enetc_pf *pf;
>+	struct device_node *node = pdev->dev.of_node;

Nit: move this long line to the top (reverse tree)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] enetc: fix build warning
  2020-12-04 12:18 ` Claudiu Manoil
@ 2020-12-04 16:51   ` Jakub Kicinski
  0 siblings, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2020-12-04 16:51 UTC (permalink / raw)
  To: Claudiu Manoil
  Cc: Arnd Bergmann, David S. Miller, Russell King, Ioana Ciornei,
	Arnd Bergmann, Michael Walle, Po Liu, netdev, linux-kernel

On Fri, 4 Dec 2020 12:18:16 +0000 Claudiu Manoil wrote:
> >-----Original Message-----
> >From: Arnd Bergmann <arnd@kernel.org>
> >Sent: Friday, December 4, 2020 12:37 AM  
> [...]
> >Subject: [PATCH] enetc: fix build warning
> >
> >From: Arnd Bergmann <arnd@arndb.de>
> >
> >When CONFIG_OF is disabled, there is a harmless warning about
> >an unused variable:
> >
> >enetc_pf.c: In function 'enetc_phylink_create':
> >enetc_pf.c:981:17: error: unused variable 'dev' [-Werror=unused-variable]
> >
> >Slightly rearrange the code to pass around the of_node as a
> >function argument, which avoids the problem without hurting
> >readability.
> >
> >Fixes: 71b77a7a27a3 ("enetc: Migrate to PHYLINK and PCS_LYNX")
> >Signed-off-by: Arnd Bergmann <arnd@arndb.de>  
> 
> Very nice cleanup, the code looks much better like this.
> For some reason this patch is marked as "Not applicable" in patchwork.
> So I took the patch, made a small cosmetic change (see nit below), added a more
> verbose subject line, tested and resent it, patchwork link here:
> https://patchwork.ozlabs.org/project/netdev/patch/20201204120800.17193-1-claudiu.manoil@nxp.com/

We switched to a different PW instance:

https://patchwork.kernel.org/project/netdevbpf/patch/20201203223747.1337389-1-arnd@kernel.org/

> >---
> > .../net/ethernet/freescale/enetc/enetc_pf.c   | 21 +++++++++----------
> >@@ -1005,9 +1003,10 @@ static int enetc_pf_probe(struct pci_dev *pdev,
> > 	struct net_device *ndev;
> > 	struct enetc_si *si;
> > 	struct enetc_pf *pf;
> >+	struct device_node *node = pdev->dev.of_node;  
> 
> Nit: move this long line to the top (reverse tree)

Now it's gonna get marked as changes requested ;)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-04 16:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 22:37 [PATCH] enetc: fix build warning Arnd Bergmann
2020-12-04 12:18 ` Claudiu Manoil
2020-12-04 16:51   ` Jakub Kicinski

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).