Skip to content

Commit

Permalink
net: make ndo_get_stats64 a void function
Browse files Browse the repository at this point in the history
The network device operation for reading statistics is only called
in one place, and it ignores the return value. Having a structure
return value is potentially confusing because some future driver could
incorrectly assume that the return value was used.

Fix all drivers with ndo_get_stats64 to have a void function.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
stephen hemminger authored and David S. Miller committed Jan 8, 2017
1 parent 63c64de commit bc1f447
Show file tree
Hide file tree
Showing 82 changed files with 166 additions and 309 deletions.
10 changes: 4 additions & 6 deletions drivers/net/bonding/bond_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ static int lacp_fast;

static int bond_init(struct net_device *bond_dev);
static void bond_uninit(struct net_device *bond_dev);
static struct rtnl_link_stats64 *bond_get_stats(struct net_device *bond_dev,
struct rtnl_link_stats64 *stats);
static void bond_get_stats(struct net_device *bond_dev,
struct rtnl_link_stats64 *stats);
static void bond_slave_arr_handler(struct work_struct *work);
static bool bond_time_in_interval(struct bonding *bond, unsigned long last_act,
int mod);
Expand Down Expand Up @@ -3337,8 +3337,8 @@ static void bond_fold_stats(struct rtnl_link_stats64 *_res,
}
}

static struct rtnl_link_stats64 *bond_get_stats(struct net_device *bond_dev,
struct rtnl_link_stats64 *stats)
static void bond_get_stats(struct net_device *bond_dev,
struct rtnl_link_stats64 *stats)
{
struct bonding *bond = netdev_priv(bond_dev);
struct rtnl_link_stats64 temp;
Expand All @@ -3362,8 +3362,6 @@ static struct rtnl_link_stats64 *bond_get_stats(struct net_device *bond_dev,

memcpy(&bond->bond_stats, stats, sizeof(*stats));
spin_unlock(&bond->stats_lock);

return stats;
}

static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd)
Expand Down
5 changes: 2 additions & 3 deletions drivers/net/dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ struct pcpu_dstats {
struct u64_stats_sync syncp;
};

static struct rtnl_link_stats64 *dummy_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *stats)
static void dummy_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *stats)
{
int i;

Expand All @@ -73,7 +73,6 @@ static struct rtnl_link_stats64 *dummy_get_stats64(struct net_device *dev,
stats->tx_bytes += tbytes;
stats->tx_packets += tpackets;
}
return stats;
}

static netdev_tx_t dummy_xmit(struct sk_buff *skb, struct net_device *dev)
Expand Down
6 changes: 2 additions & 4 deletions drivers/net/ethernet/alacritech/slicoss.c
Original file line number Diff line number Diff line change
Expand Up @@ -1471,8 +1471,8 @@ static netdev_tx_t slic_xmit(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_OK;
}

static struct rtnl_link_stats64 *slic_get_stats(struct net_device *dev,
struct rtnl_link_stats64 *lst)
static void slic_get_stats(struct net_device *dev,
struct rtnl_link_stats64 *lst)
{
struct slic_device *sdev = netdev_priv(dev);
struct slic_stats *stats = &sdev->stats;
Expand All @@ -1489,8 +1489,6 @@ static struct rtnl_link_stats64 *slic_get_stats(struct net_device *dev,
SLIC_GET_STATS_COUNTER(lst->rx_crc_errors, stats, rx_crc);
SLIC_GET_STATS_COUNTER(lst->rx_fifo_errors, stats, rx_oflow802);
SLIC_GET_STATS_COUNTER(lst->tx_carrier_errors, stats, tx_carrier);

return lst;
}

static int slic_get_sset_count(struct net_device *dev, int sset)
Expand Down
10 changes: 4 additions & 6 deletions drivers/net/ethernet/amazon/ena/ena_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2165,19 +2165,19 @@ static void ena_config_debug_area(struct ena_adapter *adapter)
ena_com_delete_debug_area(adapter->ena_dev);
}

