aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDan Carpenter <error27@gmail.com>2010-08-09 17:47:56 -0400
committerDavid S. Miller <davem@davemloft.net>2010-08-10 04:34:36 -0400
commitca315ac22c1a91fc8047254b250599890d8a7b30 (patch)
tree814076c69d1779aa3fe04fd2b0c3c9a2e09aa054 /drivers
parent00c7d9202a19091d1873954ba158375d2efd5a64 (diff)
qlcnic: clean up qlcnic_init_pci_info()
In the original code we allocated memory conditionally and freed it in the error handling unconditionally. It turns out that this function is only called during initialization and "adapter->npars" and "adapter->eswitch" are always NULL at the start of the function. I removed those checks. Also since I was cleaning things, I changed the error handling for qlcnic_get_pci_info() and pulled everything in an indent level. Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/qlcnic/qlcnic_main.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c
index b9615bd745ea..6b8df55840c0 100644
--- a/drivers/net/qlcnic/qlcnic_main.c
+++ b/drivers/net/qlcnic/qlcnic_main.c
@@ -477,44 +477,45 @@ qlcnic_init_pci_info(struct qlcnic_adapter *adapter)
477 int i, ret = 0, err; 477 int i, ret = 0, err;
478 u8 pfn; 478 u8 pfn;
479 479
480 if (!adapter->npars) 480 adapter->npars = kzalloc(sizeof(struct qlcnic_npar_info) *
481 adapter->npars = kzalloc(sizeof(struct qlcnic_npar_info) *
482 QLCNIC_MAX_PCI_FUNC, GFP_KERNEL); 481 QLCNIC_MAX_PCI_FUNC, GFP_KERNEL);
483 if (!adapter->npars) 482 if (!adapter->npars)
484 return -ENOMEM; 483 return -ENOMEM;
485 484
486 if (!adapter->eswitch) 485 adapter->eswitch = kzalloc(sizeof(struct qlcnic_eswitch) *
487 adapter->eswitch = kzalloc(sizeof(struct qlcnic_eswitch) *
488 QLCNIC_NIU_MAX_XG_PORTS, GFP_KERNEL); 486 QLCNIC_NIU_MAX_XG_PORTS, GFP_KERNEL);
489 if (!adapter->eswitch) { 487 if (!adapter->eswitch) {
490 err = -ENOMEM; 488 err = -ENOMEM;
491 goto err_eswitch; 489 goto err_npars;
492 } 490 }
493 491
494 ret = qlcnic_get_pci_info(adapter, pci_info); 492 ret = qlcnic_get_pci_info(adapter, pci_info);
495 if (!ret) { 493 if (ret)
496 for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) { 494 goto err_eswitch;
497 pfn = pci_info[i].id;
498 if (pfn > QLCNIC_MAX_PCI_FUNC)
499 return QL_STATUS_INVALID_PARAM;
500 adapter->npars[pfn].active = pci_info[i].active;
501 adapter->npars[pfn].type = pci_info[i].type;
502 adapter->npars[pfn].phy_port = pci_info[i].default_port;
503 adapter->npars[pfn].mac_learning = DEFAULT_MAC_LEARN;
504 adapter->npars[pfn].min_bw = pci_info[i].tx_min_bw;
505 adapter->npars[pfn].max_bw = pci_info[i].tx_max_bw;
506 }
507
508 for (i = 0; i < QLCNIC_NIU_MAX_XG_PORTS; i++)
509 adapter->eswitch[i].flags |= QLCNIC_SWITCH_ENABLE;
510 495
511 return ret; 496 for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) {
497 pfn = pci_info[i].id;
498 if (pfn > QLCNIC_MAX_PCI_FUNC)
499 return QL_STATUS_INVALID_PARAM;
500 adapter->npars[pfn].active = pci_info[i].active;
501 adapter->npars[pfn].type = pci_info[i].type;
502 adapter->npars[pfn].phy_port = pci_info[i].default_port;
503 adapter->npars[pfn].mac_learning = DEFAULT_MAC_LEARN;
504 adapter->npars[pfn].min_bw = pci_info[i].tx_min_bw;
505 adapter->npars[pfn].max_bw = pci_info[i].tx_max_bw;
512 } 506 }
513 507
508 for (i = 0; i < QLCNIC_NIU_MAX_XG_PORTS; i++)
509 adapter->eswitch[i].flags |= QLCNIC_SWITCH_ENABLE;
510
511 return 0;
512
513err_eswitch:
514 kfree(adapter->eswitch); 514 kfree(adapter->eswitch);
515 adapter->eswitch = NULL; 515 adapter->eswitch = NULL;
516err_eswitch: 516err_npars:
517 kfree(adapter->npars); 517 kfree(adapter->npars);
518 adapter->npars = NULL;
518 519
519 return ret; 520 return ret;
520} 521}