* [PATCH 1/2] net: ethernet: ti: cpmac: use phydev from struct net_device
@ 2016-07-15 10:39 Philippe Reynes
2016-07-15 10:39 ` [PATCH 2/2] net: ethernet: ti: cpmac: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
2016-07-15 23:44 ` [PATCH 1/2] net: ethernet: ti: cpmac: use phydev from struct net_device David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Philippe Reynes @ 2016-07-15 10:39 UTC (permalink / raw)
To: florian, davem; +Cc: netdev, linux-kernel, Philippe Reynes
The private structure contain a pointer to phydev, but the structure
net_device already contain such pointer. So we can remove the pointer
phy 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>
---
drivers/net/ethernet/ti/cpmac.c | 46 +++++++++++++++++----------------------
1 files changed, 20 insertions(+), 26 deletions(-)
diff --git a/drivers/net/ethernet/ti/cpmac.c b/drivers/net/ethernet/ti/cpmac.c
index 7eef45e..f48e43b 100644
--- a/drivers/net/ethernet/ti/cpmac.c
+++ b/drivers/net/ethernet/ti/cpmac.c
@@ -205,7 +205,6 @@ struct cpmac_priv {
dma_addr_t dma_ring;
void __iomem *regs;
struct mii_bus *mii_bus;
- struct phy_device *phy;
char phy_name[MII_BUS_ID_SIZE + 3];
int oldlink, oldspeed, oldduplex;
u32 msg_enable;
@@ -830,35 +829,29 @@ static void cpmac_tx_timeout(struct net_device *dev)
static int cpmac_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
- struct cpmac_priv *priv = netdev_priv(dev);
-
if (!(netif_running(dev)))
return -EINVAL;
- if (!priv->phy)
+ if (!dev->phydev)
return -EINVAL;
- return phy_mii_ioctl(priv->phy, ifr, cmd);
+ return phy_mii_ioctl(dev->phydev, ifr, cmd);
}
static int cpmac_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
- struct cpmac_priv *priv = netdev_priv(dev);
-
- if (priv->phy)
- return phy_ethtool_gset(priv->phy, cmd);
+ if (dev->phydev)
+ return phy_ethtool_gset(dev->phydev, cmd);
return -EINVAL;
}
static int cpmac_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
- struct cpmac_priv *priv = netdev_priv(dev);
-
if (!capable(CAP_NET_ADMIN))
return -EPERM;
- if (priv->phy)
- return phy_ethtool_sset(priv->phy, cmd);
+ if (dev->phydev)
+ return phy_ethtool_sset(dev->phydev, cmd);
return -EINVAL;
}
@@ -914,16 +907,16 @@ static void cpmac_adjust_link(struct net_device *dev)
int new_state = 0;
spin_lock(&priv->lock);
- if (priv->phy->link) {
+ if (dev->phydev->link) {
netif_tx_start_all_queues(dev);
- if (priv->phy->duplex != priv->oldduplex) {
+ if (dev->phydev->duplex != priv->oldduplex) {
new_state = 1;
- priv->oldduplex = priv->phy->duplex;
+ priv->oldduplex = dev->phydev->duplex;
}
- if (priv->phy->speed != priv->oldspeed) {
+ if (dev->phydev->speed != priv->oldspeed) {
new_state = 1;
- priv->oldspeed = priv->phy->speed;
+ priv->oldspeed = dev->phydev->speed;
}
if (!priv->oldlink) {
@@ -938,7 +931,7 @@ static void cpmac_adjust_link(struct net_device *dev)
}
if (new_state && netif_msg_link(priv) && net_ratelimit())
- phy_print_status(priv->phy);
+ phy_print_status(dev->phydev);
spin_unlock(&priv->lock);
}
@@ -1016,8 +1009,8 @@ static int cpmac_open(struct net_device *dev)
cpmac_hw_start(dev);
napi_enable(&priv->napi);
- priv->phy->state = PHY_CHANGELINK;
- phy_start(priv->phy);
+ dev->phydev->state = PHY_CHANGELINK;
+ phy_start(dev->phydev);
return 0;
@@ -1053,7 +1046,7 @@ static int cpmac_stop(struct net_device *dev)
cancel_work_sync(&priv->reset_work);
napi_disable(&priv->napi);
- phy_stop(priv->phy);
+ phy_stop(dev->phydev);
cpmac_hw_stop(dev);
@@ -1106,6 +1099,7 @@ static int cpmac_probe(struct platform_device *pdev)
struct cpmac_priv *priv;
struct net_device *dev;
struct plat_cpmac_data *pdata;
+ struct phy_device *phydev = NULL;
pdata = dev_get_platdata(&pdev->dev);
@@ -1162,14 +1156,14 @@ static int cpmac_probe(struct platform_device *pdev)
snprintf(priv->phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT,
mdio_bus_id, phy_id);
- priv->phy = phy_connect(dev, priv->phy_name, cpmac_adjust_link,
- PHY_INTERFACE_MODE_MII);
+ phydev = phy_connect(dev, priv->phy_name, cpmac_adjust_link,
+ PHY_INTERFACE_MODE_MII);
- if (IS_ERR(priv->phy)) {
+ if (IS_ERR(phydev)) {
if (netif_msg_drv(priv))
dev_err(&pdev->dev, "Could not attach to PHY\n");
- rc = PTR_ERR(priv->phy);
+ rc = PTR_ERR(phydev);
goto out;
}
--
1.7.4.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] net: ethernet: ti: cpmac: use phy_ethtool_{get|set}_link_ksettings
2016-07-15 10:39 [PATCH 1/2] net: ethernet: ti: cpmac: use phydev from struct net_device Philippe Reynes
@ 2016-07-15 10:39 ` Philippe Reynes
2016-07-15 23:44 ` David Miller
2016-07-15 23:44 ` [PATCH 1/2] net: ethernet: ti: cpmac: use phydev from struct net_device David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Philippe Reynes @ 2016-07-15 10:39 UTC (permalink / raw)
To: florian, davem; +Cc: netdev, linux-kernel, Philippe Reynes
There are two generics functions phy_ethtool_{get|set}_link_ksettings,
so we can use them instead of defining the same code in the driver.
There was a check on CAP_NET_ADMIN in cpmac_set_settings, but this
check is already done in dev_ethtool, so no need to repeat it before
calling the generic function.
Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
---
drivers/net/ethernet/ti/cpmac.c | 23 ++---------------------
1 files changed, 2 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/ti/cpmac.c b/drivers/net/ethernet/ti/cpmac.c
index f48e43b..f86497c 100644
--- a/drivers/net/ethernet/ti/cpmac.c
+++ b/drivers/net/ethernet/ti/cpmac.c
@@ -837,25 +837,6 @@ static int cpmac_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
return phy_mii_ioctl(dev->phydev, ifr, cmd);
}
-static int cpmac_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
-{
- if (dev->phydev)
- return phy_ethtool_gset(dev->phydev, cmd);
-
- return -EINVAL;
-}
-
-static int cpmac_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
-{
- if (!capable(CAP_NET_ADMIN))
- return -EPERM;
-
- if (dev->phydev)
- return phy_ethtool_sset(dev->phydev, cmd);
-
- return -EINVAL;
-}
-
static void cpmac_get_ringparam(struct net_device *dev,
struct ethtool_ringparam *ring)
{
@@ -893,12 +874,12 @@ static void cpmac_get_drvinfo(struct net_device *dev,
}
static const struct ethtool_ops cpmac_ethtool_ops = {
- .get_settings = cpmac_get_settings,
- .set_settings = cpmac_set_settings,
.get_drvinfo = cpmac_get_drvinfo,
.get_link = ethtool_op_get_link,
.get_ringparam = cpmac_get_ringparam,
.set_ringparam = cpmac_set_ringparam,
+ .get_link_ksettings = phy_ethtool_get_link_ksettings,
+ .set_link_ksettings = phy_ethtool_set_link_ksettings,
};
static void cpmac_adjust_link(struct net_device *dev)
--
1.7.4.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] net: ethernet: ti: cpmac: use phydev from struct net_device
2016-07-15 10:39 [PATCH 1/2] net: ethernet: ti: cpmac: use phydev from struct net_device Philippe Reynes
2016-07-15 10:39 ` [PATCH 2/2] net: ethernet: ti: cpmac: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
@ 2016-07-15 23:44 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2016-07-15 23:44 UTC (permalink / raw)
To: tremyfr; +Cc: florian, netdev, linux-kernel
From: Philippe Reynes <tremyfr@gmail.com>
Date: Fri, 15 Jul 2016 12:39:01 +0200
> The private structure contain a pointer to phydev, but the structure
> net_device already contain such pointer. So we can remove the pointer
> phy 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>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] net: ethernet: ti: cpmac: use phy_ethtool_{get|set}_link_ksettings
2016-07-15 10:39 ` [PATCH 2/2] net: ethernet: ti: cpmac: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
@ 2016-07-15 23:44 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2016-07-15 23:44 UTC (permalink / raw)
To: tremyfr; +Cc: florian, netdev, linux-kernel
From: Philippe Reynes <tremyfr@gmail.com>
Date: Fri, 15 Jul 2016 12:39:02 +0200
> There are two generics functions phy_ethtool_{get|set}_link_ksettings,
> so we can use them instead of defining the same code in the driver.
>
> There was a check on CAP_NET_ADMIN in cpmac_set_settings, but this
> check is already done in dev_ethtool, so no need to repeat it before
> calling the generic function.
>
> Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-07-15 23:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-15 10:39 [PATCH 1/2] net: ethernet: ti: cpmac: use phydev from struct net_device Philippe Reynes
2016-07-15 10:39 ` [PATCH 2/2] net: ethernet: ti: cpmac: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
2016-07-15 23:44 ` David Miller
2016-07-15 23:44 ` [PATCH 1/2] net: ethernet: ti: cpmac: use phydev from struct net_device David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).