summaryrefslogtreecommitdiff
path: root/drivers/pci/access.c
diff options
context:
space:
mode:
authorShuai Xue <xueshuai@linux.alibaba.com>2023-12-08 10:56:50 +0800
committerWill Deacon <will@kernel.org>2023-12-13 13:35:41 +0000
commitac16087134b837d42b75bb1c741070b6c142f258 (patch)
treee075f97329c7dca7a2dd883818f3bb3a4274dec9 /drivers/pci/access.c
parentad6534c626fedd818718d76c36d69c7d8e7b61cc (diff)
downloadlwn-ac16087134b837d42b75bb1c741070b6c142f258.tar.gz
lwn-ac16087134b837d42b75bb1c741070b6c142f258.zip
PCI: Move pci_clear_and_set_dword() helper to PCI header
The clear and set pattern is commonly used for accessing PCI config, move the helper pci_clear_and_set_dword() from aspm.c into PCI header. In addition, rename to pci_clear_and_set_config_dword() to retain the "config" information and match the other accessors. No functional change intended. Signed-off-by: Shuai Xue <xueshuai@linux.alibaba.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Tested-by: Ilkka Koskinen <ilkka@os.amperecomputing.com> Link: https://lore.kernel.org/r/20231208025652.87192-4-xueshuai@linux.alibaba.com Signed-off-by: Will Deacon <will@kernel.org>
Diffstat (limited to 'drivers/pci/access.c')
-rw-r--r--drivers/pci/access.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index 6554a2e89d36..6449056b57dd 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -598,3 +598,15 @@ int pci_write_config_dword(const struct pci_dev *dev, int where,
return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val);
}
EXPORT_SYMBOL(pci_write_config_dword);
+
+void pci_clear_and_set_config_dword(const struct pci_dev *dev, int pos,
+ u32 clear, u32 set)
+{
+ u32 val;
+
+ pci_read_config_dword(dev, pos, &val);
+ val &= ~clear;
+ val |= set;
+ pci_write_config_dword(dev, pos, val);
+}
+EXPORT_SYMBOL(pci_clear_and_set_config_dword);