[PATCH] Create vio_bus_ops

Create vio_bus_ops so that we just pass a structure to vio_bus_init
instead of three separate function pointers.

Rearrange vio.h to avoid forward references. vio.h only needs
struct device_node from prom.h so remove the include and just
declare it.

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
71d276d7 b877b90f

+69 -69
+5 -1
arch/ppc64/kernel/iSeries_vio.c
··· 131 131 return strncmp(dev->type, id->type, strlen(id->type)) == 0; 132 132 } 133 133 134 + static struct vio_bus_ops vio_bus_ops_iseries = { 135 + .match = vio_match_device_iseries, 136 + }; 137 + 134 138 /** 135 139 * vio_bus_init_iseries: - Initialize the iSeries virtual IO bus 136 140 */ ··· 142 138 { 143 139 int err; 144 140 145 - err = vio_bus_init(vio_match_device_iseries, NULL, NULL); 141 + err = vio_bus_init(&vio_bus_ops_iseries); 146 142 if (err == 0) { 147 143 iommu_vio_init(); 148 144 vio_bus_device.iommu_table = &vio_iommu_table;
+7 -3
arch/ppc64/kernel/pSeries_vio.c
··· 76 76 device_remove_file(&viodev->dev, &dev_attr_devspec); 77 77 } 78 78 79 + static struct vio_bus_ops vio_bus_ops_pseries = { 80 + .match = vio_match_device_pseries, 81 + .unregister_device = vio_unregister_device_pseries, 82 + .release_device = vio_release_device_pseries, 83 + }; 84 + 79 85 /** 80 86 * vio_bus_init_pseries: - Initialize the pSeries virtual IO bus 81 87 */ ··· 89 83 { 90 84 int err; 91 85 92 - err = vio_bus_init(vio_match_device_pseries, 93 - vio_unregister_device_pseries, 94 - vio_release_device_pseries); 86 + err = vio_bus_init(&vio_bus_ops_pseries); 95 87 if (err == 0) 96 88 probe_bus_pseries(); 97 89 return err;
+8 -16
arch/ppc64/kernel/vio.c
··· 32 32 .dev.bus = &vio_bus_type, 33 33 }; 34 34 35 - static int (*is_match)(const struct vio_device_id *id, 36 - const struct vio_dev *dev); 37 - static void (*unregister_device_callback)(struct vio_dev *dev); 38 - static void (*release_device_callback)(struct device *dev); 35 + static struct vio_bus_ops vio_bus_ops; 39 36 40 37 /* 41 38 * Convert from struct device to struct vio_dev and pass to driver. ··· 112 115 const struct vio_device_id *ids, const struct vio_dev *dev) 113 116 { 114 117 while (ids->type) { 115 - if (is_match(ids, dev)) 118 + if (vio_bus_ops.match(ids, dev)) 116 119 return ids; 117 120 ids++; 118 121 } ··· 122 125 /** 123 126 * vio_bus_init: - Initialize the virtual IO bus 124 127 */ 125 - int __init vio_bus_init(int (*match_func)(const struct vio_device_id *id, 126 - const struct vio_dev *dev), 127 - void (*unregister_dev)(struct vio_dev *), 128 - void (*release_dev)(struct device *)) 128 + int __init vio_bus_init(struct vio_bus_ops *ops) 129 129 { 130 130 int err; 131 131 132 - is_match = match_func; 133 - unregister_device_callback = unregister_dev; 134 - release_device_callback = release_dev; 132 + vio_bus_ops = *ops; 135 133 136 134 err = bus_register(&vio_bus_type); 137 135 if (err) { ··· 151 159 /* vio_dev refcount hit 0 */ 152 160 static void __devinit vio_dev_release(struct device *dev) 153 161 { 154 - if (release_device_callback) 155 - release_device_callback(dev); 162 + if (vio_bus_ops.release_device) 163 + vio_bus_ops.release_device(dev); 156 164 kfree(to_vio_dev(dev)); 157 165 } 158 166 ··· 183 191 184 192 void __devinit vio_unregister_device(struct vio_dev *viodev) 185 193 { 186 - if (unregister_device_callback) 187 - unregister_device_callback(viodev); 194 + if (vio_bus_ops.unregister_device) 195 + vio_bus_ops.unregister_device(viodev); 188 196 device_remove_file(&viodev->dev, &dev_attr_name); 189 197 device_unregister(&viodev->dev); 190 198 }
+1
drivers/scsi/ibmvscsi/rpa_vscsi.c
··· 28 28 */ 29 29 30 30 #include <asm/vio.h> 31 + #include <asm/prom.h> 31 32 #include <asm/iommu.h> 32 33 #include <asm/hvcall.h> 33 34 #include <linux/dma-mapping.h>
+48 -49
include/asm-ppc64/vio.h
··· 19 19 #include <linux/errno.h> 20 20 #include <linux/device.h> 21 21 #include <linux/dma-mapping.h> 22 + 22 23 #include <asm/hvcall.h> 23 - #include <asm/prom.h> 24 24 #include <asm/scatterlist.h> 25 - /* 25 + 26 + /* 26 27 * Architecture-specific constants for drivers to 27 28 * extract attributes of the device using vio_get_attribute() 28 - */ 29 + */ 29 30 #define VETH_MAC_ADDR "local-mac-address" 30 31 #define VETH_MCAST_FILTER_SIZE "ibm,mac-address-filters" 31 32 ··· 38 37 #define VIO_IRQ_DISABLE 0UL 39 38 #define VIO_IRQ_ENABLE 1UL 40 39 41 - struct vio_dev; 42 - struct vio_driver; 43 - struct vio_device_id; 44 40 struct iommu_table; 45 41 46 - int vio_register_driver(struct vio_driver *drv); 47 - void vio_unregister_driver(struct vio_driver *drv); 48 - 49 - #ifdef CONFIG_PPC_PSERIES 50 - struct vio_dev * __devinit vio_register_device_node( 51 - struct device_node *node_vdev); 52 - #endif 53 - void __devinit vio_unregister_device(struct vio_dev *dev); 54 - struct vio_dev *vio_find_node(struct device_node *vnode); 55 - 56 - const void * vio_get_attribute(struct vio_dev *vdev, void* which, int* length); 57 - int vio_get_irq(struct vio_dev *dev); 58 - int vio_enable_interrupts(struct vio_dev *dev); 59 - int vio_disable_interrupts(struct vio_dev *dev); 60 - extern struct vio_dev * __devinit vio_register_device(struct vio_dev *viodev); 61 - 62 - extern struct dma_mapping_ops vio_dma_ops; 63 - 64 - extern struct bus_type vio_bus_type; 42 + /* 43 + * The vio_dev structure is used to describe virtual I/O devices. 44 + */ 45 + struct vio_dev { 46 + struct iommu_table *iommu_table; /* vio_map_* uses this */ 47 + char *name; 48 + char *type; 49 + uint32_t unit_address; 50 + unsigned int irq; 51 + struct device dev; 52 + }; 65 53 66 54 struct vio_device_id { 67 55 char *type; ··· 60 70 struct vio_driver { 61 71 struct list_head node; 62 72 char *name; 63 - const struct vio_device_id *id_table; /* NULL if wants all devices */ 64 - int (*probe) (struct vio_dev *dev, const struct vio_device_id *id); /* New device inserted */ 65 - int (*remove) (struct vio_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */ 73 + const struct vio_device_id *id_table; 74 + int (*probe)(struct vio_dev *dev, const struct vio_device_id *id); 75 + int (*remove)(struct vio_dev *dev); 66 76 unsigned long driver_data; 67 - 68 77 struct device_driver driver; 69 78 }; 79 + 80 + struct vio_bus_ops { 81 + int (*match)(const struct vio_device_id *id, const struct vio_dev *dev); 82 + void (*unregister_device)(struct vio_dev *); 83 + void (*release_device)(struct device *); 84 + }; 85 + 86 + extern struct dma_mapping_ops vio_dma_ops; 87 + extern struct bus_type vio_bus_type; 88 + extern struct vio_dev vio_bus_device; 89 + 90 + extern int vio_register_driver(struct vio_driver *drv); 91 + extern void vio_unregister_driver(struct vio_driver *drv); 92 + 93 + extern struct vio_dev * __devinit vio_register_device(struct vio_dev *viodev); 94 + extern void __devinit vio_unregister_device(struct vio_dev *dev); 95 + 96 + extern int vio_bus_init(struct vio_bus_ops *); 97 + 98 + #ifdef CONFIG_PPC_PSERIES 99 + struct device_node; 100 + 101 + extern struct vio_dev * __devinit vio_register_device_node( 102 + struct device_node *node_vdev); 103 + extern struct vio_dev *vio_find_node(struct device_node *vnode); 104 + extern const void *vio_get_attribute(struct vio_dev *vdev, void *which, 105 + int *length); 106 + extern int vio_enable_interrupts(struct vio_dev *dev); 107 + extern int vio_disable_interrupts(struct vio_dev *dev); 108 + #endif 70 109 71 110 static inline struct vio_driver *to_vio_driver(struct device_driver *drv) 72 111 { 73 112 return container_of(drv, struct vio_driver, driver); 74 113 } 75 114 76 - /* 77 - * The vio_dev structure is used to describe virtual I/O devices. 78 - */ 79 - struct vio_dev { 80 - struct iommu_table *iommu_table; /* vio_map_* uses this */ 81 - char *name; 82 - char *type; 83 - uint32_t unit_address; 84 - unsigned int irq; 85 - 86 - struct device dev; 87 - }; 88 - 89 - extern struct vio_dev vio_bus_device; 90 - 91 115 static inline struct vio_dev *to_vio_dev(struct device *dev) 92 116 { 93 117 return container_of(dev, struct vio_dev, dev); 94 118 } 95 - 96 - extern int vio_bus_init(int (*is_match)(const struct vio_device_id *id, 97 - const struct vio_dev *dev), 98 - void (*)(struct vio_dev *), 99 - void (*)(struct device *)); 100 119 101 120 #endif /* _ASM_VIO_H */