@@ -380,6 +380,20 @@ static void quirk_ali7101_acpi(struct pci_dev *dev)
}
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, quirk_ali7101_acpi);
+static inline u32 piix4_acpi_quirk_size(u32 max, u32 mask)
+{
+ u32 size = max;
+
+ for (;;) {
+ unsigned bit = size >> 1;
+ if ((bit & mask) == bit)
+ break;
+ size = bit;
+ }
+
+ return size;
+}
+
static void piix4_acpi_io_quirk(struct pci_dev *dev, const char *name,
unsigned int port, unsigned int enable)
{
@@ -391,13 +405,7 @@ static void piix4_acpi_io_quirk(struct pci_dev *dev, const char *name,
return;
mask = (devres >> 16) & 15;
base = devres & 0xffff;
- size = 16;
- for (;;) {
- unsigned bit = size >> 1;
- if ((bit & mask) == bit)
- break;
- size = bit;
- }
+ size = piix4_acpi_quirk_size(16, mask);
/*
* For now we only print it out. Eventually we'll want to
* reserve it (at least if it's in the 0x1000+ range), but
@@ -418,13 +426,7 @@ static void piix4_acpi_mem_quirk(struct pci_dev *dev, const char *name,
return;
base = devres & 0xffff8000;
mask = (devres & 0x7f) << 15;
- size = 128 << 15;
- for (;;) {
- unsigned bit = size >> 1;
- if ((bit & mask) == bit)
- break;
- size = bit;
- }
+ size = piix4_acpi_quirk_size(128 << 15, mask);
/*
* For now we only print it out. Eventually we'll want to
* reserve it, but let's get enough confirmation reports first.