Skip to content

Commit

Permalink
net: ethernet: altera_tse: use phydev from struct net_device
Browse files Browse the repository at this point in the history
The private structure contain a pointer to phydev, but the structure
net_device already contain such pointer. So we can remove the pointer
phydev in the private structure, and update the driver to use the
one contained in struct net_device.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Philippe Reynes authored and David S. Miller committed Jun 22, 2016
1 parent 91cd3b4 commit 941ea69
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
1 change: 0 additions & 1 deletion drivers/net/ethernet/altera/altera_tse.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@ struct altera_tse_private {
int phy_addr; /* PHY's MDIO address, -1 for autodetection */
phy_interface_t phy_iface;
struct mii_bus *mdio;
struct phy_device *phydev;
int oldspeed;
int oldduplex;
int oldlink;
Expand Down
6 changes: 2 additions & 4 deletions drivers/net/ethernet/altera/altera_tse_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,7 @@ static void tse_get_regs(struct net_device *dev, struct ethtool_regs *regs,

static int tse_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
struct altera_tse_private *priv = netdev_priv(dev);
struct phy_device *phydev = priv->phydev;
struct phy_device *phydev = dev->phydev;

if (phydev == NULL)
return -ENODEV;
Expand All @@ -246,8 +245,7 @@ static int tse_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)

static int tse_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
struct altera_tse_private *priv = netdev_priv(dev);
struct phy_device *phydev = priv->phydev;
struct phy_device *phydev = dev->phydev;

if (phydev == NULL)
return -ENODEV;
Expand Down
16 changes: 7 additions & 9 deletions drivers/net/ethernet/altera/altera_tse_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ static int tse_start_xmit(struct sk_buff *skb, struct net_device *dev)
static void altera_tse_adjust_link(struct net_device *dev)
{
struct altera_tse_private *priv = netdev_priv(dev);
struct phy_device *phydev = priv->phydev;
struct phy_device *phydev = dev->phydev;
int new_state = 0;

/* only change config if there is a link */
Expand Down Expand Up @@ -845,7 +845,6 @@ static int init_phy(struct net_device *dev)
netdev_dbg(dev, "attached to PHY %d UID 0x%08x Link = %d\n",
phydev->mdio.addr, phydev->phy_id, phydev->link);

priv->phydev = phydev;
return 0;
}

Expand Down Expand Up @@ -1172,8 +1171,8 @@ static int tse_open(struct net_device *dev)

spin_unlock_irqrestore(&priv->rxdma_irq_lock, flags);

if (priv->phydev)
phy_start(priv->phydev);
if (dev->phydev)
phy_start(dev->phydev);

napi_enable(&priv->napi);
netif_start_queue(dev);
Expand Down Expand Up @@ -1205,8 +1204,8 @@ static int tse_shutdown(struct net_device *dev)
unsigned long int flags;

/* Stop the PHY */
if (priv->phydev)
phy_stop(priv->phydev);
if (dev->phydev)
phy_stop(dev->phydev);

netif_stop_queue(dev);
napi_disable(&priv->napi);
Expand Down Expand Up @@ -1545,10 +1544,9 @@ static int altera_tse_probe(struct platform_device *pdev)
static int altera_tse_remove(struct platform_device *pdev)
{
struct net_device *ndev = platform_get_drvdata(pdev);
struct altera_tse_private *priv = netdev_priv(ndev);

if (priv->phydev)
phy_disconnect(priv->phydev);
if (ndev->phydev)
phy_disconnect(ndev->phydev);

platform_set_drvdata(pdev, NULL);
altera_tse_mdio_destroy(ndev);
Expand Down

0 comments on commit 941ea69

Please sign in to comment.