Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1649186 > unrolled thread
| Started by | Corentin Labbe <clabbe.montjoie@gmail.com> |
|---|---|
| First post | 2017-05-24 09:30 +0200 |
| Last post | 2017-05-24 09:30 +0200 |
| Articles | 4 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH v3 0/5] net-next: stmmac: rework the speed selection Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-05-24 09:30 +0200
[PATCH v3 1/5] net-next: stmmac: Convert new_state to bool Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-05-24 09:30 +0200
[PATCH v3 3/5] net-next: stmmac: use SPEED_xxx instead of raw value Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-05-24 09:30 +0200
[PATCH v3 4/5] net-next: stmmac: Convert old_link to bool Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-05-24 09:30 +0200
| From | Corentin Labbe <clabbe.montjoie@gmail.com> |
|---|---|
| Date | 2017-05-24 09:30 +0200 |
| Subject | [PATCH v3 0/5] net-next: stmmac: rework the speed selection |
| Message-ID | <tKyU2-7Df-7@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 4 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 v3: - Added the patch #4 "Convert old_link to bool" as suggested by Joe Perches - Changed the speedmask Changes since v2: - Use true/false for new_state in patch #1 Corentin Labbe (5): net: stmmac: Convert new_state to bool net: stmmac: Remove unnecessary parenthesis net: stmmac: use SPEED_xxx instead of raw value net: stmmac: Convert old_link to bool 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.h | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 47 ++++++++-------------- 6 files changed, 57 insertions(+), 58 deletions(-) -- 2.13.0
[toc] | [next] | [standalone]
| From | Corentin Labbe <clabbe.montjoie@gmail.com> |
|---|---|
| Date | 2017-05-24 09:30 +0200 |
| Subject | [PATCH v3 1/5] net-next: stmmac: Convert new_state to bool |
| Message-ID | <tKyU2-7Df-15@gated-at.bofh.it> |
| In reply to | #1649186 |
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 b77a56b6ab70..9579592b6b6f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -786,7 +786,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;
@@ -799,7 +799,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
@@ -811,7 +811,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 ||
@@ -850,11 +850,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]
| From | Corentin Labbe <clabbe.montjoie@gmail.com> |
|---|---|
| Date | 2017-05-24 09:30 +0200 |
| Subject | [PATCH v3 3/5] net-next: stmmac: use SPEED_xxx instead of raw value |
| Message-ID | <tKyU2-7Df-19@gated-at.bofh.it> |
| In reply to | #1649186 |
Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 1fb46c124ab1..5643a5c916b6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -813,12 +813,12 @@ static void stmmac_adjust_link(struct net_device *dev)
if (phydev->speed != priv->speed) {
new_state = true;
switch (phydev->speed) {
- case 1000:
+ case SPEED_1000:
if (priv->plat->has_gmac ||
priv->plat->has_gmac4)
ctrl &= ~priv->hw->link.port;
break;
- case 100:
+ case SPEED_100:
if (priv->plat->has_gmac ||
priv->plat->has_gmac4) {
ctrl |= priv->hw->link.port;
@@ -827,7 +827,7 @@ static void stmmac_adjust_link(struct net_device *dev)
ctrl &= ~priv->hw->link.port;
}
break;
- case 10:
+ case SPEED_10:
if (priv->plat->has_gmac ||
priv->plat->has_gmac4) {
ctrl |= priv->hw->link.port;
--
2.13.0
[toc] | [prev] | [next] | [standalone]
| From | Corentin Labbe <clabbe.montjoie@gmail.com> |
|---|---|
| Date | 2017-05-24 09:30 +0200 |
| Subject | [PATCH v3 4/5] net-next: stmmac: Convert old_link to bool |
| Message-ID | <tKyU2-7Df-23@gated-at.bofh.it> |
| In reply to | #1649186 |
This patch convert old_link 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.h | 2 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index 33efe7038cab..a916e13624eb 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -104,7 +104,7 @@ struct stmmac_priv {
/* TX Queue */
struct stmmac_tx_queue tx_queue[MTL_MAX_TX_QUEUES];
- int oldlink;
+ bool oldlink;
int speed;
int oldduplex;
unsigned int flow_ctrl;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 5643a5c916b6..4bd83a29cbd5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -851,11 +851,11 @@ static void stmmac_adjust_link(struct net_device *dev)
if (!priv->oldlink) {
new_state = true;
- priv->oldlink = 1;
+ priv->oldlink = true;
}
} else if (priv->oldlink) {
new_state = true;
- priv->oldlink = 0;
+ priv->oldlink = false;
priv->speed = SPEED_UNKNOWN;
priv->oldduplex = DUPLEX_UNKNOWN;
}
@@ -918,7 +918,7 @@ static int stmmac_init_phy(struct net_device *dev)
char bus_id[MII_BUS_ID_SIZE];
int interface = priv->plat->interface;
int max_speed = priv->plat->max_speed;
- priv->oldlink = 0;
+ priv->oldlink = false;
priv->speed = SPEED_UNKNOWN;
priv->oldduplex = DUPLEX_UNKNOWN;
@@ -4308,7 +4308,7 @@ int stmmac_suspend(struct device *dev)
}
spin_unlock_irqrestore(&priv->lock, flags);
- priv->oldlink = 0;
+ priv->oldlink = false;
priv->speed = SPEED_UNKNOWN;
priv->oldduplex = DUPLEX_UNKNOWN;
return 0;
--
2.13.0
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web