[Skiboot] [PATCH 1/3] core/pci: Improve PCI config register filter

Gavin Shan gwshan at linux.vnet.ibm.com
Tue Jul 5 12:30:09 AEST 2016


This improves PCI config register filter so that it can be reused
by PCI virtual device in subsequent patch:

   * First argument to pci_cfg_reg_func() is changed to "void *".
     It allows to accept variable data types including PCI virtual
     device in future.
   * Return value from pci_cfg_reg_func() to be used by PCI virtual
     device in future.
   * Shortened name of function phb3_pcicfg_filter_rc_pref_window().

Signed-off-by: Gavin Shan <gwshan at linux.vnet.ibm.com>
---
 hw/phb3.c     | 14 ++++++++------
 include/pci.h |  8 ++++----
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/hw/phb3.c b/hw/phb3.c
index 905fdf4..85166d0 100644
--- a/hw/phb3.c
+++ b/hw/phb3.c
@@ -72,10 +72,10 @@ static bool phb3_fenced(struct phb3 *p)
 	return false;
 }
 
-static void phb3_pcicfg_filter_rc_pref_window(struct pci_device *pd __unused,
-					      struct pci_cfg_reg_filter *pcrf,
-					      uint32_t offset, uint32_t len,
-					      uint32_t *data,  bool write)
+static int64_t phb3_pcicfg_rc_pref_window(void *dev __unused,
+					  struct pci_cfg_reg_filter *pcrf,
+					  uint32_t offset, uint32_t len,
+					  uint32_t *data,  bool write)
 {
 	uint8_t *pdata;
 	uint32_t i;
@@ -85,7 +85,7 @@ static void phb3_pcicfg_filter_rc_pref_window(struct pci_device *pd __unused,
 		pdata = &pcrf->data[offset - pcrf->start];
 		for (i = 0; i < len; i++, pdata++)
 			*pdata = (uint8_t)(*data >> (8 * i));
-		return;
+		return OPAL_SUCCESS;
 	}
 
 	/* Return whatever we cached */
@@ -100,6 +100,8 @@ static void phb3_pcicfg_filter_rc_pref_window(struct pci_device *pd __unused,
 
 		*data |= *pdata;
 	}
+
+	return OPAL_SUCCESS;
 }
 
 /*
@@ -495,7 +497,7 @@ static void phb3_check_device_quirks(struct phb *phb, struct pci_device *dev)
 				pci_add_cfg_reg_filter(dev,
 					PCI_CFG_PREF_MEM_BASE_U32, 12,
 					PCI_REG_FLAG_READ | PCI_REG_FLAG_WRITE,
-					phb3_pcicfg_filter_rc_pref_window);
+					phb3_pcicfg_rc_pref_window);
 		}
 	}
 }
diff --git a/include/pci.h b/include/pci.h
index 83c9683..fcf6e86 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -25,10 +25,10 @@
 struct pci_device;
 struct pci_cfg_reg_filter;
 
-typedef void (*pci_cfg_reg_func)(struct pci_device *pd,
-				 struct pci_cfg_reg_filter *pcrf,
-				 uint32_t offset, uint32_t len,
-				 uint32_t *data, bool write);
+typedef int64_t (*pci_cfg_reg_func)(void *dev,
+				    struct pci_cfg_reg_filter *pcrf,
+				    uint32_t offset, uint32_t len,
+				    uint32_t *data, bool write);
 struct pci_cfg_reg_filter {
 	uint32_t		flags;
 #define PCI_REG_FLAG_READ	0x1
-- 
2.1.0



More information about the Skiboot mailing list