diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2014-05-19 20:28:37 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2014-05-23 14:40:48 -0400 |
commit | 30afe8d00b994416b24c63f8c5bbf1c13869ec3c (patch) | |
tree | a107bdb2d3c7ffa3c70e4d3e0a78e40926aa0ed8 /drivers/pci/setup-bus.c | |
parent | 5b28541552ef5eeffc41d6936105f38c2508e566 (diff) |
PCI: Change pbus_size_mem() return values to be more conventional
pbus_size_mem() previously returned 0 for failure and 1 for success.
Change it to return -ENOSPC for failure and 0 for success.
No functional change.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/setup-bus.c')
-rw-r--r-- | drivers/pci/setup-bus.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index b6585cb9bce7..12ab50ffdfea 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
@@ -915,6 +915,10 @@ static inline resource_size_t calculate_mem_align(resource_size_t *aligns, | |||
915 | * | 915 | * |
916 | * Calculate the size of the bus and minimal alignment which | 916 | * Calculate the size of the bus and minimal alignment which |
917 | * guarantees that all child resources fit in this size. | 917 | * guarantees that all child resources fit in this size. |
918 | * | ||
919 | * Returns -ENOSPC if there's no available bus resource of the desired type. | ||
920 | * Otherwise, sets the bus resource start/end to indicate the required | ||
921 | * size, adds things to realloc_head (if supplied), and returns 0. | ||
918 | */ | 922 | */ |
919 | static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, | 923 | static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, |
920 | unsigned long type, unsigned long type2, | 924 | unsigned long type, unsigned long type2, |
@@ -931,7 +935,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, | |||
931 | resource_size_t children_add_size = 0; | 935 | resource_size_t children_add_size = 0; |
932 | 936 | ||
933 | if (!b_res) | 937 | if (!b_res) |
934 | return 0; | 938 | return -ENOSPC; |
935 | 939 | ||
936 | memset(aligns, 0, sizeof(aligns)); | 940 | memset(aligns, 0, sizeof(aligns)); |
937 | max_order = 0; | 941 | max_order = 0; |
@@ -1003,7 +1007,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, | |||
1003 | "%pR to %pR (unused)\n", b_res, | 1007 | "%pR to %pR (unused)\n", b_res, |
1004 | &bus->busn_res); | 1008 | &bus->busn_res); |
1005 | b_res->flags = 0; | 1009 | b_res->flags = 0; |
1006 | return 1; | 1010 | return 0; |
1007 | } | 1011 | } |
1008 | b_res->start = min_align; | 1012 | b_res->start = min_align; |
1009 | b_res->end = size0 + min_align - 1; | 1013 | b_res->end = size0 + min_align - 1; |
@@ -1014,7 +1018,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, | |||
1014 | "%pR to %pR add_size %llx\n", b_res, | 1018 | "%pR to %pR add_size %llx\n", b_res, |
1015 | &bus->busn_res, (unsigned long long)size1-size0); | 1019 | &bus->busn_res, (unsigned long long)size1-size0); |
1016 | } | 1020 | } |
1017 | return 1; | 1021 | return 0; |
1018 | } | 1022 | } |
1019 | 1023 | ||
1020 | unsigned long pci_cardbus_resource_alignment(struct resource *res) | 1024 | unsigned long pci_cardbus_resource_alignment(struct resource *res) |
@@ -1126,6 +1130,7 @@ void __ref __pci_bus_size_bridges(struct pci_bus *bus, | |||
1126 | unsigned long mask, prefmask, type2 = 0, type3 = 0; | 1130 | unsigned long mask, prefmask, type2 = 0, type3 = 0; |
1127 | resource_size_t additional_mem_size = 0, additional_io_size = 0; | 1131 | resource_size_t additional_mem_size = 0, additional_io_size = 0; |
1128 | struct resource *b_res; | 1132 | struct resource *b_res; |
1133 | int ret; | ||
1129 | 1134 | ||
1130 | list_for_each_entry(dev, &bus->devices, bus_list) { | 1135 | list_for_each_entry(dev, &bus->devices, bus_list) { |
1131 | struct pci_bus *b = dev->subordinate; | 1136 | struct pci_bus *b = dev->subordinate; |
@@ -1175,25 +1180,27 @@ void __ref __pci_bus_size_bridges(struct pci_bus *bus, | |||
1175 | prefmask = IORESOURCE_MEM | IORESOURCE_PREFETCH; | 1180 | prefmask = IORESOURCE_MEM | IORESOURCE_PREFETCH; |
1176 | if (b_res[2].flags & IORESOURCE_MEM_64) { | 1181 | if (b_res[2].flags & IORESOURCE_MEM_64) { |
1177 | prefmask |= IORESOURCE_MEM_64; | 1182 | prefmask |= IORESOURCE_MEM_64; |
1178 | if (pbus_size_mem(bus, prefmask, prefmask, | 1183 | ret = pbus_size_mem(bus, prefmask, prefmask, |
1179 | prefmask, prefmask, | 1184 | prefmask, prefmask, |
1180 | realloc_head ? 0 : additional_mem_size, | 1185 | realloc_head ? 0 : additional_mem_size, |
1181 | additional_mem_size, realloc_head)) { | 1186 | additional_mem_size, realloc_head); |
1182 | /* | 1187 | if (ret == 0) { |
1183 | * Success, with pref mmio64, | 1188 | /* |
1184 | * next will size non-pref or | 1189 | * Success, with pref mmio64, |
1185 | * non-mmio64 */ | 1190 | * next will size non-pref or |
1186 | mask = prefmask; | 1191 | * non-mmio64 */ |
1187 | type2 = prefmask & ~IORESOURCE_MEM_64; | 1192 | mask = prefmask; |
1188 | type3 = prefmask & ~IORESOURCE_PREFETCH; | 1193 | type2 = prefmask & ~IORESOURCE_MEM_64; |
1194 | type3 = prefmask & ~IORESOURCE_PREFETCH; | ||
1189 | } | 1195 | } |
1190 | } | 1196 | } |
1191 | if (!type2) { | 1197 | if (!type2) { |
1192 | prefmask &= ~IORESOURCE_MEM_64; | 1198 | prefmask &= ~IORESOURCE_MEM_64; |
1193 | if (pbus_size_mem(bus, prefmask, prefmask, | 1199 | ret = pbus_size_mem(bus, prefmask, prefmask, |
1194 | prefmask, prefmask, | 1200 | prefmask, prefmask, |
1195 | realloc_head ? 0 : additional_mem_size, | 1201 | realloc_head ? 0 : additional_mem_size, |
1196 | additional_mem_size, realloc_head)) { | 1202 | additional_mem_size, realloc_head); |
1203 | if (ret == 0) { | ||
1197 | /* Success, next will size non-prefetch. */ | 1204 | /* Success, next will size non-prefetch. */ |
1198 | mask = prefmask; | 1205 | mask = prefmask; |
1199 | } else | 1206 | } else |