Skip to content

Commit 8fa0a44

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI: Make minimum bridge window alignment reference more obvious
Calculations related to bridge window size contain literal 20 that is the minimum alignment for a bridge window. Make the code more obvious by converting the literal 20 to __ffs(SZ_1M). Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]> [bhelgaas: squash https://lore.kernel.org/r/[email protected]] Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Mika Westerberg <[email protected]>
1 parent 903534f commit 8fa0a44

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/pci/setup-bus.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
* tighter packing. Prefetchable range support.
1515
*/
1616

17+
#include <linux/bitops.h>
1718
#include <linux/init.h>
1819
#include <linux/kernel.h>
1920
#include <linux/module.h>
2021
#include <linux/pci.h>
2122
#include <linux/errno.h>
2223
#include <linux/ioport.h>
2324
#include <linux/cache.h>
25+
#include <linux/sizes.h>
2426
#include <linux/slab.h>
2527
#include <linux/acpi.h>
2628
#include "pci.h"
@@ -957,7 +959,7 @@ static inline resource_size_t calculate_mem_align(resource_size_t *aligns,
957959
for (order = 0; order <= max_order; order++) {
958960
resource_size_t align1 = 1;
959961

960-
align1 <<= (order + 20);
962+
align1 <<= order + __ffs(SZ_1M);
961963

962964
if (!align)
963965
min_align = align1;
@@ -1047,7 +1049,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
10471049
* resources.
10481050
*/
10491051
align = pci_resource_alignment(dev, r);
1050-
order = __ffs(align) - 20;
1052+
order = __ffs(align) - __ffs(SZ_1M);
10511053
if (order < 0)
10521054
order = 0;
10531055
if (order >= ARRAY_SIZE(aligns)) {

0 commit comments

Comments
 (0)