mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-05 15:49:42 -04:00
PCI: Simplify size1 assignment logic
In pbus_size_io() and pbus_size_mem(), a complex ?: operation is performed to set size1. Decompose this so it's easier to read. In the case of pbus_size_mem(), simply initializing size1 to zero ensures the size1 checks work as expected. Link: https://lore.kernel.org/r/20241216175632.4175-4-ilpo.jarvinen@linux.intel.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Tested-by: Xiaochun Lee <lixc17@lenovo.com>
This commit is contained in:
committed by
Bjorn Helgaas
parent
1f82b7e84a
commit
a55bf64b30
@@ -927,9 +927,14 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
|
||||
|
||||
size0 = calculate_iosize(size, min_size, size1, 0, 0,
|
||||
resource_size(b_res), min_align);
|
||||
size1 = (!realloc_head || (realloc_head && !add_size && !children_add_size)) ? size0 :
|
||||
calculate_iosize(size, min_size, size1, add_size, children_add_size,
|
||||
resource_size(b_res), min_align);
|
||||
|
||||
size1 = size0;
|
||||
if (realloc_head && (add_size > 0 || children_add_size > 0)) {
|
||||
size1 = calculate_iosize(size, min_size, size1, add_size,
|
||||
children_add_size, resource_size(b_res),
|
||||
min_align);
|
||||
}
|
||||
|
||||
if (!size0 && !size1) {
|
||||
if (bus->self && (b_res->start || b_res->end))
|
||||
pci_info(bus->self, "disabling bridge window %pR to %pR (unused)\n",
|
||||
@@ -1058,7 +1063,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
|
||||
struct list_head *realloc_head)
|
||||
{
|
||||
struct pci_dev *dev;
|
||||
resource_size_t min_align, win_align, align, size, size0, size1;
|
||||
resource_size_t min_align, win_align, align, size, size0, size1 = 0;
|
||||
resource_size_t aligns[24]; /* Alignments from 1MB to 8TB */
|
||||
int order, max_order;
|
||||
struct resource *b_res = find_bus_resource_of_type(bus,
|
||||
@@ -1153,9 +1158,11 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
|
||||
b_res, &bus->busn_res);
|
||||
}
|
||||
|
||||
size1 = (!realloc_head || (realloc_head && !add_size && !children_add_size)) ? size0 :
|
||||
calculate_memsize(size, min_size, add_size, children_add_size,
|
||||
resource_size(b_res), add_align);
|
||||
if (realloc_head && (add_size > 0 || children_add_size > 0)) {
|
||||
size1 = calculate_memsize(size, min_size, add_size, children_add_size,
|
||||
resource_size(b_res), add_align);
|
||||
}
|
||||
|
||||
if (!size0 && !size1) {
|
||||
if (bus->self && (b_res->start || b_res->end))
|
||||
pci_info(bus->self, "disabling bridge window %pR to %pR (unused)\n",
|
||||
|
||||
Reference in New Issue
Block a user