Messages in this thread Patch in this message | | | From | Alexander Lobakin <> | Subject | [PATCH net-next 01/21] ethtool, stats: use a shorthand pointer in stats_prepare_data() | Date | Tue, 3 Aug 2021 18:36:21 +0200 |
| |
Just place dev->ethtool_ops on the stack and use it instead of dereferencing the former a bunch of times to improve code readability.
Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com> Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com> --- net/ethtool/stats.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/net/ethtool/stats.c b/net/ethtool/stats.c index ec07f5765e03..e35c87206b4c 100644 --- a/net/ethtool/stats.c +++ b/net/ethtool/stats.c @@ -108,12 +108,15 @@ static int stats_prepare_data(const struct ethnl_req_info *req_base, const struct stats_req_info *req_info = STATS_REQINFO(req_base); struct stats_reply_data *data = STATS_REPDATA(reply_base); struct net_device *dev = reply_base->dev; + const struct ethtool_ops *ops; int ret; ret = ethnl_ops_begin(dev); if (ret < 0) return ret; + ops = dev->ethtool_ops; + /* Mark all stats as unset (see ETHTOOL_STAT_NOT_SET) to prevent them * from being reported to user space in case driver did not set them. */ @@ -123,18 +126,17 @@ static int stats_prepare_data(const struct ethnl_req_info *req_base, memset(&data->rmon_stats, 0xff, sizeof(data->rmon_stats)); if (test_bit(ETHTOOL_STATS_ETH_PHY, req_info->stat_mask) && - dev->ethtool_ops->get_eth_phy_stats) - dev->ethtool_ops->get_eth_phy_stats(dev, &data->phy_stats); + ops->get_eth_phy_stats) + ops->get_eth_phy_stats(dev, &data->phy_stats); if (test_bit(ETHTOOL_STATS_ETH_MAC, req_info->stat_mask) && - dev->ethtool_ops->get_eth_mac_stats) - dev->ethtool_ops->get_eth_mac_stats(dev, &data->mac_stats); + ops->get_eth_mac_stats) + ops->get_eth_mac_stats(dev, &data->mac_stats); if (test_bit(ETHTOOL_STATS_ETH_CTRL, req_info->stat_mask) && - dev->ethtool_ops->get_eth_ctrl_stats) - dev->ethtool_ops->get_eth_ctrl_stats(dev, &data->ctrl_stats); + ops->get_eth_ctrl_stats) + ops->get_eth_ctrl_stats(dev, &data->ctrl_stats); if (test_bit(ETHTOOL_STATS_RMON, req_info->stat_mask) && - dev->ethtool_ops->get_rmon_stats) - dev->ethtool_ops->get_rmon_stats(dev, &data->rmon_stats, - &data->rmon_ranges); + ops->get_rmon_stats) + ops->get_rmon_stats(dev, &data->rmon_stats, &data->rmon_ranges); ethnl_ops_complete(dev); return 0; -- 2.31.1
| |