Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1646835 > unrolled thread

[PATCH v2 0/4] net-next: stmmac: rework the speed selection

Started byCorentin Labbe <clabbe.montjoie@gmail.com>
First post2017-05-22 14:40 +0200
Last post2017-05-22 15:10 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2 0/4] net-next: stmmac: rework the speed selection Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-05-22 14:40 +0200
    [PATCH v2 2/4] net-next: stmmac: Remove unnecessary parenthesis Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-05-22 14:40 +0200
    [PATCH v2 1/4] net-next: stmmac: Convert new_state to bool Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-05-22 14:40 +0200
      Re: [PATCH v2 1/4] net-next: stmmac: Convert new_state to bool Joe Perches <joe@perches.com> - 2017-05-22 15:10 +0200

#1646835 — [PATCH v2 0/4] net-next: stmmac: rework the speed selection

FromCorentin Labbe <clabbe.montjoie@gmail.com>
Date2017-05-22 14:40 +0200
Subject[PATCH v2 0/4] net-next: stmmac: rework the speed selection
Message-ID<tJUMV-5Hr-3@gated-at.bofh.it>
Hello

The current stmmac_adjust_link() part which handle speed have
some if (has_platform) code and my dwmac-sun8i will add more of them.

So we need to handle better speed selection.
Moreover the struct link member speed and port are hard to guess their
purpose. And their unique usage are to be combined for writing speed.

My first try was to create an adjust_link() in stmmac_ops but it duplicate some code

The current solution is to have direct value for 10/100/1000 and a mask for them.

The first 3 patchs fix some minor problem found in stmmac_adjust_link() and reported by Florian Fainelli in my previous serie.
The last patch is the real work.

This serie is tested on cubieboard2 (dwmac1000) and opipc (dwmac-sun8i).

Regards

Changes since v2:
- use true/false for new_state in patch #1

Corentin Labbe (4):
  net: stmmac: Convert new_state to bool
  net: stmmac: Remove unnecessary parenthesis
  net: stmmac: use SPEED_xxx instead of raw value
  net: stmmac: rework the speed selection

 drivers/net/ethernet/stmicro/stmmac/common.h       |  8 +++---
 .../net/ethernet/stmicro/stmmac/dwmac1000_core.c   | 26 ++++++++++--------
 .../net/ethernet/stmicro/stmmac/dwmac100_core.c    |  6 +++--
 drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c  | 26 ++++++++++--------
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  | 31 +++++++---------------
 5 files changed, 48 insertions(+), 49 deletions(-)

-- 
2.13.0

[toc] | [next] | [standalone]


#1646840 — [PATCH v2 2/4] net-next: stmmac: Remove unnecessary parenthesis

FromCorentin Labbe <clabbe.montjoie@gmail.com>
Date2017-05-22 14:40 +0200
Subject[PATCH v2 2/4] net-next: stmmac: Remove unnecessary parenthesis
Message-ID<tJUMW-5Hr-21@gated-at.bofh.it>
In reply to#1646835
Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 94b37323844b..190686e39835 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -799,7 +799,7 @@ static void stmmac_adjust_link(struct net_device *dev)
 		 * If not, we operate in half-duplex mode. */
 		if (phydev->duplex != priv->oldduplex) {
 			new_state = true;
-			if (!(phydev->duplex))
+			if (!phydev->duplex)
 				ctrl &= ~priv->hw->link.duplex;
 			else
 				ctrl |= priv->hw->link.duplex;
-- 
2.13.0

[toc] | [prev] | [next] | [standalone]


#1646841 — [PATCH v2 1/4] net-next: stmmac: Convert new_state to bool

FromCorentin Labbe <clabbe.montjoie@gmail.com>
Date2017-05-22 14:40 +0200
Subject[PATCH v2 1/4] net-next: stmmac: Convert new_state to bool
Message-ID<tJUMW-5Hr-25@gated-at.bofh.it>
In reply to#1646835
This patch convert new_state from int to bool since it store only 1 or 0

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 1da17cd519f6..94b37323844b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -785,7 +785,7 @@ static void stmmac_adjust_link(struct net_device *dev)
 	struct stmmac_priv *priv = netdev_priv(dev);
 	struct phy_device *phydev = dev->phydev;
 	unsigned long flags;
-	int new_state = 0;
+	bool new_state = false;
 
 	if (!phydev)
 		return;
@@ -798,7 +798,7 @@ static void stmmac_adjust_link(struct net_device *dev)
 		/* Now we make sure that we can be in full duplex mode.
 		 * If not, we operate in half-duplex mode. */
 		if (phydev->duplex != priv->oldduplex) {
-			new_state = 1;
+			new_state = true;
 			if (!(phydev->duplex))
 				ctrl &= ~priv->hw->link.duplex;
 			else
@@ -810,7 +810,7 @@ static void stmmac_adjust_link(struct net_device *dev)
 			stmmac_mac_flow_ctrl(priv, phydev->duplex);
 
 		if (phydev->speed != priv->speed) {
-			new_state = 1;
+			new_state = true;
 			switch (phydev->speed) {
 			case 1000:
 				if (priv->plat->has_gmac ||
@@ -849,11 +849,11 @@ static void stmmac_adjust_link(struct net_device *dev)
 		writel(ctrl, priv->ioaddr + MAC_CTRL_REG);
 
 		if (!priv->oldlink) {
-			new_state = 1;
+			new_state = true;
 			priv->oldlink = 1;
 		}
 	} else if (priv->oldlink) {
-		new_state = 1;
+		new_state = true;
 		priv->oldlink = 0;
 		priv->speed = SPEED_UNKNOWN;
 		priv->oldduplex = DUPLEX_UNKNOWN;
-- 
2.13.0

[toc] | [prev] | [next] | [standalone]


#1646863 — Re: [PATCH v2 1/4] net-next: stmmac: Convert new_state to bool

FromJoe Perches <joe@perches.com>
Date2017-05-22 15:10 +0200
SubjectRe: [PATCH v2 1/4] net-next: stmmac: Convert new_state to bool
Message-ID<tJVfX-68S-15@gated-at.bofh.it>
In reply to#1646841
On Mon, 2017-05-22 at 14:33 +0200, Corentin Labbe wrote:
> This patch convert new_state from int to bool since it store only 1 or 0
[]
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
[]
> @@ -849,11 +849,11 @@ static void stmmac_adjust_link(struct net_device *dev)
>  		writel(ctrl, priv->ioaddr + MAC_CTRL_REG);
>  
>  		if (!priv->oldlink) {
> -			new_state = 1;
> +			new_state = true;
>  			priv->oldlink = 1;
>  		}
>  	} else if (priv->oldlink) {
> -		new_state = 1;
> +		new_state = true;
>  		priv->oldlink = 0;
>  		priv->speed = SPEED_UNKNOWN;
>  		priv->oldduplex = DUPLEX_UNKNOWN;

It seems oldlink could be bool as well.

drivers/net/ethernet/stmicro/stmmac/stmmac.h:   int oldlink;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:              if (!priv->oldlink) {
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:                      priv->oldlink = 1;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:      } else if (priv->oldlink) {
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:              priv->oldlink = 0;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:      priv->oldlink = 0;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:      priv->oldlink = 0;

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web