Skip to contentSkip to conversation

PCI: Add pci_bus_set_ops

PATCH Applied Huang Ying 2 participants 2 messages Apr 24, 2009 – Jun 11, 2009 PCI

lore
Share & tools
lore

Huang Ying

author
#0 lore raw

PATCH 1/4 PCI: Add pci_bus_set_ops

pci_bus_set_ops changes pci_ops associated with a pci_bus. This can be used by some debug tool such as PCIE AER error injection to fake some PCI configuration registers.

---
 drivers/pci/access.c |   19 +++++++++++++++++++
 include/linux/pci.h  |    1 +
 2 files changed, 20 insertions(+)
drivers/pci/access.c +19 -0
@@ -66,6 +66,25 @@ EXPORT_SYMBOL(pci_bus_write_config_byte)
 EXPORT_SYMBOL(pci_bus_write_config_word);
 EXPORT_SYMBOL(pci_bus_write_config_dword);
 
+/**
+ * pci_bus_set_ops - Set raw operations of pci bus
+ * @bus:	pci bus struct
+ * @ops:	new raw operations
+ *
+ * Return previous raw operations
+ */
+struct pci_ops *pci_bus_set_ops(struct pci_bus *bus, struct pci_ops *ops)
+{
+	struct pci_ops *old_ops;
+	unsigned long flags;
+
+	spin_lock_irqsave(&pci_lock, flags);
+	old_ops = bus->ops;
+	bus->ops = ops;
+	spin_unlock_irqrestore(&pci_lock, flags);
+	return old_ops;
+}
+EXPORT_SYMBOL(pci_bus_set_ops);
 
 /**
  * pci_read_vpd - Read one entry from Vital Product Data
include/linux/pci.h +1 -0
@@ -639,6 +639,7 @@ int pci_bus_write_config_word(struct pci
 			      int where, u16 val);
 int pci_bus_write_config_dword(struct pci_bus *bus, unsigned int devfn,
 			       int where, u32 val);
+struct pci_ops *pci_bus_set_ops(struct pci_bus *bus, struct pci_ops *ops);
 
 static inline int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val)
 {
Applied
#1 lore raw
Quoted 5 lines · On Fri, 24 Apr 2009 10:45:17 +0800 Huang Ying <[email protected]> wrote:

pci_bus_set_ops changes pci_ops associated with a pci_bus. This can be used by some debug tool such as PCIE AER error injection to fake some PCI configuration registers.

Applied to linux-next, thanks.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center