Skip to content

Commit 70f23a8

Browse files
committed
Merge branch 'ethoc-next'
Florian Fainelli says: ==================== net: ethoc: Misc improvements This patch series fixes/improves a few things: - implement a proper PHYLIB adjust_link callback to set the duplex mode accordingly - do not open code the fetching of a MAC address in OF/DT environments - demote an error message that occurs more frequently than expected in low CPU/memory/bandwidth environments Tested on a Cirrus Logic EP93xx / TS7300 board. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 1c0d32f + 38b4bc2 commit 70f23a8

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

drivers/net/ethernet/ethoc.c

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/sched.h>
2424
#include <linux/slab.h>
2525
#include <linux/of.h>
26+
#include <linux/of_net.h>
2627
#include <linux/module.h>
2728
#include <net/ethoc.h>
2829

@@ -221,6 +222,9 @@ struct ethoc {
221222
struct mii_bus *mdio;
222223
struct clk *clk;
223224
s8 phy_id;
225+
226+
int old_link;
227+
int old_duplex;
224228
};
225229

226230
/**
@@ -572,7 +576,7 @@ static irqreturn_t ethoc_interrupt(int irq, void *dev_id)
572576

573577
/* We always handle the dropped packet interrupt */
574578
if (pending & INT_MASK_BUSY) {
575-
dev_err(&dev->dev, "packet dropped\n");
579+
dev_dbg(&dev->dev, "packet dropped\n");
576580
dev->stats.rx_dropped++;
577581
}
578582

@@ -667,6 +671,32 @@ static int ethoc_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
667671

668672
static void ethoc_mdio_poll(struct net_device *dev)
669673
{
674+
struct ethoc *priv = netdev_priv(dev);
675+
struct phy_device *phydev = dev->phydev;
676+
bool changed = false;
677+
u32 mode;
678+
679+
if (priv->old_link != phydev->link) {
680+
changed = true;
681+
priv->old_link = phydev->link;
682+
}
683+
684+
if (priv->old_duplex != phydev->duplex) {
685+
changed = true;
686+
priv->old_duplex = phydev->duplex;
687+
}
688+
689+
if (!changed)
690+
return;
691+
692+
mode = ethoc_read(priv, MODER);
693+
if (phydev->duplex == DUPLEX_FULL)
694+
mode |= MODER_FULLD;
695+
else
696+
mode &= ~MODER_FULLD;
697+
ethoc_write(priv, MODER, mode);
698+
699+
phy_print_status(phydev);
670700
}
671701

672702
static int ethoc_mdio_probe(struct net_device *dev)
@@ -685,6 +715,9 @@ static int ethoc_mdio_probe(struct net_device *dev)
685715
return -ENXIO;
686716
}
687717

718+
priv->old_duplex = -1;
719+
priv->old_link = -1;
720+
688721
err = phy_connect_direct(dev, phy, ethoc_mdio_poll,
689722
PHY_INTERFACE_MODE_GMII);
690723
if (err) {
@@ -721,6 +754,9 @@ static int ethoc_open(struct net_device *dev)
721754
netif_start_queue(dev);
722755
}
723756

757+
priv->old_link = -1;
758+
priv->old_duplex = -1;
759+
724760
phy_start(dev->phydev);
725761
napi_enable(&priv->napi);
726762

@@ -1123,11 +1159,9 @@ static int ethoc_probe(struct platform_device *pdev)
11231159
memcpy(netdev->dev_addr, pdata->hwaddr, IFHWADDRLEN);
11241160
priv->phy_id = pdata->phy_id;
11251161
} else {
1126-
const uint8_t *mac;
1162+
const void *mac;
11271163

1128-
mac = of_get_property(pdev->dev.of_node,
1129-
"local-mac-address",
1130-
NULL);
1164+
mac = of_get_mac_address(pdev->dev.of_node);
11311165
if (mac)
11321166
memcpy(netdev->dev_addr, mac, IFHWADDRLEN);
11331167
priv->phy_id = -1;

0 commit comments

Comments
 (0)