Commit 71d276d751ff5ddba28312aecefb174b20a5b970
Committed by
Paul Mackerras
1 parent
b877b90f22
Exists in
master
and in
4 other branches
[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>
Showing 5 changed files with 69 additions and 69 deletions Side-by-side Diff
arch/ppc64/kernel/iSeries_vio.c
| ... | ... | @@ -131,6 +131,10 @@ |
| 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 | */ |
| ... | ... | @@ -138,7 +142,7 @@ |
| 138 | 142 | { |
| 139 | 143 | int err; |
| 140 | 144 | |
| 141 | - err = vio_bus_init(vio_match_device_iseries, NULL, NULL); | |
| 145 | + err = vio_bus_init(&vio_bus_ops_iseries); | |
| 142 | 146 | if (err == 0) { |
| 143 | 147 | iommu_vio_init(); |
| 144 | 148 | vio_bus_device.iommu_table = &vio_iommu_table; |
arch/ppc64/kernel/pSeries_vio.c
| ... | ... | @@ -76,6 +76,12 @@ |
| 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 | */ |
| ... | ... | @@ -83,9 +89,7 @@ |
| 83 | 89 | { |
| 84 | 90 | int err; |
| 85 | 91 | |
| 86 | - err = vio_bus_init(vio_match_device_pseries, | |
| 87 | - vio_unregister_device_pseries, | |
| 88 | - vio_release_device_pseries); | |
| 92 | + err = vio_bus_init(&vio_bus_ops_pseries); | |
| 89 | 93 | if (err == 0) |
| 90 | 94 | probe_bus_pseries(); |
| 91 | 95 | return err; |
arch/ppc64/kernel/vio.c
| ... | ... | @@ -32,10 +32,7 @@ |
| 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. |
| ... | ... | @@ -115,7 +112,7 @@ |
| 115 | 112 | const struct vio_device_id *ids, const struct vio_dev *dev) |
| 116 | 113 | { |
| 117 | 114 | while (ids->type) { |
| 118 | - if (is_match(ids, dev)) | |
| 115 | + if (vio_bus_ops.match(ids, dev)) | |
| 119 | 116 | return ids; |
| 120 | 117 | ids++; |
| 121 | 118 | } |
| 122 | 119 | |
| ... | ... | @@ -125,16 +122,11 @@ |
| 125 | 122 | /** |
| 126 | 123 | * vio_bus_init: - Initialize the virtual IO bus |
| 127 | 124 | */ |
| 128 | -int __init vio_bus_init(int (*match_func)(const struct vio_device_id *id, | |
| 129 | - const struct vio_dev *dev), | |
| 130 | - void (*unregister_dev)(struct vio_dev *), | |
| 131 | - void (*release_dev)(struct device *)) | |
| 125 | +int __init vio_bus_init(struct vio_bus_ops *ops) | |
| 132 | 126 | { |
| 133 | 127 | int err; |
| 134 | 128 | |
| 135 | - is_match = match_func; | |
| 136 | - unregister_device_callback = unregister_dev; | |
| 137 | - release_device_callback = release_dev; | |
| 129 | + vio_bus_ops = *ops; | |
| 138 | 130 | |
| 139 | 131 | err = bus_register(&vio_bus_type); |
| 140 | 132 | if (err) { |
| ... | ... | @@ -159,8 +151,8 @@ |
| 159 | 151 | /* vio_dev refcount hit 0 */ |
| 160 | 152 | static void __devinit vio_dev_release(struct device *dev) |
| 161 | 153 | { |
| 162 | - if (release_device_callback) | |
| 163 | - release_device_callback(dev); | |
| 154 | + if (vio_bus_ops.release_device) | |
| 155 | + vio_bus_ops.release_device(dev); | |
| 164 | 156 | kfree(to_vio_dev(dev)); |
| 165 | 157 | } |
| 166 | 158 | |
| ... | ... | @@ -191,8 +183,8 @@ |
| 191 | 183 | |
| 192 | 184 | void __devinit vio_unregister_device(struct vio_dev *viodev) |
| 193 | 185 | { |
| 194 | - if (unregister_device_callback) | |
| 195 | - unregister_device_callback(viodev); | |
| 186 | + if (vio_bus_ops.unregister_device) | |
| 187 | + vio_bus_ops.unregister_device(viodev); | |
| 196 | 188 | device_remove_file(&viodev->dev, &dev_attr_name); |
| 197 | 189 | device_unregister(&viodev->dev); |
| 198 | 190 | } |
drivers/scsi/ibmvscsi/rpa_vscsi.c
include/asm-ppc64/vio.h
| ... | ... | @@ -19,13 +19,14 @@ |
| 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 | |
| 32 | 33 | |
| 33 | 34 | |
| ... | ... | @@ -37,31 +38,20 @@ |
| 37 | 38 | #define VIO_IRQ_DISABLE 0UL |
| 38 | 39 | #define VIO_IRQ_ENABLE 1UL |
| 39 | 40 | |
| 40 | -struct vio_dev; | |
| 41 | -struct vio_driver; | |
| 42 | -struct vio_device_id; | |
| 43 | 41 | struct iommu_table; |
| 44 | 42 | |
| 45 | -int vio_register_driver(struct vio_driver *drv); | |
| 46 | -void vio_unregister_driver(struct vio_driver *drv); | |
| 43 | +/* | |
| 44 | + * The vio_dev structure is used to describe virtual I/O devices. | |
| 45 | + */ | |
| 46 | +struct vio_dev { | |
| 47 | + struct iommu_table *iommu_table; /* vio_map_* uses this */ | |
| 48 | + char *name; | |
| 49 | + char *type; | |
| 50 | + uint32_t unit_address; | |
| 51 | + unsigned int irq; | |
| 52 | + struct device dev; | |
| 53 | +}; | |
| 47 | 54 | |
| 48 | -#ifdef CONFIG_PPC_PSERIES | |
| 49 | -struct vio_dev * __devinit vio_register_device_node( | |
| 50 | - struct device_node *node_vdev); | |
| 51 | -#endif | |
| 52 | -void __devinit vio_unregister_device(struct vio_dev *dev); | |
| 53 | -struct vio_dev *vio_find_node(struct device_node *vnode); | |
| 54 | - | |
| 55 | -const void * vio_get_attribute(struct vio_dev *vdev, void* which, int* length); | |
| 56 | -int vio_get_irq(struct vio_dev *dev); | |
| 57 | -int vio_enable_interrupts(struct vio_dev *dev); | |
| 58 | -int vio_disable_interrupts(struct vio_dev *dev); | |
| 59 | -extern struct vio_dev * __devinit vio_register_device(struct vio_dev *viodev); | |
| 60 | - | |
| 61 | -extern struct dma_mapping_ops vio_dma_ops; | |
| 62 | - | |
| 63 | -extern struct bus_type vio_bus_type; | |
| 64 | - | |
| 65 | 55 | struct vio_device_id { |
| 66 | 56 | char *type; |
| 67 | 57 | char *compat; |
| 68 | 58 | |
| 69 | 59 | |
| 70 | 60 | |
| 71 | 61 | |
| ... | ... | @@ -70,43 +60,52 @@ |
| 70 | 60 | struct vio_driver { |
| 71 | 61 | struct list_head node; |
| 72 | 62 | char *name; |
| 73 | - const struct vio_device_id *id_table; /* NULL if wants all devices */ | |
| 74 | - int (*probe) (struct vio_dev *dev, const struct vio_device_id *id); /* New device inserted */ | |
| 75 | - int (*remove) (struct vio_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */ | |
| 63 | + const struct vio_device_id *id_table; | |
| 64 | + int (*probe)(struct vio_dev *dev, const struct vio_device_id *id); | |
| 65 | + int (*remove)(struct vio_dev *dev); | |
| 76 | 66 | unsigned long driver_data; |
| 77 | - | |
| 78 | 67 | struct device_driver driver; |
| 79 | 68 | }; |
| 80 | 69 | |
| 70 | +struct vio_bus_ops { | |
| 71 | + int (*match)(const struct vio_device_id *id, const struct vio_dev *dev); | |
| 72 | + void (*unregister_device)(struct vio_dev *); | |
| 73 | + void (*release_device)(struct device *); | |
| 74 | +}; | |
| 75 | + | |
| 76 | +extern struct dma_mapping_ops vio_dma_ops; | |
| 77 | +extern struct bus_type vio_bus_type; | |
| 78 | +extern struct vio_dev vio_bus_device; | |
| 79 | + | |
| 80 | +extern int vio_register_driver(struct vio_driver *drv); | |
| 81 | +extern void vio_unregister_driver(struct vio_driver *drv); | |
| 82 | + | |
| 83 | +extern struct vio_dev * __devinit vio_register_device(struct vio_dev *viodev); | |
| 84 | +extern void __devinit vio_unregister_device(struct vio_dev *dev); | |
| 85 | + | |
| 86 | +extern int vio_bus_init(struct vio_bus_ops *); | |
| 87 | + | |
| 88 | +#ifdef CONFIG_PPC_PSERIES | |
| 89 | +struct device_node; | |
| 90 | + | |
| 91 | +extern struct vio_dev * __devinit vio_register_device_node( | |
| 92 | + struct device_node *node_vdev); | |
| 93 | +extern struct vio_dev *vio_find_node(struct device_node *vnode); | |
| 94 | +extern const void *vio_get_attribute(struct vio_dev *vdev, void *which, | |
| 95 | + int *length); | |
| 96 | +extern int vio_enable_interrupts(struct vio_dev *dev); | |
| 97 | +extern int vio_disable_interrupts(struct vio_dev *dev); | |
| 98 | +#endif | |
| 99 | + | |
| 81 | 100 | static inline struct vio_driver *to_vio_driver(struct device_driver *drv) |
| 82 | 101 | { |
| 83 | 102 | return container_of(drv, struct vio_driver, driver); |
| 84 | 103 | } |
| 85 | 104 | |
| 86 | -/* | |
| 87 | - * The vio_dev structure is used to describe virtual I/O devices. | |
| 88 | - */ | |
| 89 | -struct vio_dev { | |
| 90 | - struct iommu_table *iommu_table; /* vio_map_* uses this */ | |
| 91 | - char *name; | |
| 92 | - char *type; | |
| 93 | - uint32_t unit_address; | |
| 94 | - unsigned int irq; | |
| 95 | - | |
| 96 | - struct device dev; | |
| 97 | -}; | |
| 98 | - | |
| 99 | -extern struct vio_dev vio_bus_device; | |
| 100 | - | |
| 101 | 105 | static inline struct vio_dev *to_vio_dev(struct device *dev) |
| 102 | 106 | { |
| 103 | 107 | return container_of(dev, struct vio_dev, dev); |
| 104 | 108 | } |
| 105 | - | |
| 106 | -extern int vio_bus_init(int (*is_match)(const struct vio_device_id *id, | |
| 107 | - const struct vio_dev *dev), | |
| 108 | - void (*)(struct vio_dev *), | |
| 109 | - void (*)(struct device *)); | |
| 110 | 109 | |
| 111 | 110 | #endif /* _ASM_VIO_H */ |