* [PATCH 1/2] net: ethernet: pasemi_mac: use phydev from struct net_device
@ 2016-07-14 21:44 Philippe Reynes
2016-07-14 21:44 ` [PATCH 2/2] net: ethernet: pasemi_mac: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
2016-07-15 23:43 ` [PATCH 1/2] net: ethernet: pasemi_mac: use phydev from struct net_device David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Philippe Reynes @ 2016-07-14 21:44 UTC (permalink / raw)
To: olof, 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/pasemi/pasemi_mac.c | 28 ++++++++++-----------
drivers/net/ethernet/pasemi/pasemi_mac.h | 1 -
drivers/net/ethernet/pasemi/pasemi_mac_ethtool.c | 6 +---
3 files changed, 15 insertions(+), 20 deletions(-)
diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.c b/drivers/net/ethernet/pasemi/pasemi_mac.c
index af54df5..2f4a837 100644
--- a/drivers/net/ethernet/pasemi/pasemi_mac.c
+++ b/drivers/net/ethernet/pasemi/pasemi_mac.c
@@ -989,7 +989,7 @@ static void pasemi_adjust_link(struct net_device *dev)
unsigned int flags;
unsigned int new_flags;
- if (!mac->phydev->link) {
+ if (!dev->phydev->link) {
/* If no link, MAC speed settings don't matter. Just report
* link down and return.
*/
@@ -1010,10 +1010,10 @@ static void pasemi_adjust_link(struct net_device *dev)
new_flags = flags & ~(PAS_MAC_CFG_PCFG_HD | PAS_MAC_CFG_PCFG_SPD_M |
PAS_MAC_CFG_PCFG_TSR_M);
- if (!mac->phydev->duplex)
+ if (!dev->phydev->duplex)
new_flags |= PAS_MAC_CFG_PCFG_HD;
- switch (mac->phydev->speed) {
+ switch (dev->phydev->speed) {
case 1000:
new_flags |= PAS_MAC_CFG_PCFG_SPD_1G |
PAS_MAC_CFG_PCFG_TSR_1G;
@@ -1027,15 +1027,15 @@ static void pasemi_adjust_link(struct net_device *dev)
PAS_MAC_CFG_PCFG_TSR_10M;
break;
default:
- printk("Unsupported speed %d\n", mac->phydev->speed);
+ printk("Unsupported speed %d\n", dev->phydev->speed);
}
/* Print on link or speed/duplex change */
- msg = mac->link != mac->phydev->link || flags != new_flags;
+ msg = mac->link != dev->phydev->link || flags != new_flags;
- mac->duplex = mac->phydev->duplex;
- mac->speed = mac->phydev->speed;
- mac->link = mac->phydev->link;
+ mac->duplex = dev->phydev->duplex;
+ mac->speed = dev->phydev->speed;
+ mac->link = dev->phydev->link;
if (new_flags != flags)
write_mac_reg(mac, PAS_MAC_CFG_PCFG, new_flags);
@@ -1067,8 +1067,6 @@ static int pasemi_mac_phy_init(struct net_device *dev)
return -ENODEV;
}
- mac->phydev = phydev;
-
return 0;
}
@@ -1198,8 +1196,8 @@ static int pasemi_mac_open(struct net_device *dev)
goto out_rx_int;
}
- if (mac->phydev)
- phy_start(mac->phydev);
+ if (dev->phydev)
+ phy_start(dev->phydev);
setup_timer(&mac->tx->clean_timer, pasemi_mac_tx_timer,
(unsigned long)mac->tx);
@@ -1293,9 +1291,9 @@ static int pasemi_mac_close(struct net_device *dev)
rxch = rx_ring(mac)->chan.chno;
txch = tx_ring(mac)->chan.chno;
- if (mac->phydev) {
- phy_stop(mac->phydev);
- phy_disconnect(mac->phydev);
+ if (dev->phydev) {
+ phy_stop(dev->phydev);
+ phy_disconnect(dev->phydev);
}
del_timer_sync(&mac->tx->clean_timer);
diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.h b/drivers/net/ethernet/pasemi/pasemi_mac.h
index 161c99a..7c47e26 100644
--- a/drivers/net/ethernet/pasemi/pasemi_mac.h
+++ b/drivers/net/ethernet/pasemi/pasemi_mac.h
@@ -70,7 +70,6 @@ struct pasemi_mac {
struct pci_dev *pdev;
struct pci_dev *dma_pdev;
struct pci_dev *iob_pdev;
- struct phy_device *phydev;
struct napi_struct napi;
int bufsz; /* RX ring buffer size */
diff --git a/drivers/net/ethernet/pasemi/pasemi_mac_ethtool.c b/drivers/net/ethernet/pasemi/pasemi_mac_ethtool.c
index f046bfc..e99cf42 100644
--- a/drivers/net/ethernet/pasemi/pasemi_mac_ethtool.c
+++ b/drivers/net/ethernet/pasemi/pasemi_mac_ethtool.c
@@ -66,8 +66,7 @@ static int
pasemi_mac_ethtool_get_settings(struct net_device *netdev,
struct ethtool_cmd *cmd)
{
- struct pasemi_mac *mac = netdev_priv(netdev);
- struct phy_device *phydev = mac->phydev;
+ struct phy_device *phydev = netdev->phydev;
if (!phydev)
return -EOPNOTSUPP;
@@ -79,8 +78,7 @@ static int
pasemi_mac_ethtool_set_settings(struct net_device *netdev,
struct ethtool_cmd *cmd)
{
- struct pasemi_mac *mac = netdev_priv(netdev);
- struct phy_device *phydev = mac->phydev;
+ struct phy_device *phydev = netdev->phydev;
if (!phydev)
return -EOPNOTSUPP;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] net: ethernet: pasemi_mac: use phy_ethtool_{get|set}_link_ksettings
2016-07-14 21:44 [PATCH 1/2] net: ethernet: pasemi_mac: use phydev from struct net_device Philippe Reynes
@ 2016-07-14 21:44 ` Philippe Reynes
2016-07-15 23:43 ` David Miller
2016-07-15 23:43 ` [PATCH 1/2] net: ethernet: pasemi_mac: use phydev from struct net_device David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Philippe Reynes @ 2016-07-14 21:44 UTC (permalink / raw)
To: olof, 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.
Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
---
drivers/net/ethernet/pasemi/pasemi_mac_ethtool.c | 28 +--------------------
1 files changed, 2 insertions(+), 26 deletions(-)
diff --git a/drivers/net/ethernet/pasemi/pasemi_mac_ethtool.c b/drivers/net/ethernet/pasemi/pasemi_mac_ethtool.c
index e99cf42..d0afc2b 100644
--- a/drivers/net/ethernet/pasemi/pasemi_mac_ethtool.c
+++ b/drivers/net/ethernet/pasemi/pasemi_mac_ethtool.c
@@ -62,30 +62,6 @@ static struct {
{ "tx-1024-1518-byte-packets" },
};
-static int
-pasemi_mac_ethtool_get_settings(struct net_device *netdev,
- struct ethtool_cmd *cmd)
-{
- struct phy_device *phydev = netdev->phydev;
-
- if (!phydev)
- return -EOPNOTSUPP;
-
- return phy_ethtool_gset(phydev, cmd);
-}
-
-static int
-pasemi_mac_ethtool_set_settings(struct net_device *netdev,
- struct ethtool_cmd *cmd)
-{
- struct phy_device *phydev = netdev->phydev;
-
- if (!phydev)
- return -EOPNOTSUPP;
-
- return phy_ethtool_sset(phydev, cmd);
-}
-
static u32
pasemi_mac_ethtool_get_msglevel(struct net_device *netdev)
{
@@ -143,8 +119,6 @@ static void pasemi_mac_get_strings(struct net_device *netdev, u32 stringset,
}
const struct ethtool_ops pasemi_mac_ethtool_ops = {
- .get_settings = pasemi_mac_ethtool_get_settings,
- .set_settings = pasemi_mac_ethtool_set_settings,
.get_msglevel = pasemi_mac_ethtool_get_msglevel,
.set_msglevel = pasemi_mac_ethtool_set_msglevel,
.get_link = ethtool_op_get_link,
@@ -152,5 +126,7 @@ const struct ethtool_ops pasemi_mac_ethtool_ops = {
.get_strings = pasemi_mac_get_strings,
.get_sset_count = pasemi_mac_get_sset_count,
.get_ethtool_stats = pasemi_mac_get_ethtool_stats,
+ .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: pasemi_mac: use phydev from struct net_device
2016-07-14 21:44 [PATCH 1/2] net: ethernet: pasemi_mac: use phydev from struct net_device Philippe Reynes
2016-07-14 21:44 ` [PATCH 2/2] net: ethernet: pasemi_mac: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
@ 2016-07-15 23:43 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2016-07-15 23:43 UTC (permalink / raw)
To: tremyfr; +Cc: olof, netdev, linux-kernel
From: Philippe Reynes <tremyfr@gmail.com>
Date: Thu, 14 Jul 2016 23:44:52 +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: pasemi_mac: use phy_ethtool_{get|set}_link_ksettings
2016-07-14 21:44 ` [PATCH 2/2] net: ethernet: pasemi_mac: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
@ 2016-07-15 23:43 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2016-07-15 23:43 UTC (permalink / raw)
To: tremyfr; +Cc: olof, netdev, linux-kernel
From: Philippe Reynes <tremyfr@gmail.com>
Date: Thu, 14 Jul 2016 23:44:53 +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.
>
> 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:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-14 21:44 [PATCH 1/2] net: ethernet: pasemi_mac: use phydev from struct net_device Philippe Reynes
2016-07-14 21:44 ` [PATCH 2/2] net: ethernet: pasemi_mac: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
2016-07-15 23:43 ` David Miller
2016-07-15 23:43 ` [PATCH 1/2] net: ethernet: pasemi_mac: 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.