[PATCH 3/4] ppc64: make the bus matching function platform specific

Stephen Rothwell sfr at canb.auug.org.au
Tue Jul 12 17:45:27 EST 2005


Hi all,

This patch allows us to have a different bus if matching function for
each platform.

Signed-off-by: Stephen Rothwell <sfr at canb.auug.org.au>
---
 arch/ppc64/kernel/iSeries_vio.c |   12 +++++++++++-
 arch/ppc64/kernel/vio.c         |   28 +++++++++++++++++++---------
 include/asm-ppc64/vio.h         |    3 ++-
 3 files changed, 32 insertions(+), 11 deletions(-)

-- 
Cheers,
Stephen Rothwell                    sfr at canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

diff -ruNp linus-vio-init.2/arch/ppc64/kernel/iSeries_vio.c linus-vio-init.3/arch/ppc64/kernel/iSeries_vio.c
--- linus-vio-init.2/arch/ppc64/kernel/iSeries_vio.c	2005-06-26 06:23:28.000000000 +1000
+++ linus-vio-init.3/arch/ppc64/kernel/iSeries_vio.c	2005-06-26 08:08:55.000000000 +1000
@@ -115,13 +115,23 @@ void __init probe_bus_iseries(void)
 }
 
 /**
+ * vio_match_device_iseries: - Tell if a iSeries VIO device matches a
+ *	vio_device_id
+ */
+static int vio_match_device_iseries(const struct vio_device_id *id,
+		const struct vio_dev *dev)
+{
+	return strncmp(dev->type, id->type, strlen(id->type)) == 0;
+}
+
+/**
  * vio_bus_init_iseries: - Initialize the iSeries virtual IO bus
  */
 static int __init vio_bus_init_iseries(void)
 {
 	int err;
 
-	err = vio_bus_init();
+	err = vio_bus_init(vio_match_device_iseries);
 	if (err == 0) {
 		iommu_vio_init();
 		vio_bus_device.iommu_table = &vio_iommu_table;
diff -ruNp linus-vio-init.2/arch/ppc64/kernel/vio.c linus-vio-init.3/arch/ppc64/kernel/vio.c
--- linus-vio-init.2/arch/ppc64/kernel/vio.c	2005-06-27 18:01:17.000000000 +1000
+++ linus-vio-init.3/arch/ppc64/kernel/vio.c	2005-06-27 16:44:25.000000000 +1000
@@ -44,11 +44,8 @@ struct vio_dev vio_bus_device  = { /* fa
 	.dev.bus = &vio_bus_type,
 };
 
-#ifdef CONFIG_PPC_ISERIES
-
-#define device_is_compatible(a, b)	1
-
-#endif
+static int (*is_match)(const struct vio_device_id *id,
+		const struct vio_dev *dev);
 
 /* convert from struct device to struct vio_dev and pass to driver.
  * dev->driver has already been set by generic code because vio_bus_match
@@ -133,8 +130,7 @@ static const struct vio_device_id * vio_
 	DBGENTER();
 
 	while (ids->type) {
-		if ((strncmp(dev->type, ids->type, strlen(ids->type)) == 0) &&
-			device_is_compatible(dev->dev.platform_data, ids->compat))
+		if (is_match(ids, dev))
 			return ids;
 		ids++;
 	}
@@ -168,10 +164,13 @@ static void probe_bus_pseries(void)
 /**
  * vio_bus_init: - Initialize the virtual IO bus
  */
-int __init vio_bus_init(void)
+int __init vio_bus_init(int (*match_func)(const struct vio_device_id *id,
+			const struct vio_dev *dev))
 {
 	int err;
 
+	is_match = match_func;
+
 	err = bus_register(&vio_bus_type);
 	if (err) {
 		printk(KERN_ERR "failed to register VIO bus\n");
@@ -193,13 +192,24 @@ int __init vio_bus_init(void)
 
 #ifdef CONFIG_PPC_PSERIES
 /**
+ * vio_match_device_pseries: - Tell if a pSeries VIO device matches a
+ *	vio_device_id
+ */
+static int vio_match_device_pseries(const struct vio_device_id *id,
+		const struct vio_dev *dev)
+{
+	return (strncmp(dev->type, id->type, strlen(id->type)) == 0) &&
+			device_is_compatible(dev->dev.platform_data, id->compat);
+}
+
+/**
  * vio_bus_init_pseries: - Initialize the pSeries virtual IO bus
  */
 static int __init vio_bus_init_pseries(void)
 {
 	int err;
 
-	err = vio_bus_init();
+	err = vio_bus_init(vio_match_device_pseries);
 	if (err == 0)
 		probe_bus_pseries();
 	return err;
diff -ruNp linus-vio-init.2/include/asm-ppc64/vio.h linus-vio-init.3/include/asm-ppc64/vio.h
--- linus-vio-init.2/include/asm-ppc64/vio.h	2005-06-27 18:01:17.000000000 +1000
+++ linus-vio-init.3/include/asm-ppc64/vio.h	2005-06-27 16:49:40.000000000 +1000
@@ -105,6 +105,7 @@ static inline struct vio_dev *to_vio_dev
 	return container_of(dev, struct vio_dev, dev);
 }
 
-extern int vio_bus_init(void);
+extern int vio_bus_init(int (*is_match)(const struct vio_device_id *id,
+			const struct vio_dev *dev));
 
 #endif /* _ASM_VIO_H */



More information about the Linuxppc64-dev mailing list