[net-next] smsc911x: remove superfluous variable init

Message ID 20230321114721.20531-1-wsa+renesas@sang-engineering.com
State New
Headers
Series [net-next] smsc911x: remove superfluous variable init |

Commit Message

Wolfram Sang March 21, 2023, 11:47 a.m. UTC
  phydev is assigned a value right away, no need to initialize it.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/net/ethernet/smsc/smsc911x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Geert Uytterhoeven March 21, 2023, 2:27 p.m. UTC | #1
Hi Wolfram,

On Tue, Mar 21, 2023 at 12:50 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> phydev is assigned a value right away, no need to initialize it.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Thanks for your patch!

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

> --- a/drivers/net/ethernet/smsc/smsc911x.c
> +++ b/drivers/net/ethernet/smsc/smsc911x.c
> @@ -1016,7 +1016,7 @@ static void smsc911x_phy_adjust_link(struct net_device *dev)
>  static int smsc911x_mii_probe(struct net_device *dev)
>  {
>         struct smsc911x_data *pdata = netdev_priv(dev);
> -       struct phy_device *phydev = NULL;
> +       struct phy_device *phydev;
>         int ret;
>
>         phydev = phy_find_first(pdata->mii_bus);

Nit: perhaps combine this assignment with the variable declaration?

Gr{oetje,eeting}s,

                        Geert
  
Wolfram Sang March 21, 2023, 2:38 p.m. UTC | #2
> >         struct smsc911x_data *pdata = netdev_priv(dev);
> > -       struct phy_device *phydev = NULL;
> > +       struct phy_device *phydev;
> >         int ret;
> >
> >         phydev = phy_find_first(pdata->mii_bus);
> 
> Nit: perhaps combine this assignment with the variable declaration?

I thought about it but found this version to be easier readable.

Thanks!
  
Jakub Kicinski March 21, 2023, 7:27 p.m. UTC | #3
On Tue, 21 Mar 2023 15:38:31 +0100 Wolfram Sang wrote:
> > >         struct smsc911x_data *pdata = netdev_priv(dev);
> > > -       struct phy_device *phydev = NULL;
> > > +       struct phy_device *phydev;
> > >         int ret;
> > >
> > >         phydev = phy_find_first(pdata->mii_bus);  
> > 
> > Nit: perhaps combine this assignment with the variable declaration?  
> 
> I thought about it but found this version to be easier readable.

+1 

Calling functions which need their return value error-checked as part
of the variable declaration should be against the kernel coding style
IMHO.
  
Paolo Abeni March 22, 2023, 2:58 p.m. UTC | #4
On Tue, 2023-03-21 at 15:38 +0100, Wolfram Sang wrote:
> > >         struct smsc911x_data *pdata = netdev_priv(dev);
> > > -       struct phy_device *phydev = NULL;
> > > +       struct phy_device *phydev;
> > >         int ret;
> > > 
> > >         phydev = phy_find_first(pdata->mii_bus);
> > 
> > Nit: perhaps combine this assignment with the variable declaration?
> 
> I thought about it but found this version to be easier readable.

This patch does not apply cleanly to net-next, please rebase and
resping.

Thanks!

Paolo
  

Patch

diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index 25e867b74185..037a2b6b89d7 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -1016,7 +1016,7 @@  static void smsc911x_phy_adjust_link(struct net_device *dev)
 static int smsc911x_mii_probe(struct net_device *dev)
 {
 	struct smsc911x_data *pdata = netdev_priv(dev);
-	struct phy_device *phydev = NULL;
+	struct phy_device *phydev;
 	int ret;
 
 	phydev = phy_find_first(pdata->mii_bus);