* [PATCH 1/2] net: ethernet: amd: au1000_eth: use phydev from struct net_device
@ 2016-07-15 10:05 Philippe Reynes
2016-07-15 10:05 ` [PATCH 2/2] net: ethernet: amd: au1000_eth: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
2016-07-15 23:44 ` [PATCH 1/2] net: ethernet: amd: au1000_eth: use phydev from struct net_device David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Philippe Reynes @ 2016-07-15 10:05 UTC (permalink / raw)
To: davem, andrew, f.fainelli, manuel.lauss, mugunthanvnm, ivecera,
xypron.glpk
Cc: netdev, 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
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>
---
drivers/net/ethernet/amd/au1000_eth.c | 40 +++++++++++++-------------------
drivers/net/ethernet/amd/au1000_eth.h | 1 -
2 files changed, 16 insertions(+), 25 deletions(-)
diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
index 20760e1..18fe333 100644
--- a/drivers/net/ethernet/amd/au1000_eth.c
+++ b/drivers/net/ethernet/amd/au1000_eth.c
@@ -412,13 +412,13 @@ static void
au1000_adjust_link(struct net_device *dev)
{
struct au1000_private *aup = netdev_priv(dev);
- struct phy_device *phydev = aup->phy_dev;
+ struct phy_device *phydev = dev->phydev;
unsigned long flags;
u32 reg;
int status_change = 0;
- BUG_ON(!aup->phy_dev);
+ BUG_ON(!phydev);
spin_lock_irqsave(&aup->lock, flags);
@@ -579,7 +579,6 @@ static int au1000_mii_probe(struct net_device *dev)
aup->old_link = 0;
aup->old_speed = 0;
aup->old_duplex = -1;
- aup->phy_dev = phydev;
phy_attached_info(phydev);
@@ -680,23 +679,19 @@ au1000_setup_hw_rings(struct au1000_private *aup, void __iomem *tx_base)
static int au1000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
- struct au1000_private *aup = netdev_priv(dev);
-
- if (aup->phy_dev)
- return phy_ethtool_gset(aup->phy_dev, cmd);
+ if (dev->phydev)
+ return phy_ethtool_gset(dev->phydev, cmd);
return -EINVAL;
}
static int au1000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
- struct au1000_private *aup = netdev_priv(dev);
-
if (!capable(CAP_NET_ADMIN))
return -EPERM;
- if (aup->phy_dev)
- return phy_ethtool_sset(aup->phy_dev, cmd);
+ if (dev->phydev)
+ return phy_ethtool_sset(dev->phydev, cmd);
return -EINVAL;
}
@@ -778,8 +773,8 @@ static int au1000_init(struct net_device *dev)
#ifndef CONFIG_CPU_LITTLE_ENDIAN
control |= MAC_BIG_ENDIAN;
#endif
- if (aup->phy_dev) {
- if (aup->phy_dev->link && (DUPLEX_FULL == aup->phy_dev->duplex))
+ if (dev->phydev) {
+ if (dev->phydev->link && (DUPLEX_FULL == dev->phydev->duplex))
control |= MAC_FULL_DUPLEX;
else
control |= MAC_DISABLE_RX_OWN;
@@ -891,11 +886,10 @@ static int au1000_rx(struct net_device *dev)
static void au1000_update_tx_stats(struct net_device *dev, u32 status)
{
- struct au1000_private *aup = netdev_priv(dev);
struct net_device_stats *ps = &dev->stats;
if (status & TX_FRAME_ABORTED) {
- if (!aup->phy_dev || (DUPLEX_FULL == aup->phy_dev->duplex)) {
+ if (!dev->phydev || (DUPLEX_FULL == dev->phydev->duplex)) {
if (status & (TX_JAB_TIMEOUT | TX_UNDERRUN)) {
/* any other tx errors are only valid
* in half duplex mode
@@ -975,10 +969,10 @@ static int au1000_open(struct net_device *dev)
return retval;
}
- if (aup->phy_dev) {
+ if (dev->phydev) {
/* cause the PHY state machine to schedule a link state check */
- aup->phy_dev->state = PHY_CHANGELINK;
- phy_start(aup->phy_dev);
+ dev->phydev->state = PHY_CHANGELINK;
+ phy_start(dev->phydev);
}
netif_start_queue(dev);
@@ -995,8 +989,8 @@ static int au1000_close(struct net_device *dev)
netif_dbg(aup, drv, dev, "close: dev=%p\n", dev);
- if (aup->phy_dev)
- phy_stop(aup->phy_dev);
+ if (dev->phydev)
+ phy_stop(dev->phydev);
spin_lock_irqsave(&aup->lock, flags);
@@ -1110,15 +1104,13 @@ static void au1000_multicast_list(struct net_device *dev)
static int au1000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
- struct au1000_private *aup = netdev_priv(dev);
-
if (!netif_running(dev))
return -EINVAL;
- if (!aup->phy_dev)
+ if (!dev->phydev)
return -EINVAL; /* PHY not controllable */
- return phy_mii_ioctl(aup->phy_dev, rq, cmd);
+ return phy_mii_ioctl(dev->phydev, rq, cmd);
}
static const struct net_device_ops au1000_netdev_ops = {
diff --git a/drivers/net/ethernet/amd/au1000_eth.h b/drivers/net/ethernet/amd/au1000_eth.h
index ca53024..4c47c23 100644
--- a/drivers/net/ethernet/amd/au1000_eth.h
+++ b/drivers/net/ethernet/amd/au1000_eth.h
@@ -106,7 +106,6 @@ struct au1000_private {
int old_speed;
int old_duplex;
- struct phy_device *phy_dev;
struct mii_bus *mii_bus;
/* PHY configuration */
--
1.7.4.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] net: ethernet: amd: au1000_eth: use phy_ethtool_{get|set}_link_ksettings
2016-07-15 10:05 [PATCH 1/2] net: ethernet: amd: au1000_eth: use phydev from struct net_device Philippe Reynes
@ 2016-07-15 10:05 ` Philippe Reynes
2016-07-15 23:44 ` David Miller
2016-07-15 23:44 ` [PATCH 1/2] net: ethernet: amd: au1000_eth: use phydev from struct net_device David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Philippe Reynes @ 2016-07-15 10:05 UTC (permalink / raw)
To: davem, andrew, f.fainelli, manuel.lauss, mugunthanvnm, ivecera,
xypron.glpk
Cc: netdev, 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 au1000_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/amd/au1000_eth.c | 23 ++---------------------
1 files changed, 2 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
index 18fe333..df66418 100644
--- a/drivers/net/ethernet/amd/au1000_eth.c
+++ b/drivers/net/ethernet/amd/au1000_eth.c
@@ -677,25 +677,6 @@ au1000_setup_hw_rings(struct au1000_private *aup, void __iomem *tx_base)
* ethtool operations
*/
-static int au1000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
-{
- if (dev->phydev)
- return phy_ethtool_gset(dev->phydev, cmd);
-
- return -EINVAL;
-}
-
-static int au1000_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
au1000_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
{
@@ -720,12 +701,12 @@ static u32 au1000_get_msglevel(struct net_device *dev)
}
static const struct ethtool_ops au1000_ethtool_ops = {
- .get_settings = au1000_get_settings,
- .set_settings = au1000_set_settings,
.get_drvinfo = au1000_get_drvinfo,
.get_link = ethtool_op_get_link,
.get_msglevel = au1000_get_msglevel,
.set_msglevel = au1000_set_msglevel,
+ .get_link_ksettings = phy_ethtool_get_link_ksettings,
+ .set_link_ksettings = phy_ethtool_set_link_ksettings,
};
--
1.7.4.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] net: ethernet: amd: au1000_eth: use phydev from struct net_device
2016-07-15 10:05 [PATCH 1/2] net: ethernet: amd: au1000_eth: use phydev from struct net_device Philippe Reynes
2016-07-15 10:05 ` [PATCH 2/2] net: ethernet: amd: au1000_eth: 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: andrew, f.fainelli, manuel.lauss, mugunthanvnm, ivecera,
xypron.glpk, netdev
From: Philippe Reynes <tremyfr@gmail.com>
Date: Fri, 15 Jul 2016 12:05:11 +0200
> 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>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] net: ethernet: amd: au1000_eth: use phy_ethtool_{get|set}_link_ksettings
2016-07-15 10:05 ` [PATCH 2/2] net: ethernet: amd: au1000_eth: 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: andrew, f.fainelli, manuel.lauss, mugunthanvnm, ivecera,
xypron.glpk, netdev
From: Philippe Reynes <tremyfr@gmail.com>
Date: Fri, 15 Jul 2016 12:05:12 +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 au1000_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:05 [PATCH 1/2] net: ethernet: amd: au1000_eth: use phydev from struct net_device Philippe Reynes
2016-07-15 10:05 ` [PATCH 2/2] net: ethernet: amd: au1000_eth: 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: amd: au1000_eth: use phydev from struct net_device David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.