Commit 6312236f authored by Stephen Rothwell's avatar Stephen Rothwell Committed by Paul Mackerras

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

This patch allows us to have a different bus if matching function for
each platform.
Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent 8c65b5c9
...@@ -114,6 +114,16 @@ void __init probe_bus_iseries(void) ...@@ -114,6 +114,16 @@ void __init probe_bus_iseries(void)
vio_register_device_iseries("viotape", i); vio_register_device_iseries("viotape", i);
} }
/**
* 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 * vio_bus_init_iseries: - Initialize the iSeries virtual IO bus
*/ */
...@@ -121,7 +131,7 @@ static int __init vio_bus_init_iseries(void) ...@@ -121,7 +131,7 @@ static int __init vio_bus_init_iseries(void)
{ {
int err; int err;
err = vio_bus_init(); err = vio_bus_init(vio_match_device_iseries);
if (err == 0) { if (err == 0) {
iommu_vio_init(); iommu_vio_init();
vio_bus_device.iommu_table = &vio_iommu_table; vio_bus_device.iommu_table = &vio_iommu_table;
......
...@@ -44,11 +44,8 @@ struct vio_dev vio_bus_device = { /* fake "parent" device */ ...@@ -44,11 +44,8 @@ struct vio_dev vio_bus_device = { /* fake "parent" device */
.dev.bus = &vio_bus_type, .dev.bus = &vio_bus_type,
}; };
#ifdef CONFIG_PPC_ISERIES static int (*is_match)(const struct vio_device_id *id,
const struct vio_dev *dev);
#define device_is_compatible(a, b) 1
#endif
/* convert from struct device to struct vio_dev and pass to driver. /* 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 * dev->driver has already been set by generic code because vio_bus_match
...@@ -133,8 +130,7 @@ static const struct vio_device_id * vio_match_device(const struct vio_device_id ...@@ -133,8 +130,7 @@ static const struct vio_device_id * vio_match_device(const struct vio_device_id
DBGENTER(); DBGENTER();
while (ids->type) { while (ids->type) {
if ((strncmp(dev->type, ids->type, strlen(ids->type)) == 0) && if (is_match(ids, dev))
device_is_compatible(dev->dev.platform_data, ids->compat))
return ids; return ids;
ids++; ids++;
} }
...@@ -168,10 +164,13 @@ static void probe_bus_pseries(void) ...@@ -168,10 +164,13 @@ static void probe_bus_pseries(void)
/** /**
* vio_bus_init: - Initialize the virtual IO bus * 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; int err;
is_match = match_func;
err = bus_register(&vio_bus_type); err = bus_register(&vio_bus_type);
if (err) { if (err) {
printk(KERN_ERR "failed to register VIO bus\n"); printk(KERN_ERR "failed to register VIO bus\n");
...@@ -192,6 +191,17 @@ int __init vio_bus_init(void) ...@@ -192,6 +191,17 @@ int __init vio_bus_init(void)
} }
#ifdef CONFIG_PPC_PSERIES #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 * vio_bus_init_pseries: - Initialize the pSeries virtual IO bus
*/ */
...@@ -199,7 +209,7 @@ static int __init vio_bus_init_pseries(void) ...@@ -199,7 +209,7 @@ static int __init vio_bus_init_pseries(void)
{ {
int err; int err;
err = vio_bus_init(); err = vio_bus_init(vio_match_device_pseries);
if (err == 0) if (err == 0)
probe_bus_pseries(); probe_bus_pseries();
return err; return err;
......
...@@ -105,6 +105,7 @@ static inline struct vio_dev *to_vio_dev(struct device *dev) ...@@ -105,6 +105,7 @@ static inline struct vio_dev *to_vio_dev(struct device *dev)
return container_of(dev, struct vio_dev, 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 */ #endif /* _ASM_VIO_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment