[PATCH] ldpaa_eth.c: Fix warning when PHYLIB is not enabled

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] ldpaa_eth.c: Fix warning when PHYLIB is not enabled

Tom Rini-4
We need to #ifdef some variables to avoid warning about them being
unused.

Fixes: 1a048cd65645 ("driver: net: fsl-mc: Add support of multiple phys for dpmac")
Signed-off-by: Tom Rini <[hidden email]>
---
 drivers/net/ldpaa_eth/ldpaa_eth.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c b/drivers/net/ldpaa_eth/ldpaa_eth.c
index fe1c03e9e436..73b7ba29dfdc 100644
--- a/drivers/net/ldpaa_eth/ldpaa_eth.c
+++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
@@ -402,10 +402,12 @@ error:
 static int ldpaa_get_dpmac_state(struct ldpaa_eth_priv *priv,
  struct dpmac_link_state *state)
 {
- struct phy_device *phydev = NULL;
  phy_interface_t enet_if;
- int phy_num, phys_detected;
- int err;
+ int phys_detected;
+#ifdef CONFIG_PHYLIB
+ struct phy_device *phydev = NULL;
+ int err, phy_num;
+#endif
 
  /* let's start off with maximum capabilities */
  enet_if = wriop_get_enet_if(priv->dpmac_id);
@@ -590,8 +592,10 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)
 {
  struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv;
  int err = 0;
+#ifdef CONFIG_PHYLIB
  struct phy_device *phydev = NULL;
  int phy_num;
+#endif
 
  if ((net_dev->state == ETH_STATE_PASSIVE) ||
     (net_dev->state == ETH_STATE_INIT))
--
2.7.4

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ldpaa_eth.c: Fix warning when PHYLIB is not enabled

Philipp Tomsich


> On 12.10.2018, at 16:34, Tom Rini <[hidden email]> wrote:
>
> We need to #ifdef some variables to avoid warning about them being
> unused.
>
> Fixes: 1a048cd65645 ("driver: net: fsl-mc: Add support of multiple phys for dpmac")
> Signed-off-by: Tom Rini <[hidden email]>
> ---
> drivers/net/ldpaa_eth/ldpaa_eth.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c b/drivers/net/ldpaa_eth/ldpaa_eth.c
> index fe1c03e9e436..73b7ba29dfdc 100644
> --- a/drivers/net/ldpaa_eth/ldpaa_eth.c
> +++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
> @@ -402,10 +402,12 @@ error:
> static int ldpaa_get_dpmac_state(struct ldpaa_eth_priv *priv,
> struct dpmac_link_state *state)
> {
> - struct phy_device *phydev = NULL;
> phy_interface_t enet_if;
> - int phy_num, phys_detected;
> - int err;
> + int phys_detected;
> +#ifdef CONFIG_PHYLIB
> + struct phy_device *phydev = NULL;
> + int err, phy_num;
> +#endif

Reading this, I started to wonder whether we want to use __maybe_unused to
suppress these warnings w/o having to add these #if defined(…) blocks?

The drawback is that GCC won’t warn about lingering unused variables is a
‘maybe’ unused becomes a permanently unused variable...

>
> /* let's start off with maximum capabilities */
> enet_if = wriop_get_enet_if(priv->dpmac_id);
> @@ -590,8 +592,10 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)
> {
> struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv;
> int err = 0;
> +#ifdef CONFIG_PHYLIB
> struct phy_device *phydev = NULL;
> int phy_num;
> +#endif
>
> if ((net_dev->state == ETH_STATE_PASSIVE) ||
>    (net_dev->state == ETH_STATE_INIT))
> --
> 2.7.4
>
> _______________________________________________
> U-Boot mailing list
> [hidden email]
> https://lists.denx.de/listinfo/u-boot

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ldpaa_eth.c: Fix warning when PHYLIB is not enabled

Tom Rini-4
In reply to this post by Tom Rini-4
On Fri, Oct 12, 2018 at 10:34:50AM -0400, Tom Rini wrote:

> We need to #ifdef some variables to avoid warning about them being
> unused.
>
> Fixes: 1a048cd65645 ("driver: net: fsl-mc: Add support of multiple phys for dpmac")
> Signed-off-by: Tom Rini <[hidden email]>

Applied to u-boot/master, thanks!

--
Tom

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ldpaa_eth.c: Fix warning when PHYLIB is not enabled

Tom Rini-4
In reply to this post by Philipp Tomsich
On Fri, Oct 12, 2018 at 04:58:17PM +0200, Philipp Tomsich wrote:
 

> > On 12.10.2018, at 16:34, Tom Rini <[hidden email]> wrote:
> >
> > We need to #ifdef some variables to avoid warning about them being
> > unused.
> >
> > Fixes: 1a048cd65645 ("driver: net: fsl-mc: Add support of multiple phys for dpmac")
> > Signed-off-by: Tom Rini <[hidden email]>
> > ---
> > drivers/net/ldpaa_eth/ldpaa_eth.c | 10 +++++++---
> > 1 file changed, 7 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c b/drivers/net/ldpaa_eth/ldpaa_eth.c
> > index fe1c03e9e436..73b7ba29dfdc 100644
> > --- a/drivers/net/ldpaa_eth/ldpaa_eth.c
> > +++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
> > @@ -402,10 +402,12 @@ error:
> > static int ldpaa_get_dpmac_state(struct ldpaa_eth_priv *priv,
> > struct dpmac_link_state *state)
> > {
> > - struct phy_device *phydev = NULL;
> > phy_interface_t enet_if;
> > - int phy_num, phys_detected;
> > - int err;
> > + int phys_detected;
> > +#ifdef CONFIG_PHYLIB
> > + struct phy_device *phydev = NULL;
> > + int err, phy_num;
> > +#endif
>
> Reading this, I started to wonder whether we want to use __maybe_unused to
> suppress these warnings w/o having to add these #if defined(…) blocks?
>
> The drawback is that GCC won’t warn about lingering unused variables is a
> ‘maybe’ unused becomes a permanently unused variable...
Yeah, I'm not sure sometimes if __maybe_unused is cleaner looking or
not.  I think it depends on the number of things that are or aren't
needing to get blocked off.

--
Tom

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot

signature.asc (836 bytes) Download Attachment