aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2013-02-03 12:43:58 -0500
committerDavid S. Miller <davem@davemloft.net>2013-02-04 13:22:33 -0500
commitb2adaca92c63b9bb8beb021d554f656e387a7648 (patch)
treeec0ca7c14267dc090435ddbefe29b110912b851f /drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c
parent09da6c5f60ad2e2018366e47192a9ddbccfb3ac5 (diff)
ethernet: Remove unnecessary alloc/OOM messages, alloc cleanups
alloc failures already get standardized OOM messages and a dump_stack. Convert kzalloc's with multiplies to kcalloc. Convert kmalloc's with multiplies to kmalloc_array. Fix a few whitespace defects. Convert a constant 6 to ETH_ALEN. Use parentheses around sizeof. Convert vmalloc/memset to vzalloc. Remove now unused size variables. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c')
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c
index aa71ebaefdc0..10ad25d7aa0e 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c
@@ -184,18 +184,15 @@ int qlcnic_alloc_sw_resources(struct qlcnic_adapter *adapter)
184 struct qlcnic_host_rds_ring *rds_ring; 184 struct qlcnic_host_rds_ring *rds_ring;
185 struct qlcnic_host_sds_ring *sds_ring; 185 struct qlcnic_host_sds_ring *sds_ring;
186 struct qlcnic_rx_buffer *rx_buf; 186 struct qlcnic_rx_buffer *rx_buf;
187 int ring, i, size; 187 int ring, i;
188
189 struct net_device *netdev = adapter->netdev;
190 188
191 recv_ctx = adapter->recv_ctx; 189 recv_ctx = adapter->recv_ctx;
192 190
193 size = adapter->max_rds_rings * sizeof(struct qlcnic_host_rds_ring); 191 rds_ring = kcalloc(adapter->max_rds_rings,
194 rds_ring = kzalloc(size, GFP_KERNEL); 192 sizeof(struct qlcnic_host_rds_ring), GFP_KERNEL);
195 if (rds_ring == NULL) { 193 if (rds_ring == NULL)
196 dev_err(&netdev->dev, "failed to allocate rds ring struct\n");
197 goto err_out; 194 goto err_out;
198 } 195
199 recv_ctx->rds_rings = rds_ring; 196 recv_ctx->rds_rings = rds_ring;
200 197
201 for (ring = 0; ring < adapter->max_rds_rings; ring++) { 198 for (ring = 0; ring < adapter->max_rds_rings; ring++) {
@@ -221,11 +218,8 @@ int qlcnic_alloc_sw_resources(struct qlcnic_adapter *adapter)
221 break; 218 break;
222 } 219 }
223 rds_ring->rx_buf_arr = vzalloc(RCV_BUFF_RINGSIZE(rds_ring)); 220 rds_ring->rx_buf_arr = vzalloc(RCV_BUFF_RINGSIZE(rds_ring));
224 if (rds_ring->rx_buf_arr == NULL) { 221 if (rds_ring->rx_buf_arr == NULL)
225 dev_err(&netdev->dev,
226 "Failed to allocate rx buffer ring %d\n", ring);
227 goto err_out; 222 goto err_out;
228 }
229 223
230 INIT_LIST_HEAD(&rds_ring->free_list); 224 INIT_LIST_HEAD(&rds_ring->free_list);
231 /* 225 /*
@@ -448,10 +442,8 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter)
448 } 442 }
449 443
450 buf = kcalloc(n, sizeof(struct crb_addr_pair), GFP_KERNEL); 444 buf = kcalloc(n, sizeof(struct crb_addr_pair), GFP_KERNEL);
451 if (buf == NULL) { 445 if (buf == NULL)
452 dev_err(&pdev->dev, "Unable to calloc memory for rom read.\n");
453 return -ENOMEM; 446 return -ENOMEM;
454 }
455 447
456 for (i = 0; i < n; i++) { 448 for (i = 0; i < n; i++) {
457 if (qlcnic_rom_fast_read(adapter, 8*i + 4*offset, &val) != 0 || 449 if (qlcnic_rom_fast_read(adapter, 8*i + 4*offset, &val) != 0 ||
@@ -657,10 +649,8 @@ static int qlcnic_get_flt_entry(struct qlcnic_adapter *adapter, u8 region,
657 649
658 entry_size = flt_hdr.len - sizeof(struct qlcnic_flt_header); 650 entry_size = flt_hdr.len - sizeof(struct qlcnic_flt_header);
659 flt_entry = vzalloc(entry_size); 651 flt_entry = vzalloc(entry_size);
660 if (flt_entry == NULL) { 652 if (flt_entry == NULL)
661 dev_warn(&adapter->pdev->dev, "error allocating memory\n");
662 return -EIO; 653 return -EIO;
663 }
664 654
665 ret = qlcnic_rom_fast_read_words(adapter, QLCNIC_FLT_LOCATION + 655 ret = qlcnic_rom_fast_read_words(adapter, QLCNIC_FLT_LOCATION +
666 sizeof(struct qlcnic_flt_header), 656 sizeof(struct qlcnic_flt_header),