* [PATCH 1/2] net: ethernet: ethoc: use phydev from struct net_device
@ 2016-06-25 14:33 Philippe Reynes
2016-06-25 14:33 ` [PATCH 2/2] net: ethernet: ethoc: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Philippe Reynes @ 2016-06-25 14:33 UTC (permalink / raw)
To: davem, andrew, tklauser, colin.king, f.fainelli, jcmvbkbc
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/ethoc.c | 19 +++++++------------
1 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 4edb98c..fe09021 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -219,7 +219,6 @@ struct ethoc {
spinlock_t lock;
- struct phy_device *phy;
struct mii_bus *mdio;
struct clk *clk;
s8 phy_id;
@@ -694,7 +693,6 @@ static int ethoc_mdio_probe(struct net_device *dev)
return err;
}
- priv->phy = phy;
phy->advertising &= ~(ADVERTISED_1000baseT_Full |
ADVERTISED_1000baseT_Half);
phy->supported &= ~(SUPPORTED_1000baseT_Full |
@@ -724,7 +722,7 @@ static int ethoc_open(struct net_device *dev)
netif_start_queue(dev);
}
- phy_start(priv->phy);
+ phy_start(dev->phydev);
napi_enable(&priv->napi);
if (netif_msg_ifup(priv)) {
@@ -741,8 +739,8 @@ static int ethoc_stop(struct net_device *dev)
napi_disable(&priv->napi);
- if (priv->phy)
- phy_stop(priv->phy);
+ if (dev->phydev)
+ phy_stop(dev->phydev);
ethoc_disable_rx_and_tx(priv);
free_irq(dev->irq, dev);
@@ -770,7 +768,7 @@ static int ethoc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
if (!phy)
return -ENODEV;
} else {
- phy = priv->phy;
+ phy = dev->phydev;
}
return phy_mii_ioctl(phy, ifr, cmd);
@@ -899,8 +897,7 @@ out:
static int ethoc_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
- struct ethoc *priv = netdev_priv(dev);
- struct phy_device *phydev = priv->phy;
+ struct phy_device *phydev = dev->phydev;
if (!phydev)
return -EOPNOTSUPP;
@@ -910,8 +907,7 @@ static int ethoc_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
static int ethoc_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
- struct ethoc *priv = netdev_priv(dev);
- struct phy_device *phydev = priv->phy;
+ struct phy_device *phydev = dev->phydev;
if (!phydev)
return -EOPNOTSUPP;
@@ -1261,8 +1257,7 @@ static int ethoc_remove(struct platform_device *pdev)
if (netdev) {
netif_napi_del(&priv->napi);
- phy_disconnect(priv->phy);
- priv->phy = NULL;
+ phy_disconnect(netdev->phydev);
if (priv->mdio) {
mdiobus_unregister(priv->mdio);
--
1.7.4.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] net: ethernet: ethoc: use phy_ethtool_{get|set}_link_ksettings
2016-06-25 14:33 [PATCH 1/2] net: ethernet: ethoc: use phydev from struct net_device Philippe Reynes
@ 2016-06-25 14:33 ` Philippe Reynes
2016-06-27 6:35 ` Tobias Klauser
2016-06-25 18:31 ` [PATCH 1/2] net: ethernet: ethoc: use phydev from struct net_device Max Filippov
2016-06-27 6:32 ` Tobias Klauser
2 siblings, 1 reply; 5+ messages in thread
From: Philippe Reynes @ 2016-06-25 14:33 UTC (permalink / raw)
To: davem, andrew, tklauser, colin.king, f.fainelli, jcmvbkbc
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.
Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
---
drivers/net/ethernet/ethoc.c | 24 ++----------------------
1 files changed, 2 insertions(+), 22 deletions(-)
diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index fe09021..37fbf51 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -895,26 +895,6 @@ out:
return NETDEV_TX_OK;
}
-static int ethoc_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
-{
- struct phy_device *phydev = dev->phydev;
-
- if (!phydev)
- return -EOPNOTSUPP;
-
- return phy_ethtool_gset(phydev, cmd);
-}
-
-static int ethoc_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
-{
- struct phy_device *phydev = dev->phydev;
-
- if (!phydev)
- return -EOPNOTSUPP;
-
- return phy_ethtool_sset(phydev, cmd);
-}
-
static int ethoc_get_regs_len(struct net_device *netdev)
{
return ETH_END;
@@ -979,14 +959,14 @@ static int ethoc_set_ringparam(struct net_device *dev,
}
const struct ethtool_ops ethoc_ethtool_ops = {
- .get_settings = ethoc_get_settings,
- .set_settings = ethoc_set_settings,
.get_regs_len = ethoc_get_regs_len,
.get_regs = ethoc_get_regs,
.get_link = ethtool_op_get_link,
.get_ringparam = ethoc_get_ringparam,
.set_ringparam = ethoc_set_ringparam,
.get_ts_info = ethtool_op_get_ts_info,
+ .get_link_ksettings = phy_ethtool_get_link_ksettings,
+ .set_link_ksettings = phy_ethtool_set_link_ksettings,
};
static const struct net_device_ops ethoc_netdev_ops = {
--
1.7.4.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] net: ethernet: ethoc: use phydev from struct net_device
2016-06-25 14:33 [PATCH 1/2] net: ethernet: ethoc: use phydev from struct net_device Philippe Reynes
2016-06-25 14:33 ` [PATCH 2/2] net: ethernet: ethoc: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
@ 2016-06-25 18:31 ` Max Filippov
2016-06-27 6:32 ` Tobias Klauser
2 siblings, 0 replies; 5+ messages in thread
From: Max Filippov @ 2016-06-25 18:31 UTC (permalink / raw)
To: Philippe Reynes
Cc: davem, andrew, tklauser, colin.king, f.fainelli, netdev, linux-kernel
On Sat, Jun 25, 2016 at 04:33:41PM +0200, Philippe Reynes wrote:
> 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>
> ---
Series:
Tested-by: Max Filippov <jcmvbkbc@gmail.com>
--
Thanks.
-- Max
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] net: ethernet: ethoc: use phydev from struct net_device
2016-06-25 14:33 [PATCH 1/2] net: ethernet: ethoc: use phydev from struct net_device Philippe Reynes
2016-06-25 14:33 ` [PATCH 2/2] net: ethernet: ethoc: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
2016-06-25 18:31 ` [PATCH 1/2] net: ethernet: ethoc: use phydev from struct net_device Max Filippov
@ 2016-06-27 6:32 ` Tobias Klauser
2 siblings, 0 replies; 5+ messages in thread
From: Tobias Klauser @ 2016-06-27 6:32 UTC (permalink / raw)
To: Philippe Reynes
Cc: davem, andrew, colin.king, f.fainelli, jcmvbkbc, netdev, linux-kernel
On 2016-06-25 at 16:33:41 +0200, Philippe Reynes <tremyfr@gmail.com> wrote:
> 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.
In that case the phy member should also be removed from the definition
of private struct ethoc in the same patch.
Otherwise the patch looks good to me.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] net: ethernet: ethoc: use phy_ethtool_{get|set}_link_ksettings
2016-06-25 14:33 ` [PATCH 2/2] net: ethernet: ethoc: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
@ 2016-06-27 6:35 ` Tobias Klauser
0 siblings, 0 replies; 5+ messages in thread
From: Tobias Klauser @ 2016-06-27 6:35 UTC (permalink / raw)
To: Philippe Reynes
Cc: davem, andrew, colin.king, f.fainelli, jcmvbkbc, netdev, linux-kernel
On 2016-06-25 at 16:33:42 +0200, Philippe Reynes <tremyfr@gmail.com> wrote:
> 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.
>
> Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
Reviewed-by: Tobias Klauser <tklauser@distanz.ch>
Thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-06-27 6:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-25 14:33 [PATCH 1/2] net: ethernet: ethoc: use phydev from struct net_device Philippe Reynes
2016-06-25 14:33 ` [PATCH 2/2] net: ethernet: ethoc: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
2016-06-27 6:35 ` Tobias Klauser
2016-06-25 18:31 ` [PATCH 1/2] net: ethernet: ethoc: use phydev from struct net_device Max Filippov
2016-06-27 6:32 ` Tobias Klauser
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).