[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: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by

Stephen Rothwell and committed by
Paul Mackerras
6312236f 8c65b5c9

+32 -11
+11 -1
arch/ppc64/kernel/iSeries_vio.c
··· 115 } 116 117 /** 118 * vio_bus_init_iseries: - Initialize the iSeries virtual IO bus 119 */ 120 static int __init vio_bus_init_iseries(void) 121 { 122 int err; 123 124 - err = vio_bus_init(); 125 if (err == 0) { 126 iommu_vio_init(); 127 vio_bus_device.iommu_table = &vio_iommu_table;
··· 115 } 116 117 /** 118 + * vio_match_device_iseries: - Tell if a iSeries VIO device matches a 119 + * vio_device_id 120 + */ 121 + static int vio_match_device_iseries(const struct vio_device_id *id, 122 + const struct vio_dev *dev) 123 + { 124 + return strncmp(dev->type, id->type, strlen(id->type)) == 0; 125 + } 126 + 127 + /** 128 * vio_bus_init_iseries: - Initialize the iSeries virtual IO bus 129 */ 130 static int __init vio_bus_init_iseries(void) 131 { 132 int err; 133 134 + err = vio_bus_init(vio_match_device_iseries); 135 if (err == 0) { 136 iommu_vio_init(); 137 vio_bus_device.iommu_table = &vio_iommu_table;
+19 -9
arch/ppc64/kernel/vio.c
··· 44 .dev.bus = &vio_bus_type, 45 }; 46 47 - #ifdef CONFIG_PPC_ISERIES 48 - 49 - #define device_is_compatible(a, b) 1 50 - 51 - #endif 52 53 /* convert from struct device to struct vio_dev and pass to driver. 54 * dev->driver has already been set by generic code because vio_bus_match ··· 130 DBGENTER(); 131 132 while (ids->type) { 133 - if ((strncmp(dev->type, ids->type, strlen(ids->type)) == 0) && 134 - device_is_compatible(dev->dev.platform_data, ids->compat)) 135 return ids; 136 ids++; 137 } ··· 164 /** 165 * vio_bus_init: - Initialize the virtual IO bus 166 */ 167 - int __init vio_bus_init(void) 168 { 169 int err; 170 171 err = bus_register(&vio_bus_type); 172 if (err) { ··· 192 193 #ifdef CONFIG_PPC_PSERIES 194 /** 195 * vio_bus_init_pseries: - Initialize the pSeries virtual IO bus 196 */ 197 static int __init vio_bus_init_pseries(void) 198 { 199 int err; 200 201 - err = vio_bus_init(); 202 if (err == 0) 203 probe_bus_pseries(); 204 return err;
··· 44 .dev.bus = &vio_bus_type, 45 }; 46 47 + static int (*is_match)(const struct vio_device_id *id, 48 + const struct vio_dev *dev); 49 50 /* convert from struct device to struct vio_dev and pass to driver. 51 * dev->driver has already been set by generic code because vio_bus_match ··· 133 DBGENTER(); 134 135 while (ids->type) { 136 + if (is_match(ids, dev)) 137 return ids; 138 ids++; 139 } ··· 168 /** 169 * vio_bus_init: - Initialize the virtual IO bus 170 */ 171 + int __init vio_bus_init(int (*match_func)(const struct vio_device_id *id, 172 + const struct vio_dev *dev)) 173 { 174 int err; 175 + 176 + is_match = match_func; 177 178 err = bus_register(&vio_bus_type); 179 if (err) { ··· 193 194 #ifdef CONFIG_PPC_PSERIES 195 /** 196 + * vio_match_device_pseries: - Tell if a pSeries VIO device matches a 197 + * vio_device_id 198 + */ 199 + static int vio_match_device_pseries(const struct vio_device_id *id, 200 + const struct vio_dev *dev) 201 + { 202 + return (strncmp(dev->type, id->type, strlen(id->type)) == 0) && 203 + device_is_compatible(dev->dev.platform_data, id->compat); 204 + } 205 + 206 + /** 207 * vio_bus_init_pseries: - Initialize the pSeries virtual IO bus 208 */ 209 static int __init vio_bus_init_pseries(void) 210 { 211 int err; 212 213 + err = vio_bus_init(vio_match_device_pseries); 214 if (err == 0) 215 probe_bus_pseries(); 216 return err;
+2 -1
include/asm-ppc64/vio.h
··· 105 return container_of(dev, struct vio_dev, dev); 106 } 107 108 - extern int vio_bus_init(void); 109 110 #endif /* _ASM_VIO_H */
··· 105 return container_of(dev, struct vio_dev, dev); 106 } 107 108 + extern int vio_bus_init(int (*is_match)(const struct vio_device_id *id, 109 + const struct vio_dev *dev)); 110 111 #endif /* _ASM_VIO_H */