diff options
author | Nicholas Johnson <nicholas.johnson-opensource@outlook.com.au> | 2019-06-22 12:43:46 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2019-07-02 14:56:26 -0400 |
commit | 5c6bcc344b18dfb3b0ddcca6c26f6858879f73bf (patch) | |
tree | 7c3829214ea44eba8feb58f07ead8115b1e22f1e | |
parent | 85dc04136e86680378546afb808357a58c06061c (diff) |
PCI: Simplify pci_bus_distribute_available_resources()
Reorder pci_bus_distribute_available_resources() to group related code
together. No functional change intended.
Link: https://lore.kernel.org/r/PS2P216MB0642C7A485649D2D787A1C6F80000@PS2P216MB0642.KORP216.PROD.OUTLOOK.COM
Link: https://lore.kernel.org/r/20190622210310.180905-2-helgaas@kernel.org
Signed-off-by: Nicholas Johnson <nicholas.johnson-opensource@outlook.com.au>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
-rw-r--r-- | drivers/pci/setup-bus.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index d533102b2788..ee5be219dd41 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
@@ -1866,16 +1866,6 @@ static void pci_bus_distribute_available_resources(struct pci_bus *bus, | |||
1866 | available_mmio_pref); | 1866 | available_mmio_pref); |
1867 | 1867 | ||
1868 | /* | 1868 | /* |
1869 | * Calculate the total amount of extra resource space we can | ||
1870 | * pass to bridges below this one. This is basically the | ||
1871 | * extra space reduced by the minimal required space for the | ||
1872 | * non-hotplug bridges. | ||
1873 | */ | ||
1874 | remaining_io = available_io; | ||
1875 | remaining_mmio = available_mmio; | ||
1876 | remaining_mmio_pref = available_mmio_pref; | ||
1877 | |||
1878 | /* | ||
1879 | * Calculate how many hotplug bridges and normal bridges there | 1869 | * Calculate how many hotplug bridges and normal bridges there |
1880 | * are on this bus. We will distribute the additional available | 1870 | * are on this bus. We will distribute the additional available |
1881 | * resources between hotplug bridges. | 1871 | * resources between hotplug bridges. |
@@ -1887,6 +1877,31 @@ static void pci_bus_distribute_available_resources(struct pci_bus *bus, | |||
1887 | normal_bridges++; | 1877 | normal_bridges++; |
1888 | } | 1878 | } |
1889 | 1879 | ||
1880 | /* | ||
1881 | * There is only one bridge on the bus so it gets all available | ||
1882 | * resources which it can then distribute to the possible hotplug | ||
1883 | * bridges below. | ||
1884 | */ | ||
1885 | if (hotplug_bridges + normal_bridges == 1) { | ||
1886 | dev = list_first_entry(&bus->devices, struct pci_dev, bus_list); | ||
1887 | if (dev->subordinate) { | ||
1888 | pci_bus_distribute_available_resources(dev->subordinate, | ||
1889 | add_list, available_io, available_mmio, | ||
1890 | available_mmio_pref); | ||
1891 | } | ||
1892 | return; | ||
1893 | } | ||
1894 | |||
1895 | /* | ||
1896 | * Calculate the total amount of extra resource space we can | ||
1897 | * pass to bridges below this one. This is basically the | ||
1898 | * extra space reduced by the minimal required space for the | ||
1899 | * non-hotplug bridges. | ||
1900 | */ | ||
1901 | remaining_io = available_io; | ||
1902 | remaining_mmio = available_mmio; | ||
1903 | remaining_mmio_pref = available_mmio_pref; | ||
1904 | |||
1890 | for_each_pci_bridge(dev, bus) { | 1905 | for_each_pci_bridge(dev, bus) { |
1891 | const struct resource *res; | 1906 | const struct resource *res; |
1892 | 1907 | ||
@@ -1911,21 +1926,6 @@ static void pci_bus_distribute_available_resources(struct pci_bus *bus, | |||
1911 | } | 1926 | } |
1912 | 1927 | ||
1913 | /* | 1928 | /* |
1914 | * There is only one bridge on the bus so it gets all available | ||
1915 | * resources which it can then distribute to the possible hotplug | ||
1916 | * bridges below. | ||
1917 | */ | ||
1918 | if (hotplug_bridges + normal_bridges == 1) { | ||
1919 | dev = list_first_entry(&bus->devices, struct pci_dev, bus_list); | ||
1920 | if (dev->subordinate) { | ||
1921 | pci_bus_distribute_available_resources(dev->subordinate, | ||
1922 | add_list, available_io, available_mmio, | ||
1923 | available_mmio_pref); | ||
1924 | } | ||
1925 | return; | ||
1926 | } | ||
1927 | |||
1928 | /* | ||
1929 | * Go over devices on this bus and distribute the remaining | 1929 | * Go over devices on this bus and distribute the remaining |
1930 | * resource space between hotplug bridges. | 1930 | * resource space between hotplug bridges. |
1931 | */ | 1931 | */ |