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

Merge branches 'pci/enumeration', 'pci/virtualization' and 'pci/cleanup' into next

* pci/enumeration:
PCI: Generate uppercase hex for modalias interface class

* pci/virtualization:
PCI: Add ACS quirk for Solarflare SFC9120 & SFC9140
PCI: Remove unused pci_get_dma_source()
PCI: Remove unused pci_find_upstream_pcie_bridge()

* pci/cleanup:
PCI: Remove assignment from complicated "if" conditions
PCI: Remove assignment from "if" conditions
PCI: Remove unnecessary curly braces
PCI: Add space before open parenthesis

+149 -206
+2 -1
drivers/pci/hotplug/acpi_pcihp.c
··· 182 182 { 183 183 acpi_handle bridge_handle, parent_handle; 184 184 185 - if (!(bridge_handle = acpi_pci_get_bridge_handle(pbus))) 185 + bridge_handle = acpi_pci_get_bridge_handle(pbus); 186 + if (!bridge_handle) 186 187 return 0; 187 188 if ((ACPI_FAILURE(acpi_get_parent(handle, &parent_handle)))) 188 189 return 0;
+1 -1
drivers/pci/hotplug/acpiphp_ibm.c
··· 302 302 goto read_table_done; 303 303 } 304 304 305 - for(size = 0, i = 0; i < package->package.count; i++) { 305 + for (size = 0, i = 0; i < package->package.count; i++) { 306 306 if (package->package.elements[i].type != ACPI_TYPE_BUFFER) { 307 307 pr_err("%s: Invalid APCI element %d\n", __func__, i); 308 308 goto read_table_done;
+8 -5
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"); ··· 470 467 __func__, slot_name(slot), hs_csr); 471 468 472 469 if (!slot->extracting) { 473 - if (update_latch_status(slot->hotplug_slot, 0)) { 470 + if (update_latch_status(slot->hotplug_slot, 0)) 474 471 warn("failure to update latch file"); 475 - } 472 + 476 473 slot->extracting = 1; 477 474 atomic_inc(&extracting); 478 475 }
+14 -14
drivers/pci/hotplug/cpcihp_generic.c
··· 56 56 if (debug) \ 57 57 printk (KERN_DEBUG "%s: " format "\n", \ 58 58 MY_NAME , ## arg); \ 59 - } while(0) 59 + } while (0) 60 60 #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) 61 61 #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) 62 62 #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) ··· 82 82 char *p; 83 83 unsigned long tmp; 84 84 85 - if(!bridge) { 85 + if (!bridge) { 86 86 info("not configured, disabling."); 87 87 return -EINVAL; 88 88 } 89 89 str = bridge; 90 - if(!*str) 90 + if (!*str) 91 91 return -EINVAL; 92 92 93 93 tmp = simple_strtoul(str, &p, 16); 94 - if(p == str || tmp > 0xff) { 94 + if (p == str || tmp > 0xff) { 95 95 err("Invalid hotplug bus bridge device bus number"); 96 96 return -EINVAL; 97 97 } 98 98 bridge_busnr = (u8) tmp; 99 99 dbg("bridge_busnr = 0x%02x", bridge_busnr); 100 - if(*p != ':') { 100 + if (*p != ':') { 101 101 err("Invalid hotplug bus bridge device"); 102 102 return -EINVAL; 103 103 } 104 104 str = p + 1; 105 105 tmp = simple_strtoul(str, &p, 16); 106 - if(p == str || tmp > 0x1f) { 106 + if (p == str || tmp > 0x1f) { 107 107 err("Invalid hotplug bus bridge device slot number"); 108 108 return -EINVAL; 109 109 } ··· 112 112 113 113 dbg("first_slot = 0x%02x", first_slot); 114 114 dbg("last_slot = 0x%02x", last_slot); 115 - if(!(first_slot && last_slot)) { 115 + if (!(first_slot && last_slot)) { 116 116 err("Need to specify first_slot and last_slot"); 117 117 return -EINVAL; 118 118 } 119 - if(last_slot < first_slot) { 119 + if (last_slot < first_slot) { 120 120 err("first_slot must be less than last_slot"); 121 121 return -EINVAL; 122 122 } 123 123 124 124 dbg("port = 0x%04x", port); 125 125 dbg("enum_bit = 0x%02x", enum_bit); 126 - if(enum_bit > 7) { 126 + if (enum_bit > 7) { 127 127 err("Invalid #ENUM bit"); 128 128 return -EINVAL; 129 129 } ··· 151 151 return status; 152 152 153 153 r = request_region(port, 1, "#ENUM hotswap signal register"); 154 - if(!r) 154 + if (!r) 155 155 return -EBUSY; 156 156 157 157 dev = pci_get_domain_bus_and_slot(0, bridge_busnr, 158 158 PCI_DEVFN(bridge_slot, 0)); 159 - if(!dev || dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { 159 + if (!dev || dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { 160 160 err("Invalid bridge device %s", bridge); 161 161 pci_dev_put(dev); 162 162 return -EINVAL; ··· 169 169 generic_hpc.ops = &generic_hpc_ops; 170 170 171 171 status = cpci_hp_register_controller(&generic_hpc); 172 - if(status != 0) { 172 + if (status != 0) { 173 173 err("Could not register cPCI hotplug controller"); 174 174 return -ENODEV; 175 175 } 176 176 dbg("registered controller"); 177 177 178 178 status = cpci_hp_register_bus(bus, first_slot, last_slot); 179 - if(status != 0) { 179 + if (status != 0) { 180 180 err("Could not register cPCI hotplug bus"); 181 181 goto init_bus_register_error; 182 182 } 183 183 dbg("registered bus"); 184 184 185 185 status = cpci_hp_start(); 186 - if(status != 0) { 186 + if (status != 0) { 187 187 err("Could not started cPCI hotplug system"); 188 188 goto init_start_error; 189 189 }
+22 -22
drivers/pci/hotplug/cpcihp_zt5550.c
··· 51 51 if (debug) \ 52 52 printk (KERN_DEBUG "%s: " format "\n", \ 53 53 MY_NAME , ## arg); \ 54 - } while(0) 54 + } while (0) 55 55 #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) 56 56 #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) 57 57 #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) ··· 82 82 int ret; 83 83 84 84 /* Since we know that no boards exist with two HC chips, treat it as an error */ 85 - if(hc_dev) { 85 + if (hc_dev) { 86 86 err("too many host controller devices?"); 87 87 return -EBUSY; 88 88 } 89 89 90 90 ret = pci_enable_device(pdev); 91 - if(ret) { 91 + if (ret) { 92 92 err("cannot enable %s\n", pci_name(pdev)); 93 93 return ret; 94 94 } ··· 98 98 dbg("pci resource start %llx", (unsigned long long)pci_resource_start(hc_dev, 1)); 99 99 dbg("pci resource len %llx", (unsigned long long)pci_resource_len(hc_dev, 1)); 100 100 101 - if(!request_mem_region(pci_resource_start(hc_dev, 1), 101 + if (!request_mem_region(pci_resource_start(hc_dev, 1), 102 102 pci_resource_len(hc_dev, 1), MY_NAME)) { 103 103 err("cannot reserve MMIO region"); 104 104 ret = -ENOMEM; ··· 107 107 108 108 hc_registers = 109 109 ioremap(pci_resource_start(hc_dev, 1), pci_resource_len(hc_dev, 1)); 110 - if(!hc_registers) { 110 + if (!hc_registers) { 111 111 err("cannot remap MMIO region %llx @ %llx", 112 112 (unsigned long long)pci_resource_len(hc_dev, 1), 113 113 (unsigned long long)pci_resource_start(hc_dev, 1)); ··· 146 146 147 147 static int zt5550_hc_cleanup(void) 148 148 { 149 - if(!hc_dev) 149 + if (!hc_dev) 150 150 return -ENODEV; 151 151 152 152 iounmap(hc_registers); ··· 170 170 u8 reg; 171 171 172 172 ret = 0; 173 - if(dev_id == zt5550_hpc.dev_id) { 173 + if (dev_id == zt5550_hpc.dev_id) { 174 174 reg = readb(csr_int_status); 175 - if(reg) 175 + if (reg) 176 176 ret = 1; 177 177 } 178 178 return ret; ··· 182 182 { 183 183 u8 reg; 184 184 185 - if(hc_dev == NULL) { 185 + if (hc_dev == NULL) 186 186 return -ENODEV; 187 - } 187 + 188 188 reg = readb(csr_int_mask); 189 189 reg = reg & ~ENUM_INT_MASK; 190 190 writeb(reg, csr_int_mask); ··· 195 195 { 196 196 u8 reg; 197 197 198 - if(hc_dev == NULL) { 198 + if (hc_dev == NULL) 199 199 return -ENODEV; 200 - } 201 200 202 201 reg = readb(csr_int_mask); 203 202 reg = reg | ENUM_INT_MASK; ··· 209 210 int status; 210 211 211 212 status = zt5550_hc_config(pdev); 212 - if(status != 0) { 213 + if (status != 0) 213 214 return status; 214 - } 215 + 215 216 dbg("returned from zt5550_hc_config"); 216 217 217 218 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller)); 218 219 zt5550_hpc_ops.query_enum = zt5550_hc_query_enum; 219 220 zt5550_hpc.ops = &zt5550_hpc_ops; 220 - if(!poll) { 221 + if (!poll) { 221 222 zt5550_hpc.irq = hc_dev->irq; 222 223 zt5550_hpc.irq_flags = IRQF_SHARED; 223 224 zt5550_hpc.dev_id = hc_dev; ··· 230 231 } 231 232 232 233 status = cpci_hp_register_controller(&zt5550_hpc); 233 - if(status != 0) { 234 + if (status != 0) { 234 235 err("could not register cPCI hotplug controller"); 235 236 goto init_hc_error; 236 237 } 237 238 dbg("registered controller"); 238 239 239 240 /* 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))) { 241 + bus0_dev = pci_get_device(PCI_VENDOR_ID_DEC, 242 + PCI_DEVICE_ID_DEC_21154, NULL); 243 + if (!bus0_dev) { 242 244 status = -ENODEV; 243 245 goto init_register_error; 244 246 } ··· 247 247 pci_dev_put(bus0_dev); 248 248 249 249 status = cpci_hp_register_bus(bus0, 0x0a, 0x0f); 250 - if(status != 0) { 250 + if (status != 0) { 251 251 err("could not register cPCI hotplug bus"); 252 252 goto init_register_error; 253 253 } 254 254 dbg("registered bus"); 255 255 256 256 status = cpci_hp_start(); 257 - if(status != 0) { 257 + if (status != 0) { 258 258 err("could not started cPCI hotplug system"); 259 259 cpci_hp_unregister_bus(bus0); 260 260 goto init_register_error; ··· 300 300 301 301 info(DRIVER_DESC " version: " DRIVER_VERSION); 302 302 r = request_region(ENUM_PORT, 1, "#ENUM hotswap signal register"); 303 - if(!r) 303 + if (!r) 304 304 return -EBUSY; 305 305 306 306 rc = pci_register_driver(&zt5550_hc_driver); 307 - if(rc < 0) 307 + if (rc < 0) 308 308 release_region(ENUM_PORT, 1); 309 309 return rc; 310 310 }
+1 -1
drivers/pci/hotplug/cpqphp.h
··· 690 690 691 691 status = (readl(ctrl->hpc_reg + INT_INPUT_CLEAR) & (0x01L << hp_slot)); 692 692 693 - return(status == 0) ? 1 : 0; 693 + return (status == 0) ? 1 : 0; 694 694 } 695 695 696 696
+1 -2
drivers/pci/hotplug/cpqphp_core.c
··· 1096 1096 1097 1097 /* initialize our threads if they haven't already been started up */ 1098 1098 rc = one_time_init(); 1099 - if (rc) { 1099 + if (rc) 1100 1100 goto err_free_bus; 1101 - } 1102 1101 1103 1102 dbg("pdev = %p\n", pdev); 1104 1103 dbg("pci resource start %llx\n", (unsigned long long)pci_resource_start(pdev, 0));
+7 -12
drivers/pci/hotplug/cpqphp_ctrl.c
··· 705 705 if (temp == max) { 706 706 *head = max->next; 707 707 } else { 708 - while (temp && temp->next != max) { 708 + while (temp && temp->next != max) 709 709 temp = temp->next; 710 - } 711 710 712 711 if (temp) 713 712 temp->next = max->next; ··· 902 903 /* 903 904 * Check to see if it was our interrupt 904 905 */ 905 - if (!(misc & 0x000C)) { 906 + if (!(misc & 0x000C)) 906 907 return IRQ_NONE; 907 - } 908 908 909 909 if (misc & 0x0004) { 910 910 /* ··· 1141 1143 /* We don't allow freq/mode changes if we find another adapter running 1142 1144 * in another slot on this controller 1143 1145 */ 1144 - for(slot = ctrl->slot; slot; slot = slot->next) { 1146 + for (slot = ctrl->slot; slot; slot = slot->next) { 1145 1147 if (slot->device == (hp_slot + ctrl->slot_device_offset)) 1146 1148 continue; 1147 1149 if (!slot->hotplug_slot || !slot->hotplug_slot->info) ··· 1191 1193 1192 1194 reg16 = readw(ctrl->hpc_reg + NEXT_CURR_FREQ); 1193 1195 reg16 &= ~0x000F; 1194 - switch(adapter_speed) { 1196 + switch (adapter_speed) { 1195 1197 case(PCI_SPEED_133MHz_PCIX): 1196 1198 reg = 0x75; 1197 1199 reg16 |= 0xB; ··· 2004 2006 /* Check to see if the interlock is closed */ 2005 2007 tempdword = readl(ctrl->hpc_reg + INT_INPUT_CLEAR); 2006 2008 2007 - if (tempdword & (0x01 << hp_slot)) { 2009 + if (tempdword & (0x01 << hp_slot)) 2008 2010 return 1; 2009 - } 2010 2011 2011 2012 if (func->is_a_board) { 2012 2013 rc = board_replaced(func, ctrl); ··· 2067 2070 } 2068 2071 } 2069 2072 2070 - if (rc) { 2073 + if (rc) 2071 2074 dbg("%s: rc = %d\n", __func__, rc); 2072 - } 2073 2075 2074 2076 if (p_slot) 2075 2077 update_slot_info(ctrl, p_slot); ··· 2091 2095 device = func->device; 2092 2096 func = cpqhp_slot_find(ctrl->bus, device, index++); 2093 2097 p_slot = cpqhp_find_slot(ctrl, device); 2094 - if (p_slot) { 2098 + if (p_slot) 2095 2099 physical_slot = p_slot->number; 2096 - } 2097 2100 2098 2101 /* Make sure there are no video controllers here */ 2099 2102 while (func && !rc) {
+5 -8
drivers/pci/hotplug/cpqphp_nvram.c
··· 204 204 u8 temp_byte = 0xFF; 205 205 u32 rc; 206 206 207 - if (!check_for_compaq_ROM(rom_start)) { 207 + if (!check_for_compaq_ROM(rom_start)) 208 208 return -ENODEV; 209 - } 210 209 211 210 available = 1024; 212 211 ··· 249 250 250 251 available = 1024; 251 252 252 - if (!check_for_compaq_ROM(rom_start)) { 253 + if (!check_for_compaq_ROM(rom_start)) 253 254 return(1); 254 - } 255 255 256 256 buffer = (u32*) evbuffer; 257 257 ··· 425 427 426 428 void compaq_nvram_init (void __iomem *rom_start) 427 429 { 428 - if (rom_start) { 430 + if (rom_start) 429 431 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR); 430 - } 432 + 431 433 dbg("int15 entry = %p\n", compaq_int15_entry_point); 432 434 433 435 /* initialize our int15 lock */ ··· 659 661 660 662 if (evbuffer_init) { 661 663 rc = store_HRT(rom_start); 662 - if (rc) { 664 + if (rc) 663 665 err(msg_unable_to_save); 664 - } 665 666 } 666 667 return rc; 667 668 }
+11 -8
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 } ··· 1200 1199 1201 1200 debug("DISABLING SLOT...\n"); 1202 1201 1203 - if ((slot_cur == NULL) || (slot_cur->ctrl == NULL)) { 1202 + if ((slot_cur == NULL) || (slot_cur->ctrl == NULL)) 1204 1203 return -ENODEV; 1205 - } 1206 1204 1207 1205 flag = slot_cur->flag; 1208 1206 slot_cur->flag = 1; ··· 1336 1336 for (i = 0; i < 16; i++) 1337 1337 irqs[i] = 0; 1338 1338 1339 - if ((rc = ibmphp_access_ebda())) 1339 + rc = ibmphp_access_ebda(); 1340 + if (rc) 1340 1341 goto error; 1341 1342 debug("after ibmphp_access_ebda()\n"); 1342 1343 1343 - if ((rc = ibmphp_rsrc_init())) 1344 + rc = ibmphp_rsrc_init(); 1345 + if (rc) 1344 1346 goto error; 1345 1347 debug("AFTER Resource & EBDA INITIALIZATIONS\n"); 1346 1348 1347 1349 max_slots = get_max_slots(); 1348 1350 1349 - if ((rc = ibmphp_register_pci())) 1351 + rc = ibmphp_register_pci(); 1352 + if (rc) 1350 1353 goto error; 1351 1354 1352 1355 if (init_ops()) { ··· 1358 1355 } 1359 1356 1360 1357 ibmphp_print_test(); 1361 - if ((rc = ibmphp_hpc_start_poll_thread())) { 1358 + rc = ibmphp_hpc_start_poll_thread(); 1359 + if (rc) 1362 1360 goto error; 1363 - } 1364 1361 1365 1362 exit: 1366 1363 return rc;
+1 -2
drivers/pci/hotplug/ibmphp_ebda.c
··· 215 215 debug ("%s - cap of the slot: %x\n", __func__, hpc_ptr->slots[index].slot_cap); 216 216 } 217 217 218 - for (index = 0; index < hpc_ptr->bus_count; index++) { 218 + for (index = 0; index < hpc_ptr->bus_count; index++) 219 219 debug ("%s - bus# of each bus controlled by this ctlr: %x\n", __func__, hpc_ptr->buses[index].bus_num); 220 - } 221 220 222 221 debug ("%s - type of hpc: %x\n", __func__, hpc_ptr->ctlr_type); 223 222 switch (hpc_ptr->ctlr_type) {
+1 -2
drivers/pci/hotplug/ibmphp_hpc.c
··· 997 997 rc = ibmphp_do_disable_slot (pslot); 998 998 } 999 999 1000 - if (update || disable) { 1000 + if (update || disable) 1001 1001 ibmphp_update_slot_info (pslot); 1002 - } 1003 1002 1004 1003 debug ("%s - Exit rc[%d] disable[%x] update[%x]\n", __func__, rc, disable, update); 1005 1004
+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);
+31 -14
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); ··· 1044 1038 /* found our range */ 1045 1039 if (!res_prev) { 1046 1040 /* first time in the loop */ 1047 - if ((res_cur->start != range->start) && ((len_tmp = res_cur->start - 1 - range->start) >= res->len)) { 1041 + len_tmp = res_cur->start - 1 - range->start; 1042 + 1043 + if ((res_cur->start != range->start) && (len_tmp >= res->len)) { 1048 1044 debug ("len_tmp = %x\n", len_tmp); 1049 1045 1050 1046 if ((len_tmp < len_cur) || (len_cur == 0)) { ··· 1086 1078 } 1087 1079 if (!res_cur->next) { 1088 1080 /* last device on the range */ 1089 - if ((range->end != res_cur->end) && ((len_tmp = range->end - (res_cur->end + 1)) >= res->len)) { 1081 + len_tmp = range->end - (res_cur->end + 1); 1082 + 1083 + if ((range->end != res_cur->end) && (len_tmp >= res->len)) { 1090 1084 debug ("len_tmp = %x\n", len_tmp); 1091 1085 if ((len_tmp < len_cur) || (len_cur == 0)) { 1092 1086 ··· 1127 1117 if (res_prev) { 1128 1118 if (res_prev->rangeno != res_cur->rangeno) { 1129 1119 /* 1st device on this range */ 1130 - if ((res_cur->start != range->start) && 1131 - ((len_tmp = res_cur->start - 1 - range->start) >= res->len)) { 1120 + len_tmp = res_cur->start - 1 - range->start; 1121 + 1122 + if ((res_cur->start != range->start) && (len_tmp >= res->len)) { 1132 1123 if ((len_tmp < len_cur) || (len_cur == 0)) { 1133 1124 if ((range->start % tmp_divide) == 0) { 1134 1125 /* just perfect, starting address is divisible by length */ ··· 1164 1153 } 1165 1154 } else { 1166 1155 /* in the same range */ 1167 - 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) { 1168 1159 if ((len_tmp < len_cur) || (len_cur == 0)) { 1169 1160 if (((res_prev->end + 1) % tmp_divide) == 0) { 1170 1161 /* just perfect, starting address's divisible by length */ ··· 1225 1212 break; 1226 1213 } 1227 1214 while (range) { 1228 - if ((len_tmp = range->end - range->start) >= res->len) { 1215 + len_tmp = range->end - range->start; 1216 + 1217 + if (len_tmp >= res->len) { 1229 1218 if ((len_tmp < len_cur) || (len_cur == 0)) { 1230 1219 if ((range->start % tmp_divide) == 0) { 1231 1220 /* just perfect, starting address's divisible by length */ ··· 1291 1276 break; 1292 1277 } 1293 1278 while (range) { 1294 - if ((len_tmp = range->end - range->start) >= res->len) { 1279 + len_tmp = range->end - range->start; 1280 + 1281 + if (len_tmp >= res->len) { 1295 1282 if ((len_tmp < len_cur) || (len_cur == 0)) { 1296 1283 if ((range->start % tmp_divide) == 0) { 1297 1284 /* just perfect, starting address's divisible by length */ ··· 1352 1335 return -EINVAL; 1353 1336 } 1354 1337 } 1355 - } /* end if(!res_cur) */ 1338 + } /* end if (!res_cur) */ 1356 1339 return -EINVAL; 1357 1340 } 1358 1341
+9 -5
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 } ··· 599 595 ctrl_dbg(ctrl, "%s: p_slot->pwr_save %x\n", __func__, p_slot->pwr_save); 600 596 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 601 597 602 - if(((p_slot->ctrl->pci_dev->vendor == PCI_VENDOR_ID_AMD) || 598 + if (((p_slot->ctrl->pci_dev->vendor == PCI_VENDOR_ID_AMD) || 603 599 (p_slot->ctrl->pci_dev->device == PCI_DEVICE_ID_AMD_POGO_7458)) 604 600 && p_slot->ctrl->num_slots == 1) { 605 601 /* handle amd pogo errata; this must be done before enable */
+3 -2
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) { ··· 799 798 800 799 ctrl_dbg(ctrl, "%s: intr_loc = %x\n", __func__, intr_loc); 801 800 802 - if(!shpchp_poll_mode) { 801 + if (!shpchp_poll_mode) { 803 802 /* 804 803 * Mask Global Interrupt Mask - see implementation 805 804 * note on p. 139 of SHPC spec rev 1.0
+1 -1
drivers/pci/pci-sysfs.c
··· 177 177 { 178 178 struct pci_dev *pci_dev = to_pci_dev(dev); 179 179 180 - return sprintf(buf, "pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x\n", 180 + return sprintf(buf, "pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02X\n", 181 181 pci_dev->vendor, pci_dev->device, 182 182 pci_dev->subsystem_vendor, pci_dev->subsystem_device, 183 183 (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8),
+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);
+17 -51
drivers/pci/quirks.c
··· 3534 3534 /* Intel 82801, https://bugzilla.kernel.org/show_bug.cgi?id=44881#c49 */ 3535 3535 DECLARE_PCI_FIXUP_HEADER(0x8086, 0x244e, quirk_use_pcie_bridge_dma_alias); 3536 3536 3537 - static struct pci_dev *pci_func_0_dma_source(struct pci_dev *dev) 3538 - { 3539 - if (!PCI_FUNC(dev->devfn)) 3540 - return pci_dev_get(dev); 3541 - 3542 - return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0)); 3543 - } 3544 - 3545 - static const struct pci_dev_dma_source { 3546 - u16 vendor; 3547 - u16 device; 3548 - struct pci_dev *(*dma_source)(struct pci_dev *dev); 3549 - } pci_dev_dma_source[] = { 3550 - /* 3551 - * https://bugzilla.redhat.com/show_bug.cgi?id=605888 3552 - * 3553 - * Some Ricoh devices use the function 0 source ID for DMA on 3554 - * other functions of a multifunction device. The DMA devices 3555 - * is therefore function 0, which will have implications of the 3556 - * iommu grouping of these devices. 3557 - */ 3558 - { PCI_VENDOR_ID_RICOH, 0xe822, pci_func_0_dma_source }, 3559 - { PCI_VENDOR_ID_RICOH, 0xe230, pci_func_0_dma_source }, 3560 - { PCI_VENDOR_ID_RICOH, 0xe832, pci_func_0_dma_source }, 3561 - { PCI_VENDOR_ID_RICOH, 0xe476, pci_func_0_dma_source }, 3562 - { 0 } 3563 - }; 3564 - 3565 - /* 3566 - * IOMMUs with isolation capabilities need to be programmed with the 3567 - * correct source ID of a device. In most cases, the source ID matches 3568 - * the device doing the DMA, but sometimes hardware is broken and will 3569 - * tag the DMA as being sourced from a different device. This function 3570 - * allows that translation. Note that the reference count of the 3571 - * returned device is incremented on all paths. 3572 - */ 3573 - struct pci_dev *pci_get_dma_source(struct pci_dev *dev) 3574 - { 3575 - const struct pci_dev_dma_source *i; 3576 - 3577 - for (i = pci_dev_dma_source; i->dma_source; i++) { 3578 - if ((i->vendor == dev->vendor || 3579 - i->vendor == (u16)PCI_ANY_ID) && 3580 - (i->device == dev->device || 3581 - i->device == (u16)PCI_ANY_ID)) 3582 - return i->dma_source(dev); 3583 - } 3584 - 3585 - return pci_dev_get(dev); 3586 - } 3587 - 3588 3537 /* 3589 3538 * AMD has indicated that the devices below do not support peer-to-peer 3590 3539 * in any system where they are found in the southbridge with an AMD ··· 3635 3686 return acs_flags & ~flags ? 0 : 1; 3636 3687 } 3637 3688 3689 + static int pci_quirk_solarflare_acs(struct pci_dev *dev, u16 acs_flags) 3690 + { 3691 + /* 3692 + * SV, TB, and UF are not relevant to multifunction endpoints. 3693 + * 3694 + * Solarflare indicates that peer-to-peer between functions is not 3695 + * possible, therefore RR, CR, and DT are not implemented. Mask 3696 + * these out as if they were clear in the ACS capabilities register. 3697 + */ 3698 + acs_flags &= ~(PCI_ACS_SV | PCI_ACS_TB | PCI_ACS_RR | 3699 + PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_DT); 3700 + 3701 + return acs_flags ? 0 : 1; 3702 + } 3703 + 3638 3704 static const struct pci_dev_acs_enabled { 3639 3705 u16 vendor; 3640 3706 u16 device; ··· 3661 3697 { PCI_VENDOR_ID_ATI, 0x439d, pci_quirk_amd_sb_acs }, 3662 3698 { PCI_VENDOR_ID_ATI, 0x4384, pci_quirk_amd_sb_acs }, 3663 3699 { PCI_VENDOR_ID_ATI, 0x4399, pci_quirk_amd_sb_acs }, 3700 + { PCI_VENDOR_ID_SOLARFLARE, 0x0903, pci_quirk_solarflare_acs }, 3701 + { PCI_VENDOR_ID_SOLARFLARE, 0x0923, pci_quirk_solarflare_acs }, 3664 3702 { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_quirk_intel_pch_acs }, 3665 3703 { 0 } 3666 3704 };
-34
drivers/pci/search.c
··· 103 103 return ret; 104 104 } 105 105 106 - /* 107 - * find the upstream PCIe-to-PCI bridge of a PCI device 108 - * if the device is PCIE, return NULL 109 - * if the device isn't connected to a PCIe bridge (that is its parent is a 110 - * legacy PCI bridge and the bridge is directly connected to bus 0), return its 111 - * parent 112 - */ 113 - struct pci_dev *pci_find_upstream_pcie_bridge(struct pci_dev *pdev) 114 - { 115 - struct pci_dev *tmp = NULL; 116 - 117 - if (pci_is_pcie(pdev)) 118 - return NULL; 119 - while (1) { 120 - if (pci_is_root_bus(pdev->bus)) 121 - break; 122 - pdev = pdev->bus->self; 123 - /* a p2p bridge */ 124 - if (!pci_is_pcie(pdev)) { 125 - tmp = pdev; 126 - continue; 127 - } 128 - /* PCI device should connect to a PCIe bridge */ 129 - if (pci_pcie_type(pdev) != PCI_EXP_TYPE_PCI_BRIDGE) { 130 - /* Busted hardware? */ 131 - WARN_ON_ONCE(1); 132 - return NULL; 133 - } 134 - return pdev; 135 - } 136 - 137 - return tmp; 138 - } 139 - 140 106 static struct pci_bus *pci_do_find_bus(struct pci_bus *bus, unsigned char busnr) 141 107 { 142 108 struct pci_bus *child;
-16
include/linux/pci.h
··· 1557 1557 1558 1558 #ifdef CONFIG_PCI_QUIRKS 1559 1559 void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); 1560 - struct pci_dev *pci_get_dma_source(struct pci_dev *dev); 1561 1560 int pci_dev_specific_acs_enabled(struct pci_dev *dev, u16 acs_flags); 1562 1561 void pci_dev_specific_enable_acs(struct pci_dev *dev); 1563 1562 #else 1564 1563 static inline void pci_fixup_device(enum pci_fixup_pass pass, 1565 1564 struct pci_dev *dev) { } 1566 - static inline struct pci_dev *pci_get_dma_source(struct pci_dev *dev) 1567 - { 1568 - return pci_dev_get(dev); 1569 - } 1570 1565 static inline int pci_dev_specific_acs_enabled(struct pci_dev *dev, 1571 1566 u16 acs_flags) 1572 1567 { ··· 1822 1827 int pci_for_each_dma_alias(struct pci_dev *pdev, 1823 1828 int (*fn)(struct pci_dev *pdev, 1824 1829 u16 alias, void *data), void *data); 1825 - 1826 - /** 1827 - * pci_find_upstream_pcie_bridge - find upstream PCIe-to-PCI bridge of a device 1828 - * @pdev: the PCI device 1829 - * 1830 - * if the device is PCIE, return NULL 1831 - * if the device isn't connected to a PCIe bridge (that is its parent is a 1832 - * legacy PCI bridge and the bridge is directly connected to bus 0), return its 1833 - * parent 1834 - */ 1835 - struct pci_dev *pci_find_upstream_pcie_bridge(struct pci_dev *pdev); 1836 1830 1837 1831 /* helper functions for operation of device flag */ 1838 1832 static inline void pci_set_dev_assigned(struct pci_dev *pdev)