aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/ice/ice_main.c
diff options
context:
space:
mode:
authorBruce Allan <bruce.w.allan@intel.com>2019-02-08 15:50:31 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2019-02-25 11:56:01 -0500
commitc6dfd690f1c333475db1833ef3b5a4f4d6ba7365 (patch)
treed41b3c08e8631325ebee244f0da68c159cc9c6f4 /drivers/net/ethernet/intel/ice/ice_main.c
parent0e8fd74df2f37e2dcc305ed22f4feb8587b91929 (diff)
ice: sizeof(<type>) should be avoided
With sizeof(), it is preferable to use the variable of type <type> instead of sizeof(<type>). There are multiple places where a temporary variable is used to hold a 'size' value which is then used for a subsequent alloc/memset. Get rid of the temporary variable by calculating size as part of the alloc/memset statement. Also remove unnecessary type-cast. Signed-off-by: Bruce Allan <bruce.w.allan@intel.com> Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/ice/ice_main.c')
-rw-r--r--drivers/net/ethernet/intel/ice/ice_main.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 9d266d754445..0731b8994958 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -1513,8 +1513,8 @@ static int ice_cfg_netdev(struct ice_vsi *vsi)
1513 u8 mac_addr[ETH_ALEN]; 1513 u8 mac_addr[ETH_ALEN];
1514 int err; 1514 int err;
1515 1515
1516 netdev = alloc_etherdev_mqs(sizeof(struct ice_netdev_priv), 1516 netdev = alloc_etherdev_mqs(sizeof(*np), vsi->alloc_txq,
1517 vsi->alloc_txq, vsi->alloc_rxq); 1517 vsi->alloc_rxq);
1518 if (!netdev) 1518 if (!netdev)
1519 return -ENOMEM; 1519 return -ENOMEM;
1520 1520
@@ -1867,7 +1867,7 @@ static int ice_ena_msix_range(struct ice_pf *pf)
1867 v_left -= pf->num_lan_msix; 1867 v_left -= pf->num_lan_msix;
1868 1868
1869 pf->msix_entries = devm_kcalloc(&pf->pdev->dev, v_budget, 1869 pf->msix_entries = devm_kcalloc(&pf->pdev->dev, v_budget,
1870 sizeof(struct msix_entry), GFP_KERNEL); 1870 sizeof(*pf->msix_entries), GFP_KERNEL);
1871 1871
1872 if (!pf->msix_entries) { 1872 if (!pf->msix_entries) {
1873 err = -ENOMEM; 1873 err = -ENOMEM;
@@ -1955,7 +1955,6 @@ static void ice_clear_interrupt_scheme(struct ice_pf *pf)
1955static int ice_init_interrupt_scheme(struct ice_pf *pf) 1955static int ice_init_interrupt_scheme(struct ice_pf *pf)
1956{ 1956{
1957 int vectors = 0, hw_vectors = 0; 1957 int vectors = 0, hw_vectors = 0;
1958 ssize_t size;
1959 1958
1960 if (test_bit(ICE_FLAG_MSIX_ENA, pf->flags)) 1959 if (test_bit(ICE_FLAG_MSIX_ENA, pf->flags))
1961 vectors = ice_ena_msix_range(pf); 1960 vectors = ice_ena_msix_range(pf);
@@ -1966,9 +1965,9 @@ static int ice_init_interrupt_scheme(struct ice_pf *pf)
1966 return vectors; 1965 return vectors;
1967 1966
1968 /* set up vector assignment tracking */ 1967 /* set up vector assignment tracking */
1969 size = sizeof(struct ice_res_tracker) + (sizeof(u16) * vectors); 1968 pf->sw_irq_tracker =
1970 1969 devm_kzalloc(&pf->pdev->dev, sizeof(*pf->sw_irq_tracker) +
1971 pf->sw_irq_tracker = devm_kzalloc(&pf->pdev->dev, size, GFP_KERNEL); 1970 (sizeof(u16) * vectors), GFP_KERNEL);
1972 if (!pf->sw_irq_tracker) { 1971 if (!pf->sw_irq_tracker) {
1973 ice_dis_msix(pf); 1972 ice_dis_msix(pf);
1974 return -ENOMEM; 1973 return -ENOMEM;
@@ -1980,9 +1979,9 @@ static int ice_init_interrupt_scheme(struct ice_pf *pf)
1980 1979
1981 /* set up HW vector assignment tracking */ 1980 /* set up HW vector assignment tracking */
1982 hw_vectors = pf->hw.func_caps.common_cap.num_msix_vectors; 1981 hw_vectors = pf->hw.func_caps.common_cap.num_msix_vectors;
1983 size = sizeof(struct ice_res_tracker) + (sizeof(u16) * hw_vectors); 1982 pf->hw_irq_tracker =
1984 1983 devm_kzalloc(&pf->pdev->dev, sizeof(*pf->hw_irq_tracker) +
1985 pf->hw_irq_tracker = devm_kzalloc(&pf->pdev->dev, size, GFP_KERNEL); 1984 (sizeof(u16) * hw_vectors), GFP_KERNEL);
1986 if (!pf->hw_irq_tracker) { 1985 if (!pf->hw_irq_tracker) {
1987 ice_clear_interrupt_scheme(pf); 1986 ice_clear_interrupt_scheme(pf);
1988 return -ENOMEM; 1987 return -ENOMEM;
@@ -2116,7 +2115,7 @@ static int ice_probe(struct pci_dev *pdev,
2116 } 2115 }
2117 2116
2118 pf->vsi = devm_kcalloc(&pdev->dev, pf->num_alloc_vsi, 2117 pf->vsi = devm_kcalloc(&pdev->dev, pf->num_alloc_vsi,
2119 sizeof(struct ice_vsi *), GFP_KERNEL); 2118 sizeof(*pf->vsi), GFP_KERNEL);
2120 if (!pf->vsi) { 2119 if (!pf->vsi) {
2121 err = -ENOMEM; 2120 err = -ENOMEM;
2122 goto err_init_pf_unroll; 2121 goto err_init_pf_unroll;
@@ -2148,7 +2147,7 @@ static int ice_probe(struct pci_dev *pdev,
2148 } 2147 }
2149 2148
2150 /* create switch struct for the switch element created by FW on boot */ 2149 /* create switch struct for the switch element created by FW on boot */
2151 pf->first_sw = devm_kzalloc(&pdev->dev, sizeof(struct ice_sw), 2150 pf->first_sw = devm_kzalloc(&pdev->dev, sizeof(*pf->first_sw),
2152 GFP_KERNEL); 2151 GFP_KERNEL);
2153 if (!pf->first_sw) { 2152 if (!pf->first_sw) {
2154 err = -ENOMEM; 2153 err = -ENOMEM;