Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Quentin Lambert and committed by
Bjorn Helgaas
79e50e72 656f978f

+66 -30
+2 -1
drivers/pci/hotplug/acpi_pcihp.c
··· 433 433 { 434 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 438 return 0; 438 439 if ((ACPI_FAILURE(acpi_get_parent(handle, &parent_handle)))) 439 440 return 0;
+6 -3
drivers/pci/hotplug/cpci_hotplug_core.c
··· 125 125 126 126 /* Unconfigure device */ 127 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 130 err("%s - could not unconfigure slot %s", 130 131 __func__, slot_name(slot)); 131 132 goto disable_error; ··· 142 141 } 143 142 cpci_led_on(slot); 144 143 145 - if (controller->ops->set_power) 146 - if ((retval = controller->ops->set_power(slot, 0))) 144 + if (controller->ops->set_power) { 145 + retval = controller->ops->set_power(slot, 0); 146 + if (retval) 147 147 goto disable_error; 148 + } 148 149 149 150 if (update_adapter_status(slot->hotplug_slot, 0)) 150 151 warn("failure to update adapter file");
+3 -2
drivers/pci/hotplug/cpcihp_zt5550.c
··· 237 237 dbg("registered controller"); 238 238 239 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, 241 - PCI_DEVICE_ID_DEC_21154, NULL))) { 240 + bus0_dev = pci_get_device(PCI_VENDOR_ID_DEC, 241 + PCI_DEVICE_ID_DEC_21154, NULL); 242 + if (!bus0_dev) { 242 243 status = -ENODEV; 243 244 goto init_register_error; 244 245 }
+10 -5
drivers/pci/hotplug/ibmphp_core.c
··· 1023 1023 debug("ENABLING SLOT........\n"); 1024 1024 slot_cur = hs->private; 1025 1025 1026 - if ((rc = validate(slot_cur, ENABLE))) { 1026 + rc = validate(slot_cur, ENABLE); 1027 + if (rc) { 1027 1028 err("validate function failed\n"); 1028 1029 goto error_nopower; 1029 1030 } ··· 1336 1335 for (i = 0; i < 16; i++) 1337 1336 irqs[i] = 0; 1338 1337 1339 - if ((rc = ibmphp_access_ebda())) 1338 + rc = ibmphp_access_ebda(); 1339 + if (rc) 1340 1340 goto error; 1341 1341 debug("after ibmphp_access_ebda()\n"); 1342 1342 1343 - if ((rc = ibmphp_rsrc_init())) 1343 + rc = ibmphp_rsrc_init(); 1344 + if (rc) 1344 1345 goto error; 1345 1346 debug("AFTER Resource & EBDA INITIALIZATIONS\n"); 1346 1347 1347 1348 max_slots = get_max_slots(); 1348 1349 1349 - if ((rc = ibmphp_register_pci())) 1350 + rc = ibmphp_register_pci(); 1351 + if (rc) 1350 1352 goto error; 1351 1353 1352 1354 if (init_ops()) { ··· 1358 1354 } 1359 1355 1360 1356 ibmphp_print_test(); 1361 - if ((rc = ibmphp_hpc_start_poll_thread())) 1357 + rc = ibmphp_hpc_start_poll_thread(); 1358 + if (rc) 1362 1359 goto error; 1363 1360 1364 1361 exit:
+4 -2
drivers/pci/hotplug/ibmphp_pci.c
··· 145 145 case PCI_HEADER_TYPE_NORMAL: 146 146 debug ("single device case.... vendor id = %x, hdr_type = %x, class = %x\n", vendor_id, hdr_type, class); 147 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 150 /* We need to do this in case some other BARs were properly inserted */ 150 151 err ("was not able to configure devfunc %x on bus %x.\n", 151 152 cur_func->device, cur_func->busno); ··· 158 157 break; 159 158 case PCI_HEADER_TYPE_MULTIDEVICE: 160 159 assign_alt_irq (cur_func, class_code); 161 - if ((rc = configure_device (cur_func)) < 0) { 160 + rc = configure_device(cur_func); 161 + if (rc < 0) { 162 162 /* We need to do this in case some other BARs were properly inserted */ 163 163 err ("was not able to configure devfunc %x on bus %x...bailing out\n", 164 164 cur_func->device, cur_func->busno);
+21 -9
drivers/pci/hotplug/ibmphp_res.c
··· 224 224 if ((curr->rsrc_type & RESTYPE) == MMASK) { 225 225 /* no bus structure exists in place yet */ 226 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 229 return rc; 229 230 list_add_tail (&newbus->bus_list, &gbuses); 230 231 debug ("gbuses = NULL, Memory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); ··· 238 237 return rc; 239 238 } else { 240 239 /* went through all the buses and didn't find ours, need to create a new bus node */ 241 - if ((rc = alloc_bus_range (&newbus, &newrange, curr, MEM, 1))) 240 + rc = alloc_bus_range(&newbus, &newrange, curr, MEM, 1); 241 + if (rc) 242 242 return rc; 243 243 244 244 list_add_tail (&newbus->bus_list, &gbuses); ··· 250 248 /* prefetchable memory */ 251 249 if (list_empty (&gbuses)) { 252 250 /* no bus structure exists in place yet */ 253 - if ((rc = alloc_bus_range (&newbus, &newrange, curr, PFMEM, 1))) 251 + rc = alloc_bus_range(&newbus, &newrange, curr, PFMEM, 1); 252 + if (rc) 254 253 return rc; 255 254 list_add_tail (&newbus->bus_list, &gbuses); 256 255 debug ("gbuses = NULL, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); ··· 264 261 return rc; 265 262 } else { 266 263 /* went through all the buses and didn't find ours, need to create a new bus node */ 267 - if ((rc = alloc_bus_range (&newbus, &newrange, curr, PFMEM, 1))) 264 + rc = alloc_bus_range(&newbus, &newrange, curr, PFMEM, 1); 265 + if (rc) 268 266 return rc; 269 267 list_add_tail (&newbus->bus_list, &gbuses); 270 268 debug ("1st Bus, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); ··· 275 271 /* IO */ 276 272 if (list_empty (&gbuses)) { 277 273 /* no bus structure exists in place yet */ 278 - if ((rc = alloc_bus_range (&newbus, &newrange, curr, IO, 1))) 274 + rc = alloc_bus_range(&newbus, &newrange, curr, IO, 1); 275 + if (rc) 279 276 return rc; 280 277 list_add_tail (&newbus->bus_list, &gbuses); 281 278 debug ("gbuses = NULL, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); ··· 288 283 return rc; 289 284 } else { 290 285 /* went through all the buses and didn't find ours, need to create a new bus node */ 291 - if ((rc = alloc_bus_range (&newbus, &newrange, curr, IO, 1))) 286 + rc = alloc_bus_range(&newbus, &newrange, curr, IO, 1); 287 + if (rc) 292 288 return rc; 293 289 list_add_tail (&newbus->bus_list, &gbuses); 294 290 debug ("1st Bus, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); ··· 1159 1153 } 1160 1154 } else { 1161 1155 /* in the same range */ 1162 - if ((len_tmp = res_cur->start - 1 - res_prev->end - 1) >= res->len) { 1156 + len_tmp = res_cur->start - 1 - res_prev->end - 1; 1157 + 1158 + if (len_tmp >= res->len) { 1163 1159 if ((len_tmp < len_cur) || (len_cur == 0)) { 1164 1160 if (((res_prev->end + 1) % tmp_divide) == 0) { 1165 1161 /* just perfect, starting address's divisible by length */ ··· 1220 1212 break; 1221 1213 } 1222 1214 while (range) { 1223 - if ((len_tmp = range->end - range->start) >= res->len) { 1215 + len_tmp = range->end - range->start; 1216 + 1217 + if (len_tmp >= res->len) { 1224 1218 if ((len_tmp < len_cur) || (len_cur == 0)) { 1225 1219 if ((range->start % tmp_divide) == 0) { 1226 1220 /* just perfect, starting address's divisible by length */ ··· 1286 1276 break; 1287 1277 } 1288 1278 while (range) { 1289 - if ((len_tmp = range->end - range->start) >= res->len) { 1279 + len_tmp = range->end - range->start; 1280 + 1281 + if (len_tmp >= res->len) { 1290 1282 if ((len_tmp < len_cur) || (len_cur == 0)) { 1291 1283 if ((range->start % tmp_divide) == 0) { 1292 1284 /* just perfect, starting address's divisible by length */
+8 -4
drivers/pci/hotplug/shpchp_ctrl.c
··· 195 195 int rc = 0; 196 196 197 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 200 ctrl_err(ctrl, "%s: Issue of set bus speed mode command failed\n", 200 201 __func__); 201 202 return WRONG_BUS_FREQUENCY; ··· 262 261 } 263 262 264 263 if ((ctrl->pci_dev->vendor == 0x8086) && (ctrl->pci_dev->device == 0x0332)) { 265 - if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) { 264 + rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz); 265 + if (rc) { 266 266 ctrl_err(ctrl, "%s: Issue of set bus speed mode command failed\n", 267 267 __func__); 268 268 return WRONG_BUS_FREQUENCY; 269 269 } 270 270 271 271 /* turn on board, blink green LED, turn off Amber LED */ 272 - if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { 272 + rc = p_slot->hpc_ops->slot_enable(p_slot); 273 + if (rc) { 273 274 ctrl_err(ctrl, "Issue of Slot Enable command failed\n"); 274 275 return rc; 275 276 } ··· 299 296 return rc; 300 297 301 298 /* turn on board, blink green LED, turn off Amber LED */ 302 - if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { 299 + rc = p_slot->hpc_ops->slot_enable(p_slot); 300 + if (rc) { 303 301 ctrl_err(ctrl, "Issue of Slot Enable command failed\n"); 304 302 return rc; 305 303 }
+2 -1
drivers/pci/hotplug/shpchp_hpc.c
··· 466 466 u8 m66_cap = !!(slot_reg & MHZ66_CAP); 467 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 471 return retval; 471 472 472 473 switch (pi) {
+10 -3
drivers/pci/pci.c
··· 1003 1003 for (i = 0; i < 16; i++) 1004 1004 pci_read_config_dword(dev, i * 4, &dev->saved_config_space[i]); 1005 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 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 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 1017 return i; 1018 + 1012 1019 return 0; 1013 1020 } 1014 1021 EXPORT_SYMBOL(pci_save_state);