From: "Nikhil P. Rao" ionic_get_fecparam() maps config.fec_type onto the ethtool FEC values with a switch that assigns both fec->active_fec and fec->fec in each arm. A later patch gives the two fields distinct sources, which would mean duplicating the switch. Move the mapping into ionic_fec_type_to_ethtool() and call it once per field. Read config.fec_type once, as the switch did, so the two fields cannot be filled from different values while firmware rewrites port_info. No functional change. Signed-off-by: Nikhil P. Rao Signed-off-by: Eric Joyner Signed-off-by: Brett Creeley --- .../net/ethernet/pensando/ionic/ionic_ethtool.c | 36 +++++++++++++--------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c index e7262a842eda..312cd3e5e404 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c @@ -424,25 +424,33 @@ static int ionic_set_pauseparam(struct net_device *netdev, return 0; } -static int ionic_get_fecparam(struct net_device *netdev, - struct ethtool_fecparam *fec) +static u32 ionic_fec_type_to_ethtool(u8 fec_type) { - struct ionic_lif *lif = netdev_priv(netdev); - - switch (lif->ionic->idev.port_info->config.fec_type) { + switch (fec_type) { case IONIC_PORT_FEC_TYPE_NONE: - fec->active_fec = ETHTOOL_FEC_OFF; - fec->fec = ETHTOOL_FEC_OFF; - break; + return ETHTOOL_FEC_OFF; case IONIC_PORT_FEC_TYPE_RS: - fec->active_fec = ETHTOOL_FEC_RS; - fec->fec = ETHTOOL_FEC_RS; - break; + return ETHTOOL_FEC_RS; case IONIC_PORT_FEC_TYPE_FC: - fec->active_fec = ETHTOOL_FEC_BASER; - fec->fec = ETHTOOL_FEC_BASER; - break; + return ETHTOOL_FEC_BASER; + default: + return 0; } +} + +static int ionic_get_fecparam(struct net_device *netdev, + struct ethtool_fecparam *fec) +{ + struct ionic_port_info *port_info; + struct ionic_lif *lif; + u8 config_fec_type; + + lif = netdev_priv(netdev); + port_info = lif->ionic->idev.port_info; + config_fec_type = port_info->config.fec_type; + + fec->active_fec = ionic_fec_type_to_ethtool(config_fec_type); + fec->fec = ionic_fec_type_to_ethtool(config_fec_type); return 0; } -- 2.43.0