[PATCH] net: ethernet: sun: remove redundant variables adv and lpa

Subsystems: networking drivers, the rest

STALE2965d

8 messages, 4 authors, 2018-07-05 · open the first message on its own page

[PATCH] net: ethernet: sun: remove redundant variables adv and lpa

From: Colin King <hidden>
Date: 2018-07-05 09:37:41

From: Colin Ian King <redacted>

Variables adv and lpa are being assigned but are never used hence they
are redundant and can be removed.

Cleans up clang warnings:
warning: variable 'lpa' set but not used [-Wunused-but-set-variable]
warning: variable 'adv' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <redacted>
---
 drivers/net/ethernet/sun/niu.c | 4 ----
 1 file changed, 4 deletions(-)
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
index 88c12474a0c3..2d6b62c6d9ab 100644
--- a/drivers/net/ethernet/sun/niu.c
+++ b/drivers/net/ethernet/sun/niu.c
@@ -1225,17 +1225,13 @@ static int link_status_1g_rgmii(struct niu *np, int *link_up_p)
 
 	bmsr = err;
 	if (bmsr & BMSR_LSTATUS) {
-		u16 adv, lpa;
-
 		err = mii_read(np, np->phy_addr, MII_ADVERTISE);
 		if (err < 0)
 			goto out;
-		adv = err;
 
 		err = mii_read(np, np->phy_addr, MII_LPA);
 		if (err < 0)
 			goto out;
-		lpa = err;
 
 		err = mii_read(np, np->phy_addr, MII_ESTATUS);
 		if (err < 0)
-- 
2.17.1

Re: [PATCH] net: ethernet: sun: remove redundant variables adv and lpa

From: Dan Carpenter <hidden>
Date: 2018-07-05 09:52:38

On Thu, Jul 05, 2018 at 10:37:32AM +0100, Colin King wrote:
quoted hunk
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
index 88c12474a0c3..2d6b62c6d9ab 100644
--- a/drivers/net/ethernet/sun/niu.c
+++ b/drivers/net/ethernet/sun/niu.c
@@ -1225,17 +1225,13 @@ static int link_status_1g_rgmii(struct niu *np, int *link_up_p)
 
 	bmsr = err;
 	if (bmsr & BMSR_LSTATUS) {
-		u16 adv, lpa;
-
 		err = mii_read(np, np->phy_addr, MII_ADVERTISE);
 		if (err < 0)
 			goto out;
-		adv = err;
 
 		err = mii_read(np, np->phy_addr, MII_LPA);
 		if (err < 0)
 			goto out;
-		lpa = err;
I'm fairly sure we could get rid of the mii_read() calls as well.

regards,
dan carpenter

Re: [PATCH] net: ethernet: sun: remove redundant variables adv and lpa

From: Colin Ian King <hidden>
Date: 2018-07-05 09:55:04

On 05/07/18 10:52, Dan Carpenter wrote:
On Thu, Jul 05, 2018 at 10:37:32AM +0100, Colin King wrote:
quoted
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
index 88c12474a0c3..2d6b62c6d9ab 100644
--- a/drivers/net/ethernet/sun/niu.c
+++ b/drivers/net/ethernet/sun/niu.c
@@ -1225,17 +1225,13 @@ static int link_status_1g_rgmii(struct niu *np, int *link_up_p)
 
 	bmsr = err;
 	if (bmsr & BMSR_LSTATUS) {
-		u16 adv, lpa;
-
 		err = mii_read(np, np->phy_addr, MII_ADVERTISE);
 		if (err < 0)
 			goto out;
-		adv = err;
 
 		err = mii_read(np, np->phy_addr, MII_LPA);
 		if (err < 0)
 			goto out;
-		lpa = err;
I'm fairly sure we could get rid of the mii_read() calls as well.
I'm always concerned that removing the reads of H/W registers can affect
the behavior, so I left those in.

Colin
regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Re: [PATCH] net: ethernet: sun: remove redundant variables adv and lpa

From: Dan Carpenter <hidden>
Date: 2018-07-05 10:01:45

On Thu, Jul 05, 2018 at 10:54:51AM +0100, Colin Ian King wrote:
On 05/07/18 10:52, Dan Carpenter wrote:
quoted
On Thu, Jul 05, 2018 at 10:37:32AM +0100, Colin King wrote:
quoted
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
index 88c12474a0c3..2d6b62c6d9ab 100644
--- a/drivers/net/ethernet/sun/niu.c
+++ b/drivers/net/ethernet/sun/niu.c
@@ -1225,17 +1225,13 @@ static int link_status_1g_rgmii(struct niu *np, int *link_up_p)
 
 	bmsr = err;
 	if (bmsr & BMSR_LSTATUS) {
-		u16 adv, lpa;
-
 		err = mii_read(np, np->phy_addr, MII_ADVERTISE);
 		if (err < 0)
 			goto out;
-		adv = err;
 
 		err = mii_read(np, np->phy_addr, MII_LPA);
 		if (err < 0)
 			goto out;
-		lpa = err;
I'm fairly sure we could get rid of the mii_read() calls as well.
I'm always concerned that removing the reads of H/W registers can affect
the behavior, so I left those in.
Yeah...  That's true sometimes.  Hence my "fairly sure" equivocation.  I
looked to see if any of the original devs are around and it's been a
while since anyone worked on this driver.

When we remove these warnings it means that there is no chance that
someone will look at the code again and remove the unneeded mii_read()
calls.  I'm 90% sure the reads are unnecessary.

regards,
dan carpenter

Re: [PATCH] net: ethernet: sun: remove redundant variables adv and lpa

From: David Miller <davem@davemloft.net>
Date: 2018-07-05 10:33:24

From: Colin King <redacted>
Date: Thu,  5 Jul 2018 10:37:32 +0100
From: Colin Ian King <redacted>

Variables adv and lpa are being assigned but are never used hence they
are redundant and can be removed.

Cleans up clang warnings:
warning: variable 'lpa' set but not used [-Wunused-but-set-variable]
warning: variable 'adv' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <redacted>
I think you can safely remove the register reads too, so please
do so.

Thanks.

Re: [PATCH] net: ethernet: sun: remove redundant variables adv and lpa

From: Colin Ian King <hidden>
Date: 2018-07-05 10:50:09

On 05/07/18 11:33, David Miller wrote:
From: Colin King <redacted>
Date: Thu,  5 Jul 2018 10:37:32 +0100
quoted
From: Colin Ian King <redacted>

Variables adv and lpa are being assigned but are never used hence they
are redundant and can be removed.

Cleans up clang warnings:
warning: variable 'lpa' set but not used [-Wunused-but-set-variable]
warning: variable 'adv' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <redacted>
I think you can safely remove the register reads too, so please
do so.
Just to clarify, just the MII_ADVERTISE and MII_LPA, or both these AND
also MII_ESTATUS too?
Thanks.

Re: [PATCH] net: ethernet: sun: remove redundant variables adv and lpa

From: David Miller <davem@davemloft.net>
Date: 2018-07-05 10:52:41

From: Colin Ian King <redacted>
Date: Thu, 5 Jul 2018 11:50:01 +0100
Just to clarify, just the MII_ADVERTISE and MII_LPA, or both these AND
also MII_ESTATUS too?
I think you can safely remove all three.

Re: [PATCH] net: ethernet: sun: remove redundant variables adv and lpa

From: Andrew Lunn <andrew@lunn.ch>
Date: 2018-07-05 13:54:09

On Thu, Jul 05, 2018 at 10:37:32AM +0100, Colin King wrote:
quoted hunk
From: Colin Ian King <redacted>

Variables adv and lpa are being assigned but are never used hence they
are redundant and can be removed.

Cleans up clang warnings:
warning: variable 'lpa' set but not used [-Wunused-but-set-variable]
warning: variable 'adv' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <redacted>
---
 drivers/net/ethernet/sun/niu.c | 4 ----
 1 file changed, 4 deletions(-)
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
index 88c12474a0c3..2d6b62c6d9ab 100644
--- a/drivers/net/ethernet/sun/niu.c
+++ b/drivers/net/ethernet/sun/niu.c
@@ -1225,17 +1225,13 @@ static int link_status_1g_rgmii(struct niu *np, int *link_up_p)
 
 	bmsr = err;
 	if (bmsr & BMSR_LSTATUS) {
-		u16 adv, lpa;
-
 		err = mii_read(np, np->phy_addr, MII_ADVERTISE);
 		if (err < 0)
 			goto out;
-		adv = err;
 
 		err = mii_read(np, np->phy_addr, MII_LPA);
 		if (err < 0)
 			goto out;
-		lpa = err;
 
 		err = mii_read(np, np->phy_addr, MII_ESTATUS);
 		if (err < 0)
What should really happen is something like:

                common_adv = lpa & adv;

                lp->active_speed = SPEED_10;
                lp->active_duplex = DUPLEX_HALF;

                if (common_adv_gb & (LPA_1000FULL | LPA_1000HALF)) {
                        lp->active_speed = SPEED_1000;

                        if (common_adv_gb & LPA_1000FULL)
                                lp->active_duplex = DUPLEX_FULL;
                } else if (common_adv & (LPA_100FULL | LPA_100HALF)) {
                        lp->active_speed = SPEED_100;

                        if (common_adv & LPA_100FULL)
                                lp->active_duplex = DUPLEX_FULL;
                } else
                        if (common_adv & LPA_10FULL)
                                lp->active_duplex = DUPLEX_FULL;

i.e. making use of the results of the autoneg to determine the link
speed and duplex, rather than just assuming it is 1G.

If i turn this into a real patch, does anybody have the hardware to
test it?

      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