aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorQuentin Lambert <lambert.quentin@gmail.com>2014-09-07 14:03:32 -0400
committerBjorn Helgaas <bhelgaas@google.com>2014-09-24 09:50:53 -0400
commit79e50e72986c9fcb06d707ce587cfd24fefa33e3 (patch)
tree1a21fd09d544924c1bc1417840a8569821820516 /drivers
parent656f978f9af9d8d77436e8159f51f7aa1e673309 (diff)
PCI: Remove assignment from "if" conditions
The following Coccinelle semantic patch was used to find and correct cases of assignments in "if" conditions: @@ expression var, expr; statement S; @@ + var = expr; if( - (var = expr) + var ) S Signed-off-by: Quentin Lambert <lambert.quentin@gmail.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pci/hotplug/acpi_pcihp.c3
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_core.c9
-rw-r--r--drivers/pci/hotplug/cpcihp_zt5550.c5
-rw-r--r--drivers/pci/hotplug/ibmphp_core.c15
-rw-r--r--drivers/pci/hotplug/ibmphp_pci.c6
-rw-r--r--drivers/pci/hotplug/ibmphp_res.c30
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c12
-rw-r--r--drivers/pci/hotplug/shpchp_hpc.c3
-rw-r--r--drivers/pci/pci.c13
9 files changed, 66 insertions, 30 deletions
diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c
index a94d850ae228..2cac54802567 100644
--- a/drivers/pci/hotplug/acpi_pcihp.c
+++ b/drivers/pci/hotplug/acpi_pcihp.c
@@ -433,7 +433,8 @@ int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle)
433{ 433{
434 acpi_handle bridge_handle, parent_handle; 434 acpi_handle bridge_handle, parent_handle;
435 435
436 if (!(bridge_handle = acpi_pci_get_bridge_handle(pbus))) 436 bridge_handle = acpi_pci_get_bridge_handle(pbus);
437 if (!bridge_handle)
437 return 0; 438 return 0;
438 if ((ACPI_FAILURE(acpi_get_parent(handle, &parent_handle)))) 439 if ((ACPI_FAILURE(acpi_get_parent(handle, &parent_handle))))
439 return 0; 440 return 0;
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
index 8359e29156ea..a5a7fd8332ac 100644
--- a/drivers/pci/hotplug/cpci_hotplug_core.c
+++ b/drivers/pci/hotplug/cpci_hotplug_core.c
@@ -125,7 +125,8 @@ disable_slot(struct hotplug_slot *hotplug_slot)
125 125
126 /* Unconfigure device */ 126 /* Unconfigure device */
127 dbg("%s - unconfiguring slot %s", __func__, slot_name(slot)); 127 dbg("%s - unconfiguring slot %s", __func__, slot_name(slot));
128 if ((retval = cpci_unconfigure_slot(slot))) { 128 retval = cpci_unconfigure_slot(slot);
129 if (retval) {
129 err("%s - could not unconfigure slot %s", 130 err("%s - could not unconfigure slot %s",
130 __func__, slot_name(slot)); 131 __func__, slot_name(slot));
131 goto disable_error; 132 goto disable_error;
@@ -141,9 +142,11 @@ disable_slot(struct hotplug_slot *hotplug_slot)
141 } 142 }
142 cpci_led_on(slot); 143 cpci_led_on(slot);
143 144
144 if (controller->ops->set_power) 145 if (controller->ops->set_power) {
145 if ((retval = controller->ops->set_power(slot, 0))) 146 retval = controller->ops->set_power(slot, 0);
147 if (retval)
146 goto disable_error; 148 goto disable_error;
149 }
147 150
148 if (update_adapter_status(slot->hotplug_slot, 0)) 151 if (update_adapter_status(slot->hotplug_slot, 0))
149 warn("failure to update adapter file"); 152 warn("failure to update adapter file");
diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
index cfd01e93e137..7ecf34e76a61 100644
--- a/drivers/pci/hotplug/cpcihp_zt5550.c
+++ b/drivers/pci/hotplug/cpcihp_zt5550.c
@@ -237,8 +237,9 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
237 dbg("registered controller"); 237 dbg("registered controller");
238 238
239 /* Look for first device matching cPCI bus's bridge vendor and device IDs */ 239 /* Look for first device matching cPCI bus's bridge vendor and device IDs */
240 if (!(bus0_dev = pci_get_device(PCI_VENDOR_ID_DEC, 240 bus0_dev = pci_get_device(PCI_VENDOR_ID_DEC,
241 PCI_DEVICE_ID_DEC_21154, NULL))) { 241 PCI_DEVICE_ID_DEC_21154, NULL);
242 if (!bus0_dev) {
242 status = -ENODEV; 243 status = -ENODEV;
243 goto init_register_error; 244 goto init_register_error;
244 } 245 }
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index cfe2afe6e7aa..3efaf4c38528 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -1023,7 +1023,8 @@ static int enable_slot(struct hotplug_slot *hs)
1023 debug("ENABLING SLOT........\n"); 1023 debug("ENABLING SLOT........\n");
1024 slot_cur = hs->private; 1024 slot_cur = hs->private;
1025 1025
1026 if ((rc = validate(slot_cur, ENABLE))) { 1026 rc = validate(slot_cur, ENABLE);
1027 if (rc) {
1027 err("validate function failed\n"); 1028 err("validate function failed\n");
1028 goto error_nopower; 1029 goto error_nopower;
1029 } 1030 }
@@ -1335,17 +1336,20 @@ static int __init ibmphp_init(void)
1335 for (i = 0; i < 16; i++) 1336 for (i = 0; i < 16; i++)
1336 irqs[i] = 0; 1337 irqs[i] = 0;
1337 1338
1338 if ((rc = ibmphp_access_ebda())) 1339 rc = ibmphp_access_ebda();
1340 if (rc)
1339 goto error; 1341 goto error;
1340 debug("after ibmphp_access_ebda()\n"); 1342 debug("after ibmphp_access_ebda()\n");
1341 1343
1342 if ((rc = ibmphp_rsrc_init())) 1344 rc = ibmphp_rsrc_init();
1345 if (rc)
1343 goto error; 1346 goto error;
1344 debug("AFTER Resource & EBDA INITIALIZATIONS\n"); 1347 debug("AFTER Resource & EBDA INITIALIZATIONS\n");
1345 1348
1346 max_slots = get_max_slots(); 1349 max_slots = get_max_slots();
1347 1350
1348 if ((rc = ibmphp_register_pci())) 1351 rc = ibmphp_register_pci();
1352 if (rc)
1349 goto error; 1353 goto error;
1350 1354
1351 if (init_ops()) { 1355 if (init_ops()) {
@@ -1354,7 +1358,8 @@ static int __init ibmphp_init(void)
1354 } 1358 }
1355 1359
1356 ibmphp_print_test(); 1360 ibmphp_print_test();
1357 if ((rc = ibmphp_hpc_start_poll_thread())) 1361 rc = ibmphp_hpc_start_poll_thread();
1362 if (rc)
1358 goto error; 1363 goto error;
1359 1364
1360exit: 1365exit:
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c
index 2fd296706ce7..814cea22a9fa 100644
--- a/drivers/pci/hotplug/ibmphp_pci.c
+++ b/drivers/pci/hotplug/ibmphp_pci.c
@@ -145,7 +145,8 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
145 case PCI_HEADER_TYPE_NORMAL: 145 case PCI_HEADER_TYPE_NORMAL:
146 debug ("single device case.... vendor id = %x, hdr_type = %x, class = %x\n", vendor_id, hdr_type, class); 146 debug ("single device case.... vendor id = %x, hdr_type = %x, class = %x\n", vendor_id, hdr_type, class);
147 assign_alt_irq (cur_func, class_code); 147 assign_alt_irq (cur_func, class_code);
148 if ((rc = configure_device (cur_func)) < 0) { 148 rc = configure_device(cur_func);
149 if (rc < 0) {
149 /* We need to do this in case some other BARs were properly inserted */ 150 /* We need to do this in case some other BARs were properly inserted */
150 err ("was not able to configure devfunc %x on bus %x.\n", 151 err ("was not able to configure devfunc %x on bus %x.\n",
151 cur_func->device, cur_func->busno); 152 cur_func->device, cur_func->busno);
@@ -157,7 +158,8 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
157 break; 158 break;
158 case PCI_HEADER_TYPE_MULTIDEVICE: 159 case PCI_HEADER_TYPE_MULTIDEVICE:
159 assign_alt_irq (cur_func, class_code); 160 assign_alt_irq (cur_func, class_code);
160 if ((rc = configure_device (cur_func)) < 0) { 161 rc = configure_device(cur_func);
162 if (rc < 0) {
161 /* We need to do this in case some other BARs were properly inserted */ 163 /* We need to do this in case some other BARs were properly inserted */
162 err ("was not able to configure devfunc %x on bus %x...bailing out\n", 164 err ("was not able to configure devfunc %x on bus %x...bailing out\n",
163 cur_func->device, cur_func->busno); 165 cur_func->device, cur_func->busno);
diff --git a/drivers/pci/hotplug/ibmphp_res.c b/drivers/pci/hotplug/ibmphp_res.c
index 78cf442e36d6..2f2fcc8f7f8b 100644
--- a/drivers/pci/hotplug/ibmphp_res.c
+++ b/drivers/pci/hotplug/ibmphp_res.c
@@ -224,7 +224,8 @@ int __init ibmphp_rsrc_init (void)
224 if ((curr->rsrc_type & RESTYPE) == MMASK) { 224 if ((curr->rsrc_type & RESTYPE) == MMASK) {
225 /* no bus structure exists in place yet */ 225 /* no bus structure exists in place yet */
226 if (list_empty (&gbuses)) { 226 if (list_empty (&gbuses)) {
227 if ((rc = alloc_bus_range (&newbus, &newrange, curr, MEM, 1))) 227 rc = alloc_bus_range(&newbus, &newrange, curr, MEM, 1);
228 if (rc)
228 return rc; 229 return rc;
229 list_add_tail (&newbus->bus_list, &gbuses); 230 list_add_tail (&newbus->bus_list, &gbuses);
230 debug ("gbuses = NULL, Memory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 231 debug ("gbuses = NULL, Memory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
@@ -237,7 +238,8 @@ int __init ibmphp_rsrc_init (void)
237 return rc; 238 return rc;
238 } else { 239 } else {
239 /* went through all the buses and didn't find ours, need to create a new bus node */ 240 /* went through all the buses and didn't find ours, need to create a new bus node */
240 if ((rc = alloc_bus_range (&newbus, &newrange, curr, MEM, 1))) 241 rc = alloc_bus_range(&newbus, &newrange, curr, MEM, 1);
242 if (rc)
241 return rc; 243 return rc;
242 244
243 list_add_tail (&newbus->bus_list, &gbuses); 245 list_add_tail (&newbus->bus_list, &gbuses);
@@ -248,7 +250,8 @@ int __init ibmphp_rsrc_init (void)
248 /* prefetchable memory */ 250 /* prefetchable memory */
249 if (list_empty (&gbuses)) { 251 if (list_empty (&gbuses)) {
250 /* no bus structure exists in place yet */ 252 /* no bus structure exists in place yet */
251 if ((rc = alloc_bus_range (&newbus, &newrange, curr, PFMEM, 1))) 253 rc = alloc_bus_range(&newbus, &newrange, curr, PFMEM, 1);
254 if (rc)
252 return rc; 255 return rc;
253 list_add_tail (&newbus->bus_list, &gbuses); 256 list_add_tail (&newbus->bus_list, &gbuses);
254 debug ("gbuses = NULL, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 257 debug ("gbuses = NULL, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
@@ -261,7 +264,8 @@ int __init ibmphp_rsrc_init (void)
261 return rc; 264 return rc;
262 } else { 265 } else {
263 /* went through all the buses and didn't find ours, need to create a new bus node */ 266 /* went through all the buses and didn't find ours, need to create a new bus node */
264 if ((rc = alloc_bus_range (&newbus, &newrange, curr, PFMEM, 1))) 267 rc = alloc_bus_range(&newbus, &newrange, curr, PFMEM, 1);
268 if (rc)
265 return rc; 269 return rc;
266 list_add_tail (&newbus->bus_list, &gbuses); 270 list_add_tail (&newbus->bus_list, &gbuses);
267 debug ("1st Bus, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 271 debug ("1st Bus, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
@@ -271,7 +275,8 @@ int __init ibmphp_rsrc_init (void)
271 /* IO */ 275 /* IO */
272 if (list_empty (&gbuses)) { 276 if (list_empty (&gbuses)) {
273 /* no bus structure exists in place yet */ 277 /* no bus structure exists in place yet */
274 if ((rc = alloc_bus_range (&newbus, &newrange, curr, IO, 1))) 278 rc = alloc_bus_range(&newbus, &newrange, curr, IO, 1);
279 if (rc)
275 return rc; 280 return rc;
276 list_add_tail (&newbus->bus_list, &gbuses); 281 list_add_tail (&newbus->bus_list, &gbuses);
277 debug ("gbuses = NULL, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 282 debug ("gbuses = NULL, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
@@ -283,7 +288,8 @@ int __init ibmphp_rsrc_init (void)
283 return rc; 288 return rc;
284 } else { 289 } else {
285 /* went through all the buses and didn't find ours, need to create a new bus node */ 290 /* went through all the buses and didn't find ours, need to create a new bus node */
286 if ((rc = alloc_bus_range (&newbus, &newrange, curr, IO, 1))) 291 rc = alloc_bus_range(&newbus, &newrange, curr, IO, 1);
292 if (rc)
287 return rc; 293 return rc;
288 list_add_tail (&newbus->bus_list, &gbuses); 294 list_add_tail (&newbus->bus_list, &gbuses);
289 debug ("1st Bus, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 295 debug ("1st Bus, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
@@ -1153,7 +1159,9 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1153 } 1159 }
1154 } else { 1160 } else {
1155 /* in the same range */ 1161 /* in the same range */
1156 if ((len_tmp = res_cur->start - 1 - res_prev->end - 1) >= res->len) { 1162 len_tmp = res_cur->start - 1 - res_prev->end - 1;
1163
1164 if (len_tmp >= res->len) {
1157 if ((len_tmp < len_cur) || (len_cur == 0)) { 1165 if ((len_tmp < len_cur) || (len_cur == 0)) {
1158 if (((res_prev->end + 1) % tmp_divide) == 0) { 1166 if (((res_prev->end + 1) % tmp_divide) == 0) {
1159 /* just perfect, starting address's divisible by length */ 1167 /* just perfect, starting address's divisible by length */
@@ -1212,7 +1220,9 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1212 break; 1220 break;
1213 } 1221 }
1214 while (range) { 1222 while (range) {
1215 if ((len_tmp = range->end - range->start) >= res->len) { 1223 len_tmp = range->end - range->start;
1224
1225 if (len_tmp >= res->len) {
1216 if ((len_tmp < len_cur) || (len_cur == 0)) { 1226 if ((len_tmp < len_cur) || (len_cur == 0)) {
1217 if ((range->start % tmp_divide) == 0) { 1227 if ((range->start % tmp_divide) == 0) {
1218 /* just perfect, starting address's divisible by length */ 1228 /* just perfect, starting address's divisible by length */
@@ -1276,7 +1286,9 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1276 break; 1286 break;
1277 } 1287 }
1278 while (range) { 1288 while (range) {
1279 if ((len_tmp = range->end - range->start) >= res->len) { 1289 len_tmp = range->end - range->start;
1290
1291 if (len_tmp >= res->len) {
1280 if ((len_tmp < len_cur) || (len_cur == 0)) { 1292 if ((len_tmp < len_cur) || (len_cur == 0)) {
1281 if ((range->start % tmp_divide) == 0) { 1293 if ((range->start % tmp_divide) == 0) {
1282 /* just perfect, starting address's divisible by length */ 1294 /* just perfect, starting address's divisible by length */
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index 764650b4de3f..10c7927599b3 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -195,7 +195,8 @@ static int change_bus_speed(struct controller *ctrl, struct slot *p_slot,
195 int rc = 0; 195 int rc = 0;
196 196
197 ctrl_dbg(ctrl, "Change speed to %d\n", speed); 197 ctrl_dbg(ctrl, "Change speed to %d\n", speed);
198 if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed))) { 198 rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed);
199 if (rc) {
199 ctrl_err(ctrl, "%s: Issue of set bus speed mode command failed\n", 200 ctrl_err(ctrl, "%s: Issue of set bus speed mode command failed\n",
200 __func__); 201 __func__);
201 return WRONG_BUS_FREQUENCY; 202 return WRONG_BUS_FREQUENCY;
@@ -261,14 +262,16 @@ static int board_added(struct slot *p_slot)
261 } 262 }
262 263
263 if ((ctrl->pci_dev->vendor == 0x8086) && (ctrl->pci_dev->device == 0x0332)) { 264 if ((ctrl->pci_dev->vendor == 0x8086) && (ctrl->pci_dev->device == 0x0332)) {
264 if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) { 265 rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz);
266 if (rc) {
265 ctrl_err(ctrl, "%s: Issue of set bus speed mode command failed\n", 267 ctrl_err(ctrl, "%s: Issue of set bus speed mode command failed\n",
266 __func__); 268 __func__);
267 return WRONG_BUS_FREQUENCY; 269 return WRONG_BUS_FREQUENCY;
268 } 270 }
269 271
270 /* turn on board, blink green LED, turn off Amber LED */ 272 /* turn on board, blink green LED, turn off Amber LED */
271 if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { 273 rc = p_slot->hpc_ops->slot_enable(p_slot);
274 if (rc) {
272 ctrl_err(ctrl, "Issue of Slot Enable command failed\n"); 275 ctrl_err(ctrl, "Issue of Slot Enable command failed\n");
273 return rc; 276 return rc;
274 } 277 }
@@ -296,7 +299,8 @@ static int board_added(struct slot *p_slot)
296 return rc; 299 return rc;
297 300
298 /* turn on board, blink green LED, turn off Amber LED */ 301 /* turn on board, blink green LED, turn off Amber LED */
299 if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { 302 rc = p_slot->hpc_ops->slot_enable(p_slot);
303 if (rc) {
300 ctrl_err(ctrl, "Issue of Slot Enable command failed\n"); 304 ctrl_err(ctrl, "Issue of Slot Enable command failed\n");
301 return rc; 305 return rc;
302 } 306 }
diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c
index 1d89916351ed..7d223e9080ef 100644
--- a/drivers/pci/hotplug/shpchp_hpc.c
+++ b/drivers/pci/hotplug/shpchp_hpc.c
@@ -466,7 +466,8 @@ static int hpc_get_adapter_speed(struct slot *slot, enum pci_bus_speed *value)
466 u8 m66_cap = !!(slot_reg & MHZ66_CAP); 466 u8 m66_cap = !!(slot_reg & MHZ66_CAP);
467 u8 pi, pcix_cap; 467 u8 pi, pcix_cap;
468 468
469 if ((retval = hpc_get_prog_int(slot, &pi))) 469 retval = hpc_get_prog_int(slot, &pi);
470 if (retval)
470 return retval; 471 return retval;
471 472
472 switch (pi) { 473 switch (pi) {
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 2c9ac70254e2..8b63a5b11fc6 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1003,12 +1003,19 @@ int pci_save_state(struct pci_dev *dev)
1003 for (i = 0; i < 16; i++) 1003 for (i = 0; i < 16; i++)
1004 pci_read_config_dword(dev, i * 4, &dev->saved_config_space[i]); 1004 pci_read_config_dword(dev, i * 4, &dev->saved_config_space[i]);
1005 dev->state_saved = true; 1005 dev->state_saved = true;
1006 if ((i = pci_save_pcie_state(dev)) != 0) 1006
1007 i = pci_save_pcie_state(dev);
1008 if (i != 0)
1007 return i; 1009 return i;
1008 if ((i = pci_save_pcix_state(dev)) != 0) 1010
1011 i = pci_save_pcix_state(dev);
1012 if (i != 0)
1009 return i; 1013 return i;
1010 if ((i = pci_save_vc_state(dev)) != 0) 1014
1015 i = pci_save_vc_state(dev);
1016 if (i != 0)
1011 return i; 1017 return i;
1018
1012 return 0; 1019 return 0;
1013} 1020}
1014EXPORT_SYMBOL(pci_save_state); 1021EXPORT_SYMBOL(pci_save_state);