aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2009-09-05 23:24:48 -0400
committerRoland Dreier <rolandd@cisco.com>2009-09-05 23:24:48 -0400
commita01df0fe5e4db8c272dcc395354884ff7c15fc10 (patch)
tree849c1726aad78f51440e8718b252957a69b6a3b0
parente07cccf4046978df10f2e13fe2b99b2f9b3a65db (diff)
mlx4_core: Use pci_request_regions()
The old code used two calls to pci_request_region() to get the two BARs for the mlx4 device, for no particularly good reason. Clean up the code a little by converting this to a single call to pci_request_regions(). Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r--drivers/net/mlx4/main.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/drivers/net/mlx4/main.c b/drivers/net/mlx4/main.c
index dac621b1e9fc..5c1afe0d73e8 100644
--- a/drivers/net/mlx4/main.c
+++ b/drivers/net/mlx4/main.c
@@ -1070,18 +1070,12 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
1070 goto err_disable_pdev; 1070 goto err_disable_pdev;
1071 } 1071 }
1072 1072
1073 err = pci_request_region(pdev, 0, DRV_NAME); 1073 err = pci_request_regions(pdev, DRV_NAME);
1074 if (err) { 1074 if (err) {
1075 dev_err(&pdev->dev, "Cannot request control region, aborting.\n"); 1075 dev_err(&pdev->dev, "Couldn't get PCI resources, aborting\n");
1076 goto err_disable_pdev; 1076 goto err_disable_pdev;
1077 } 1077 }
1078 1078
1079 err = pci_request_region(pdev, 2, DRV_NAME);
1080 if (err) {
1081 dev_err(&pdev->dev, "Cannot request UAR region, aborting.\n");
1082 goto err_release_bar0;
1083 }
1084
1085 pci_set_master(pdev); 1079 pci_set_master(pdev);
1086 1080
1087 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64)); 1081 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
@@ -1090,7 +1084,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
1090 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 1084 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
1091 if (err) { 1085 if (err) {
1092 dev_err(&pdev->dev, "Can't set PCI DMA mask, aborting.\n"); 1086 dev_err(&pdev->dev, "Can't set PCI DMA mask, aborting.\n");
1093 goto err_release_bar2; 1087 goto err_release_regions;
1094 } 1088 }
1095 } 1089 }
1096 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); 1090 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
@@ -1101,7 +1095,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
1101 if (err) { 1095 if (err) {
1102 dev_err(&pdev->dev, "Can't set consistent PCI DMA mask, " 1096 dev_err(&pdev->dev, "Can't set consistent PCI DMA mask, "
1103 "aborting.\n"); 1097 "aborting.\n");
1104 goto err_release_bar2; 1098 goto err_release_regions;
1105 } 1099 }
1106 } 1100 }
1107 1101
@@ -1110,7 +1104,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
1110 dev_err(&pdev->dev, "Device struct alloc failed, " 1104 dev_err(&pdev->dev, "Device struct alloc failed, "
1111 "aborting.\n"); 1105 "aborting.\n");
1112 err = -ENOMEM; 1106 err = -ENOMEM;
1113 goto err_release_bar2; 1107 goto err_release_regions;
1114 } 1108 }
1115 1109
1116 dev = &priv->dev; 1110 dev = &priv->dev;
@@ -1205,11 +1199,8 @@ err_cmd:
1205err_free_dev: 1199err_free_dev:
1206 kfree(priv); 1200 kfree(priv);
1207 1201
1208err_release_bar2: 1202err_release_regions:
1209 pci_release_region(pdev, 2); 1203 pci_release_regions(pdev);
1210
1211err_release_bar0:
1212 pci_release_region(pdev, 0);
1213 1204
1214err_disable_pdev: 1205err_disable_pdev:
1215 pci_disable_device(pdev); 1206 pci_disable_device(pdev);
@@ -1265,8 +1256,7 @@ static void mlx4_remove_one(struct pci_dev *pdev)
1265 pci_disable_msix(pdev); 1256 pci_disable_msix(pdev);
1266 1257
1267 kfree(priv); 1258 kfree(priv);
1268 pci_release_region(pdev, 2); 1259 pci_release_regions(pdev);
1269 pci_release_region(pdev, 0);
1270 pci_disable_device(pdev); 1260 pci_disable_device(pdev);
1271 pci_set_drvdata(pdev, NULL); 1261 pci_set_drvdata(pdev, NULL);
1272 } 1262 }