Skip to content

Commit

Permalink
i40e: better return values
Browse files Browse the repository at this point in the history
As mentioned by Joe Perches, clean up return values in some functions
making sure to have consistent return types, not mixing types.

A couple of Joe's comments suggested returning void, but since
the functions in question are ndo defined, the return values are fixed.
So make a comment in the header that notes this is a function called by
net_device_ops.

v2: fix post increment bug in return

CC: Joe Perches <joe@perches.com>
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Kavindya Deegala <kavindya.s.deegala@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
  • Loading branch information
Jesse Brandeburg authored and Jeff Kirsher committed Sep 27, 2013
1 parent dcae29b commit 078b587
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions drivers/net/ethernet/intel/i40e/i40e_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1787,6 +1787,8 @@ int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid)
* i40e_vsi_kill_vlan - Remove vsi membership for given vlan
* @vsi: the vsi being configured
* @vid: vlan id to be removed (0 = untagged only , -1 = any)
*
* Return: 0 on success or negative otherwise
**/
int i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid)
{
Expand Down Expand Up @@ -1860,53 +1862,56 @@ int i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid)
* i40e_vlan_rx_add_vid - Add a vlan id filter to HW offload
* @netdev: network interface to be adjusted
* @vid: vlan id to be added
*
* net_device_ops implementation for adding vlan ids
**/
static int i40e_vlan_rx_add_vid(struct net_device *netdev,
__always_unused __be16 proto, u16 vid)
{
struct i40e_netdev_priv *np = netdev_priv(netdev);
struct i40e_vsi *vsi = np->vsi;
int ret;
int ret = 0;

if (vid > 4095)
return 0;
return -EINVAL;

netdev_info(netdev, "adding %pM vid=%d\n", netdev->dev_addr, vid);

netdev_info(vsi->netdev, "adding %pM vid=%d\n",
netdev->dev_addr, vid);
/* If the network stack called us with vid = 0, we should
* indicate to i40e_vsi_add_vlan() that we want to receive
* any traffic (i.e. with any vlan tag, or untagged)
*/
ret = i40e_vsi_add_vlan(vsi, vid ? vid : I40E_VLAN_ANY);

if (!ret) {
if (vid < VLAN_N_VID)
set_bit(vid, vsi->active_vlans);
}
if (!ret && (vid < VLAN_N_VID))
set_bit(vid, vsi->active_vlans);

return 0;
return ret;
}

/**
* i40e_vlan_rx_kill_vid - Remove a vlan id filter from HW offload
* @netdev: network interface to be adjusted
* @vid: vlan id to be removed
*
* net_device_ops implementation for adding vlan ids
**/
static int i40e_vlan_rx_kill_vid(struct net_device *netdev,
__always_unused __be16 proto, u16 vid)
{
struct i40e_netdev_priv *np = netdev_priv(netdev);
struct i40e_vsi *vsi = np->vsi;

netdev_info(vsi->netdev, "removing %pM vid=%d\n",
netdev->dev_addr, vid);
netdev_info(netdev, "removing %pM vid=%d\n", netdev->dev_addr, vid);

/* return code is ignored as there is nothing a user
* can do about failure to remove and a log message was
* already printed from another function
* already printed from the other function
*/
i40e_vsi_kill_vlan(vsi, vid);

clear_bit(vid, vsi->active_vlans);

return 0;
}

Expand Down Expand Up @@ -3324,7 +3329,8 @@ static void i40e_pf_unquiesce_all_vsi(struct i40e_pf *pf)
**/
static u8 i40e_dcb_get_num_tc(struct i40e_dcbx_config *dcbcfg)
{
int num_tc = 0, i;
u8 num_tc = 0;
int i;

/* Scan the ETS Config Priority Table to find
* traffic class enabled for a given priority
Expand All @@ -3339,9 +3345,7 @@ static u8 i40e_dcb_get_num_tc(struct i40e_dcbx_config *dcbcfg)
/* Traffic class index starts from zero so
* increment to return the actual count
*/
num_tc++;

return num_tc;
return num_tc + 1;
}

/**
Expand Down Expand Up @@ -3491,6 +3495,7 @@ static int i40e_vsi_get_bw_info(struct i40e_vsi *vsi)
/* 3 bits out of 4 for each TC */
vsi->bw_ets_max_quanta[i] = (u8)((tc_bw_max >> (i*4)) & 0x7);
}

return 0;
}

Expand Down

0 comments on commit 078b587

Please sign in to comment.