static struct rtnl_link_stats64 *ena_get_stats64(struct net_device *netdev,
struct rtnl_link_stats64 *stats)
static void ena_get_stats64(struct net_device *netdev,
struct rtnl_link_stats64 *stats)
{
struct ena_adapter *adapter = netdev_priv(netdev);
struct ena_admin_basic_stats ena_stats;
int rc;

if (!test_bit(ENA_FLAG_DEV_UP, &adapter->flags))
return NULL;
return;

rc = ena_com_get_dev_basic_stats(adapter->ena_dev, &ena_stats);
if (rc)
return NULL;
return;

stats->tx_bytes = ((u64)ena_stats.tx_bytes_high << 32) |
ena_stats.tx_bytes_low;
Expand All @@ -2204,8 +2204,6 @@ static struct rtnl_link_stats64 *ena_get_stats64(struct net_device *netdev,

stats->rx_errors = 0;
stats->tx_errors = 0;

return stats;
}

static const struct net_device_ops ena_netdev_ops = {
Expand Down
6 changes: 2 additions & 4 deletions drivers/net/ethernet/amd/xgbe/xgbe-drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1759,8 +1759,8 @@ static void xgbe_tx_timeout(struct net_device *netdev)
schedule_work(&pdata->restart_work);
}

static struct rtnl_link_stats64 *xgbe_get_stats64(struct net_device *netdev,
struct rtnl_link_stats64 *s)
static void xgbe_get_stats64(struct net_device *netdev,
struct rtnl_link_stats64 *s)
{
struct xgbe_prv_data *pdata = netdev_priv(netdev);
struct xgbe_mmc_stats *pstats = &pdata->mmc_stats;
Expand All @@ -1786,8 +1786,6 @@ static struct rtnl_link_stats64 *xgbe_get_stats64(struct net_device *netdev,
s->tx_dropped = netdev->stats.tx_dropped;

DBGPR("<--%s\n", __func__);

return s;
}

static int xgbe_vlan_rx_add_vid(struct net_device *netdev, __be16 proto,
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/ethernet/apm/xgene/xgene_enet_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,7 @@ static int xgene_enet_create_desc_rings(struct net_device *ndev)
return ret;
}

static struct rtnl_link_stats64 *xgene_enet_get_stats64(
static void xgene_enet_get_stats64(
struct net_device *ndev,
struct rtnl_link_stats64 *storage)
{
Expand Down Expand Up @@ -1484,8 +1484,6 @@ static struct rtnl_link_stats64 *xgene_enet_get_stats64(
}
}
memcpy(storage, stats, sizeof(struct rtnl_link_stats64));

return storage;
}

static int xgene_enet_set_mac_address(struct net_device *ndev, void *addr)
Expand Down
6 changes: 2 additions & 4 deletions drivers/net/ethernet/atheros/alx/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1643,8 +1643,8 @@ static void alx_poll_controller(struct net_device *netdev)
}
#endif

static struct rtnl_link_stats64 *alx_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *net_stats)
static void alx_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *net_stats)
{
struct alx_priv *alx = netdev_priv(dev);
struct alx_hw_stats *hw_stats = &alx->hw.stats;
Expand Down Expand Up @@ -1688,8 +1688,6 @@ static struct rtnl_link_stats64 *alx_get_stats64(struct net_device *dev,
net_stats->rx_packets = hw_stats->rx_ok + net_stats->rx_errors;

spin_unlock(&alx->stats_lock);

return net_stats;
}

static const struct net_device_ops alx_netdev_ops = {
Expand Down
5 changes: 2 additions & 3 deletions drivers/net/ethernet/broadcom/b44.c
Original file line number Diff line number Diff line change
Expand Up @@ -1674,8 +1674,8 @@ static int b44_close(struct net_device *dev)
return 0;
}

static struct rtnl_link_stats64 *b44_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *nstat)
static void b44_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *nstat)
{
struct b44 *bp = netdev_priv(dev);
struct b44_hw_stats *hwstat = &bp->hw_stats;
Expand Down Expand Up @@ -1718,7 +1718,6 @@ static struct rtnl_link_stats64 *b44_get_stats64(struct net_device *dev,
#endif
} while (u64_stats_fetch_retry_irq(&hwstat->syncp, start));

return nstat;
}

static int __b44_load_mcast(struct b44 *bp, struct net_device *dev)
Expand Down
5 changes: 2 additions & 3 deletions drivers/net/ethernet/broadcom/bnx2.c
Original file line number Diff line number Diff line change
Expand Up @@ -6821,13 +6821,13 @@ bnx2_save_stats(struct bnx2 *bp)
(unsigned long) (bp->stats_blk->ctr + \
bp->temp_stats_blk->ctr)

