[PATCH] net: phy: Simplify the return expression of dp83640_ack_interrupt

Subsystems: ethernet phy library, networking drivers, ptp hardware clock support, the rest

STALE1891d

3 messages, 3 authors, 2021-06-04 · open the first message on its own page

[PATCH] net: phy: Simplify the return expression of dp83640_ack_interrupt

From: <hidden>
Date: 2021-06-04 03:23:45

From: dingsenjie <redacted>

Simplify the return expression.

Signed-off-by: dingsenjie <redacted>
---
 drivers/net/phy/dp83640.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index 0d79f68..bcd14ec 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -1141,12 +1141,7 @@ static int dp83640_config_init(struct phy_device *phydev)
 
 static int dp83640_ack_interrupt(struct phy_device *phydev)
 {
-	int err = phy_read(phydev, MII_DP83640_MISR);
-
-	if (err < 0)
-		return err;
-
-	return 0;
+	return phy_read(phydev, MII_DP83640_MISR);
 }
 
 static int dp83640_config_intr(struct phy_device *phydev)
-- 
1.9.1

Re: [PATCH] net: phy: Simplify the return expression of dp83640_ack_interrupt

From: Heiner Kallweit <hkallweit1@gmail.com>
Date: 2021-06-04 07:49:47

On 04.06.2021 05:22, dingsenjie@163.com wrote:
quoted hunk
From: dingsenjie <redacted>

Simplify the return expression.

Signed-off-by: dingsenjie <redacted>
---
 drivers/net/phy/dp83640.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index 0d79f68..bcd14ec 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -1141,12 +1141,7 @@ static int dp83640_config_init(struct phy_device *phydev)
 
 static int dp83640_ack_interrupt(struct phy_device *phydev)
 {
-	int err = phy_read(phydev, MII_DP83640_MISR);
-
-	if (err < 0)
-		return err;
-
-	return 0;
+	return phy_read(phydev, MII_DP83640_MISR);
 }
 
 static int dp83640_config_intr(struct phy_device *phydev)
This would be a functional change. You'd return a positive value
instead of 0.

Re: [PATCH] net: phy: Simplify the return expression of dp83640_ack_interrupt

From: Andrew Lunn <andrew@lunn.ch>
Date: 2021-06-04 23:02:39

On Fri, Jun 04, 2021 at 09:49:17AM +0200, Heiner Kallweit wrote:
On 04.06.2021 05:22, dingsenjie@163.com wrote:
quoted
From: dingsenjie <redacted>

Simplify the return expression.

Signed-off-by: dingsenjie <redacted>
---
 drivers/net/phy/dp83640.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index 0d79f68..bcd14ec 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -1141,12 +1141,7 @@ static int dp83640_config_init(struct phy_device *phydev)
 
 static int dp83640_ack_interrupt(struct phy_device *phydev)
 {
-	int err = phy_read(phydev, MII_DP83640_MISR);
-
-	if (err < 0)
-		return err;
-
-	return 0;
+	return phy_read(phydev, MII_DP83640_MISR);
 }
 
 static int dp83640_config_intr(struct phy_device *phydev)
This would be a functional change. You'd return a positive value
instead of 0.
And looking a bit further down in the code:

static int dp83640_ack_interrupt(struct phy_device *phydev)
{
        int err = phy_read(phydev, MII_DP83640_MISR);

        if (err < 0)
                return err;

        return 0;
}

static int dp83640_config_intr(struct phy_device *phydev)
{
        int micr;
        int misr;
        int err;

        if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
                err = dp83640_ack_interrupt(phydev);
                if (err)
                        return err;

So a positive value is going to break the driver.

NACK

	Andrew
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help