mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-07 22:03:14 +00:00
net: usb: r8152: Use linkmode helpers for EEE
Make use of the existing linkmode helpers for converting PHY EEE register values into links modes, now that ethtool_keee uses link modes, rather than u32 values. Rework determining if EEE is active to make is similar as to how phylib decides, and make use of a phylib helper to validate if EEE is valid in for the current link mode. This then requires that PHYLIB is selected. Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
2e26b6dfad
commit
17206c116d
@ -99,6 +99,7 @@ config USB_RTL8150
|
||||
config USB_RTL8152
|
||||
tristate "Realtek RTL8152/RTL8153 Based USB Ethernet Adapters"
|
||||
select MII
|
||||
select PHYLIB
|
||||
select CRC32
|
||||
select CRYPTO
|
||||
select CRYPTO_HASH
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/mii.h>
|
||||
#include <linux/ethtool.h>
|
||||
#include <linux/phy.h>
|
||||
#include <linux/usb.h>
|
||||
#include <linux/crc32.h>
|
||||
#include <linux/if_vlan.h>
|
||||
@ -8924,30 +8925,29 @@ static void rtl8152_get_strings(struct net_device *dev, u32 stringset, u8 *data)
|
||||
|
||||
static int r8152_get_eee(struct r8152 *tp, struct ethtool_keee *eee)
|
||||
{
|
||||
u32 lp, adv, supported = 0;
|
||||
__ETHTOOL_DECLARE_LINK_MODE_MASK(common);
|
||||
u16 val;
|
||||
|
||||
val = r8152_mmd_read(tp, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
|
||||
supported = mmd_eee_cap_to_ethtool_sup_t(val);
|
||||
mii_eee_cap1_mod_linkmode_t(eee->supported, val);
|
||||
|
||||
val = r8152_mmd_read(tp, MDIO_MMD_AN, MDIO_AN_EEE_ADV);
|
||||
adv = mmd_eee_adv_to_ethtool_adv_t(val);
|
||||
mii_eee_cap1_mod_linkmode_t(eee->advertised, val);
|
||||
|
||||
val = r8152_mmd_read(tp, MDIO_MMD_AN, MDIO_AN_EEE_LPABLE);
|
||||
lp = mmd_eee_adv_to_ethtool_adv_t(val);
|
||||
mii_eee_cap1_mod_linkmode_t(eee->lp_advertised, val);
|
||||
|
||||
eee->eee_enabled = tp->eee_en;
|
||||
eee->eee_active = !!(supported & adv & lp);
|
||||
eee->supported_u32 = supported;
|
||||
eee->advertised_u32 = tp->eee_adv;
|
||||
eee->lp_advertised_u32 = lp;
|
||||
|
||||
linkmode_and(common, eee->advertised, eee->lp_advertised);
|
||||
eee->eee_active = phy_check_valid(tp->speed, tp->duplex, common);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int r8152_set_eee(struct r8152 *tp, struct ethtool_keee *eee)
|
||||
{
|
||||
u16 val = ethtool_adv_to_mmd_eee_adv_t(eee->advertised_u32);
|
||||
u16 val = linkmode_to_mii_eee_cap1_t(eee->advertised);
|
||||
|
||||
tp->eee_en = eee->eee_enabled;
|
||||
tp->eee_adv = val;
|
||||
@ -8959,23 +8959,22 @@ static int r8152_set_eee(struct r8152 *tp, struct ethtool_keee *eee)
|
||||
|
||||
static int r8153_get_eee(struct r8152 *tp, struct ethtool_keee *eee)
|
||||
{
|
||||
u32 lp, adv, supported = 0;
|
||||
__ETHTOOL_DECLARE_LINK_MODE_MASK(common);
|
||||
u16 val;
|
||||
|
||||
val = ocp_reg_read(tp, OCP_EEE_ABLE);
|
||||
supported = mmd_eee_cap_to_ethtool_sup_t(val);
|
||||
mii_eee_cap1_mod_linkmode_t(eee->supported, val);
|
||||
|
||||
val = ocp_reg_read(tp, OCP_EEE_ADV);
|
||||
adv = mmd_eee_adv_to_ethtool_adv_t(val);
|
||||
mii_eee_cap1_mod_linkmode_t(eee->advertised, val);
|
||||
|
||||
val = ocp_reg_read(tp, OCP_EEE_LPABLE);
|
||||
lp = mmd_eee_adv_to_ethtool_adv_t(val);
|
||||
mii_eee_cap1_mod_linkmode_t(eee->lp_advertised, val);
|
||||
|
||||
eee->eee_enabled = tp->eee_en;
|
||||
eee->eee_active = !!(supported & adv & lp);
|
||||
eee->supported_u32 = supported;
|
||||
eee->advertised_u32 = tp->eee_adv;
|
||||
eee->lp_advertised_u32 = lp;
|
||||
|
||||
linkmode_and(common, eee->advertised, eee->lp_advertised);
|
||||
eee->eee_active = phy_check_valid(tp->speed, tp->duplex, common);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user