From patchwork Tue Aug 3 16:36:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 12416767 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 546BCC432BE for ; Tue, 3 Aug 2021 16:37:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 400806105A for ; Tue, 3 Aug 2021 16:37:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233711AbhHCQhV (ORCPT ); Tue, 3 Aug 2021 12:37:21 -0400 Received: from mga11.intel.com ([192.55.52.93]:33456 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233671AbhHCQhU (ORCPT ); Tue, 3 Aug 2021 12:37:20 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10065"; a="210621129" X-IronPort-AV: E=Sophos;i="5.84,292,1620716400"; d="scan'208";a="210621129" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2021 09:37:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,292,1620716400"; d="scan'208";a="670507815" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by fmsmga005.fm.intel.com with ESMTP; 03 Aug 2021 09:36:52 -0700 Received: from alobakin-mobl.ger.corp.intel.com (eflejszm-mobl2.ger.corp.intel.com [10.213.26.164]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 173GahEp029968; Tue, 3 Aug 2021 17:36:48 +0100 From: Alexander Lobakin To: "David S. Miller" , Jakub Kicinski Cc: Alexander Lobakin , Jesse Brandeburg , Lukasz Czapnik , Marcin Kubiak , Michal Kubiak , Michal Swiatkowski , Jonathan Corbet , Netanel Belgazal , Arthur Kiyanovski , Guy Tzalik , Saeed Bishara , Ioana Ciornei , Claudiu Manoil , Thomas Petazzoni , Marcin Wojtas , Russell King , Edward Cree , Martin Habets , "Michael S. Tsirkin" , Jason Wang , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Shay Agroskin , Sameeh Jubran , Alexander Duyck , Danielle Ratson , Ido Schimmel , Andrew Lunn , Vladyslav Tarasiuk , Arnd Bergmann , Andrew Morton , Jian Shen , Petr Vorel , Dan Murphy , Yangbo Lu , Michal Kubecek , Zheng Yongjun , Heiner Kallweit , YueHaibing , Johannes Berg , netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, bpf@vger.kernel.org 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 Message-Id: <20210803163641.3743-2-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210803163641.3743-1-alexandr.lobakin@intel.com> References: <20210803163641.3743-1-alexandr.lobakin@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Jesse Brandeburg --- 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;