static struct rtnl_link_stats64 *
static void
bnx2_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *net_stats)
{
struct bnx2 *bp = netdev_priv(dev);

if (bp->stats_blk == NULL)
return net_stats;
return;

net_stats->rx_packets =
GET_64BIT_NET_STATS(stat_IfHCInUcastPkts) +
Expand Down Expand Up @@ -6891,7 +6891,6 @@ bnx2_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *net_stats)
GET_32BIT_NET_STATS(stat_IfInMBUFDiscards) +
GET_32BIT_NET_STATS(stat_FwRxDrop);

return net_stats;
}

/* All ethtool functions called with rtnl_lock */
Expand Down
6 changes: 2 additions & 4 deletions drivers/net/ethernet/broadcom/bnxt/bnxt.c
Original file line number Diff line number Diff line change
Expand Up @@ -5879,7 +5879,7 @@ static int bnxt_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
return -EOPNOTSUPP;
}

static struct rtnl_link_stats64 *
static void
bnxt_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
{
u32 i;
Expand All @@ -5888,7 +5888,7 @@ bnxt_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
memset(stats, 0, sizeof(struct rtnl_link_stats64));

if (!bp->bnapi)
return stats;
return;

/* TODO check if we need to synchronize with bnxt_close path */
for (i = 0; i < bp->cp_nr_rings; i++) {
Expand Down Expand Up @@ -5935,8 +5935,6 @@ bnxt_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
stats->tx_fifo_errors = le64_to_cpu(tx->tx_fifo_underruns);
stats->tx_errors = le64_to_cpu(tx->tx_err);
}

return stats;
}

static bool bnxt_mc_list_updated(struct bnxt *bp, u32 *rx_mask)
Expand Down
8 changes: 3 additions & 5 deletions drivers/net/ethernet/broadcom/tg3.c
Original file line number Diff line number Diff line change
Expand Up @@ -14142,22 +14142,20 @@ static const struct ethtool_ops tg3_ethtool_ops = {
.set_link_ksettings = tg3_set_link_ksettings,
};

static struct rtnl_link_stats64 *tg3_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *stats)
static void tg3_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *stats)
{
struct tg3 *tp = netdev_priv(dev);

spin_lock_bh(&tp->lock);
if (!tp->hw_stats) {
*stats = tp->net_stats_prev;
spin_unlock_bh(&tp->lock);
return stats;
return;
}

tg3_get_nstats(tp, stats);
spin_unlock_bh(&tp->lock);

return stats;
}

static void tg3_set_rx_mode(struct net_device *dev)
Expand Down
6 changes: 2 additions & 4 deletions drivers/net/ethernet/brocade/bna/bnad.c
Original file line number Diff line number Diff line change
Expand Up @@ -3111,7 +3111,7 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev)
* Used spin_lock to synchronize reading of stats structures, which
* is written by BNA under the same lock.
*/
static struct rtnl_link_stats64 *
static void
bnad_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
{
struct bnad *bnad = netdev_priv(netdev);
Expand All @@ -3123,8 +3123,6 @@ bnad_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
bnad_netdev_hwstats_fill(bnad, stats);

spin_unlock_irqrestore(&bnad->bna_lock, flags);

return stats;
}

static void
Expand Down Expand Up @@ -3427,7 +3425,7 @@ static const struct net_device_ops bnad_netdev_ops = {
.ndo_open = bnad_open,
.ndo_stop = bnad_stop,
.ndo_start_xmit = bnad_start_xmit,
.ndo_get_stats64 = bnad_get_stats64,
.ndo_get_stats64 = bnad_get_stats64,
.ndo_set_rx_mode = bnad_set_rx_mode,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = bnad_set_mac_address,
Expand Down
5 changes: 2 additions & 3 deletions drivers/net/ethernet/calxeda/xgmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1446,9 +1446,9 @@ static void xgmac_poll_controller(struct net_device *dev)
}
#endif

static struct rtnl_link_stats64 *
static void
xgmac_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *storage)
struct rtnl_link_stats64 *storage)
{
struct xgmac_priv *priv = netdev_priv(dev);
void __iomem *base = priv->base;
Expand Down Expand Up @@ -1476,7 +1476,6 @@ xgmac_get_stats64(struct net_device *dev,

writel(0, base + XGMAC_MMC_CTRL);
spin_unlock_bh(&priv->stats_lock);
return storage;
}

static int xgmac_set_mac_address(struct net_device *dev, void *p)
Expand Down
5 changes: 2 additions & 3 deletions drivers/net/ethernet/cavium/thunder/nicvf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1461,8 +1461,8 @@ void nicvf_update_stats(struct nicvf *nic)
nicvf_update_sq_stats(nic, qidx);
}

