Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] net: mdio: Remove redundant parameter and check
@ 2020-09-23 10:05 Tang Bin
  2020-09-23 10:10 ` Heiner Kallweit
  2020-09-24  1:10 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Tang Bin @ 2020-09-23 10:05 UTC (permalink / raw)
  To: davem, andrew, hkallweit1, kuba
  Cc: netdev, linux-kernel, Tang Bin, Zhang Shengju

In the function ipq8064_mdio_probe(), of_mdiobus_register() might
returned zero, so the direct return can simplify code. Thus remove
redundant parameter and check.

Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
---
 drivers/net/mdio/mdio-ipq8064.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/net/mdio/mdio-ipq8064.c b/drivers/net/mdio/mdio-ipq8064.c
index 1bd1885..33cccce 100644
--- a/drivers/net/mdio/mdio-ipq8064.c
+++ b/drivers/net/mdio/mdio-ipq8064.c
@@ -102,7 +102,6 @@ ipq8064_mdio_probe(struct platform_device *pdev)
 	struct device_node *np = pdev->dev.of_node;
 	struct ipq8064_mdio *priv;
 	struct mii_bus *bus;
-	int ret;
 
 	bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*priv));
 	if (!bus)
@@ -125,12 +124,9 @@ ipq8064_mdio_probe(struct platform_device *pdev)
 		return PTR_ERR(priv->base);
 	}
 
-	ret = of_mdiobus_register(bus, np);
-	if (ret)
-		return ret;
-
 	platform_set_drvdata(pdev, bus);
-	return 0;
+
+	return of_mdiobus_register(bus, np);
 }
 
 static int
-- 
2.20.1.windows.1




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

* Re: [PATCH] net: mdio: Remove redundant parameter and check
  2020-09-23 10:05 [PATCH] net: mdio: Remove redundant parameter and check Tang Bin
@ 2020-09-23 10:10 ` Heiner Kallweit
  2020-09-24  1:10 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Heiner Kallweit @ 2020-09-23 10:10 UTC (permalink / raw)
  To: Tang Bin, davem, andrew, kuba; +Cc: netdev, linux-kernel, Zhang Shengju

On 23.09.2020 12:05, Tang Bin wrote:
> In the function ipq8064_mdio_probe(), of_mdiobus_register() might
> returned zero, so the direct return can simplify code. Thus remove
> redundant parameter and check.
> 
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
> ---
>  drivers/net/mdio/mdio-ipq8064.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/mdio/mdio-ipq8064.c b/drivers/net/mdio/mdio-ipq8064.c
> index 1bd1885..33cccce 100644
> --- a/drivers/net/mdio/mdio-ipq8064.c
> +++ b/drivers/net/mdio/mdio-ipq8064.c
> @@ -102,7 +102,6 @@ ipq8064_mdio_probe(struct platform_device *pdev)
>  	struct device_node *np = pdev->dev.of_node;
>  	struct ipq8064_mdio *priv;
>  	struct mii_bus *bus;
> -	int ret;
>  
>  	bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*priv));
>  	if (!bus)
> @@ -125,12 +124,9 @@ ipq8064_mdio_probe(struct platform_device *pdev)
>  		return PTR_ERR(priv->base);
>  	}
>  
> -	ret = of_mdiobus_register(bus, np);
> -	if (ret)
> -		return ret;
> -
>  	platform_set_drvdata(pdev, bus);

Before your patch this is called only after of_mdiobus_register()
returns successfully. Now it's called unconditionally before.
Are you sure this can't have a side effect?

> -	return 0;
> +
> +	return of_mdiobus_register(bus, np);
>  }
>  
>  static int
> 


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

* Re: [PATCH] net: mdio: Remove redundant parameter and check
  2020-09-23 10:05 [PATCH] net: mdio: Remove redundant parameter and check Tang Bin
  2020-09-23 10:10 ` Heiner Kallweit
@ 2020-09-24  1:10 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2020-09-24  1:10 UTC (permalink / raw)
  To: tangbin; +Cc: andrew, hkallweit1, kuba, netdev, linux-kernel, zhangshengju

From: Tang Bin <tangbin@cmss.chinamobile.com>
Date: Wed, 23 Sep 2020 18:05:32 +0800

> @@ -125,12 +124,9 @@ ipq8064_mdio_probe(struct platform_device *pdev)
>  		return PTR_ERR(priv->base);
>  	}
>  
> -	ret = of_mdiobus_register(bus, np);
> -	if (ret)
> -		return ret;
> -
>  	platform_set_drvdata(pdev, bus);
> -	return 0;
> +
> +	return of_mdiobus_register(bus, np);
>  }

You are changing the code rather than simplifying the return sequence.

The author of this code intended the platform_set_drvdata() to only
happen if all operations of this function succeeded.

I am not applying this patch, sorry.

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

end of thread, other threads:[~2020-09-24  1:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-23 10:05 [PATCH] net: mdio: Remove redundant parameter and check Tang Bin
2020-09-23 10:10 ` Heiner Kallweit
2020-09-24  1:10 ` 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).