]> git.itanic.dy.fi Git - linux-stable/commitdiff
PCI: ixp4xx: Use PCI_CONF1_ADDRESS() macro
authorPali Rohár <pali@kernel.org>
Wed, 28 Sep 2022 12:25:39 +0000 (14:25 +0200)
committerLorenzo Pieralisi <lpieralisi@kernel.org>
Fri, 24 Mar 2023 15:48:32 +0000 (16:48 +0100)
Simplify pci-ixp4xx.c driver code and use new PCI_CONF1_ADDRESS() macro for
accessing PCI config space.

Link: https://lore.kernel.org/r/20220928122539.15116-1-pali@kernel.org
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
drivers/pci/controller/pci-ixp4xx.c

index 654ac4a82beb984bb038b30456eb147c227f0e6f..e44252db6085a94b19c6a6e96198d1df233b47bc 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/bits.h>
+#include "../pci.h"
 
 /* Register offsets */
 #define IXP4XX_PCI_NP_AD               0x00
@@ -188,12 +189,13 @@ static u32 ixp4xx_config_addr(u8 bus_num, u16 devfn, int where)
        /* Root bus is always 0 in this hardware */
        if (bus_num == 0) {
                /* type 0 */
-               return BIT(32-PCI_SLOT(devfn)) | ((PCI_FUNC(devfn)) << 8) |
-                       (where & ~3);
+               return (PCI_CONF1_ADDRESS(0, 0, PCI_FUNC(devfn), where) &
+                       ~PCI_CONF1_ENABLE) | BIT(32-PCI_SLOT(devfn));
        } else {
                /* type 1 */
-               return (bus_num << 16) | ((PCI_SLOT(devfn)) << 11) |
-                       ((PCI_FUNC(devfn)) << 8) | (where & ~3) | 1;
+               return (PCI_CONF1_ADDRESS(bus_num, PCI_SLOT(devfn),
+                                         PCI_FUNC(devfn), where) &
+                       ~PCI_CONF1_ENABLE) | 1;
        }
 }