static struct rtnl_link_stats64 *nicvf_get_stats64(struct net_device *netdev,
struct rtnl_link_stats64 *stats)
static void nicvf_get_stats64(struct net_device *netdev,
struct rtnl_link_stats64 *stats)
{
struct nicvf *nic = netdev_priv(netdev);
struct nicvf_hw_stats *hw_stats = &nic->hw_stats;
Expand All @@ -1478,7 +1478,6 @@ static struct rtnl_link_stats64 *nicvf_get_stats64(struct net_device *netdev,
stats->tx_packets = hw_stats->tx_frames;
stats->tx_dropped = hw_stats->tx_drops;

return stats;
}

static void nicvf_tx_timeout(struct net_device *dev)
Expand Down
7 changes: 3 additions & 4 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2375,8 +2375,8 @@ int cxgb4_remove_server_filter(const struct net_device *dev, unsigned int stid,
}
EXPORT_SYMBOL(cxgb4_remove_server_filter);

static struct rtnl_link_stats64 *cxgb_get_stats(struct net_device *dev,
struct rtnl_link_stats64 *ns)
static void cxgb_get_stats(struct net_device *dev,
struct rtnl_link_stats64 *ns)
{
struct port_stats stats;
struct port_info *p = netdev_priv(dev);
Expand All @@ -2389,7 +2389,7 @@ static struct rtnl_link_stats64 *cxgb_get_stats(struct net_device *dev,
spin_lock(&adapter->stats_lock);
if (!netif_device_present(dev)) {
spin_unlock(&adapter->stats_lock);
return ns;
return;
}
t4_get_port_stats_offset(adapter, p->tx_chan, &stats,
&p->stats_base);
Expand Down Expand Up @@ -2423,7 +2423,6 @@ static struct rtnl_link_stats64 *cxgb_get_stats(struct net_device *dev,
ns->tx_errors = stats.tx_error_frames;
ns->rx_errors = stats.rx_symbol_err + stats.rx_fcs_err +
ns->rx_length_errors + stats.rx_len_err + ns->rx_fifo_errors;
return ns;
}

static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
Expand Down
8 changes: 3 additions & 5 deletions drivers/net/ethernet/cisco/enic/enic_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,8 @@ static netdev_tx_t enic_hard_start_xmit(struct sk_buff *skb,
}

/* dev_base_lock rwlock held, nominally process context */
static struct rtnl_link_stats64 *enic_get_stats(struct net_device *netdev,
struct rtnl_link_stats64 *net_stats)
static void enic_get_stats(struct net_device *netdev,
struct rtnl_link_stats64 *net_stats)
{
struct enic *enic = netdev_priv(netdev);
struct vnic_stats *stats;
Expand All @@ -693,7 +693,7 @@ static struct rtnl_link_stats64 *enic_get_stats(struct net_device *netdev,
* recorded stats.
*/
if (err == -ENOMEM)
return net_stats;
return;

net_stats->tx_packets = stats->tx.tx_frames_ok;
net_stats->tx_bytes = stats->tx.tx_bytes_ok;
Expand All @@ -707,8 +707,6 @@ static struct rtnl_link_stats64 *enic_get_stats(struct net_device *netdev,
net_stats->rx_over_errors = enic->rq_truncated_pkts;
net_stats->rx_crc_errors = enic->rq_bad_fcs;
net_stats->rx_dropped = stats->rx.rx_no_bufs + stats->rx.rx_drop;

return net_stats;
}

static int enic_mc_sync(struct net_device *netdev, const u8 *mc_addr)
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/ethernet/ec_bhf.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ static int ec_bhf_stop(struct net_device *net_dev)
return 0;
}

static struct rtnl_link_stats64 *
static void
ec_bhf_get_stats(struct net_device *net_dev,
struct rtnl_link_stats64 *stats)
{
Expand All @@ -472,8 +472,6 @@ ec_bhf_get_stats(struct net_device *net_dev,

stats->tx_bytes = priv->stat_tx_bytes;
stats->rx_bytes = priv->stat_rx_bytes;

return stats;
}

static const struct net_device_ops ec_bhf_netdev_ops = {
Expand Down
Loading

0 comments on commit bc1f447

Please sign in to comment.