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