[PATCH] Create vio_register_device

Take some assignments out of vio_register_device_common and
rename it to vio_register_device.

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
b877b90f 5c0b4b87

+19 -17
+11 -4
arch/ppc64/kernel/iSeries_vio.c
··· 68 } 69 70 /** 71 - * vio_register_device: - Register a new vio device. 72 * @voidev: The device to register. 73 */ 74 static struct vio_dev *__init vio_register_device_iseries(char *type, ··· 76 { 77 struct vio_dev *viodev; 78 79 - /* allocate a vio_dev for this node */ 80 viodev = kmalloc(sizeof(struct vio_dev), GFP_KERNEL); 81 if (!viodev) 82 return NULL; ··· 84 85 snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%s%d", type, unit_num); 86 87 - return vio_register_device_common(viodev, viodev->dev.bus_id, type, 88 - unit_num, &vio_iommu_table); 89 } 90 91 void __init probe_bus_iseries(void)
··· 68 } 69 70 /** 71 + * vio_register_device_iseries: - Register a new iSeries vio device. 72 * @voidev: The device to register. 73 */ 74 static struct vio_dev *__init vio_register_device_iseries(char *type, ··· 76 { 77 struct vio_dev *viodev; 78 79 + /* allocate a vio_dev for this device */ 80 viodev = kmalloc(sizeof(struct vio_dev), GFP_KERNEL); 81 if (!viodev) 82 return NULL; ··· 84 85 snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%s%d", type, unit_num); 86 87 + viodev->name = viodev->dev.bus_id; 88 + viodev->type = type; 89 + viodev->unit_address = unit_num; 90 + viodev->iommu_table = &vio_iommu_table; 91 + if (vio_register_device(viodev) == NULL) { 92 + kfree(viodev); 93 + return NULL; 94 + } 95 + return viodev; 96 } 97 98 void __init probe_bus_iseries(void)
+6 -3
arch/ppc64/kernel/pSeries_vio.c
··· 19 #include <linux/kobject.h> 20 #include <asm/iommu.h> 21 #include <asm/dma.h> 22 #include <asm/vio.h> 23 #include <asm/hvcall.h> 24 ··· 182 } 183 184 snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%x", *unit_address); 185 186 /* register with generic device framework */ 187 - if (vio_register_device_common(viodev, of_node->name, of_node->type, 188 - *unit_address, vio_build_iommu_table(viodev)) 189 - == NULL) { 190 /* XXX free TCE table */ 191 kfree(viodev); 192 return NULL;
··· 19 #include <linux/kobject.h> 20 #include <asm/iommu.h> 21 #include <asm/dma.h> 22 + #include <asm/prom.h> 23 #include <asm/vio.h> 24 #include <asm/hvcall.h> 25 ··· 181 } 182 183 snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%x", *unit_address); 184 + viodev->name = of_node->name; 185 + viodev->type = of_node->type; 186 + viodev->unit_address = *unit_address; 187 + viodev->iommu_table = vio_build_iommu_table(viodev); 188 189 /* register with generic device framework */ 190 + if (vio_register_device(viodev) == NULL) { 191 /* XXX free TCE table */ 192 kfree(viodev); 193 return NULL;
+1 -7
arch/ppc64/kernel/vio.c
··· 171 } 172 DEVICE_ATTR(name, S_IRUSR | S_IRGRP | S_IROTH, viodev_show_name, NULL); 173 174 - struct vio_dev * __devinit vio_register_device_common( 175 - struct vio_dev *viodev, char *name, char *type, 176 - uint32_t unit_address, struct iommu_table *iommu_table) 177 { 178 - viodev->name = name; 179 - viodev->type = type; 180 - viodev->unit_address = unit_address; 181 - viodev->iommu_table = iommu_table; 182 /* init generic 'struct device' fields: */ 183 viodev->dev.parent = &vio_bus_device.dev; 184 viodev->dev.bus = &vio_bus_type;
··· 171 } 172 DEVICE_ATTR(name, S_IRUSR | S_IRGRP | S_IROTH, viodev_show_name, NULL); 173 174 + struct vio_dev * __devinit vio_register_device(struct vio_dev *viodev) 175 { 176 /* init generic 'struct device' fields: */ 177 viodev->dev.parent = &vio_bus_device.dev; 178 viodev->dev.bus = &vio_bus_type;
+1 -3
include/asm-ppc64/vio.h
··· 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_common( 60 - struct vio_dev *viodev, char *name, char *type, 61 - uint32_t unit_address, struct iommu_table *iommu_table); 62 63 extern struct dma_mapping_ops vio_dma_ops; 64
··· 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