[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>
This commit is contained in:
parent
5c0b4b8759
commit
b877b90f22
|
@ -68,7 +68,7 @@ static void __init iommu_vio_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* vio_register_device: - Register a new vio device.
|
* vio_register_device_iseries: - Register a new iSeries vio device.
|
||||||
* @voidev: The device to register.
|
* @voidev: The device to register.
|
||||||
*/
|
*/
|
||||||
static struct vio_dev *__init vio_register_device_iseries(char *type,
|
static struct vio_dev *__init vio_register_device_iseries(char *type,
|
||||||
|
@ -76,7 +76,7 @@ static struct vio_dev *__init vio_register_device_iseries(char *type,
|
||||||
{
|
{
|
||||||
struct vio_dev *viodev;
|
struct vio_dev *viodev;
|
||||||
|
|
||||||
/* allocate a vio_dev for this node */
|
/* allocate a vio_dev for this device */
|
||||||
viodev = kmalloc(sizeof(struct vio_dev), GFP_KERNEL);
|
viodev = kmalloc(sizeof(struct vio_dev), GFP_KERNEL);
|
||||||
if (!viodev)
|
if (!viodev)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -84,8 +84,15 @@ static struct vio_dev *__init vio_register_device_iseries(char *type,
|
||||||
|
|
||||||
snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%s%d", type, unit_num);
|
snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%s%d", type, unit_num);
|
||||||
|
|
||||||
return vio_register_device_common(viodev, viodev->dev.bus_id, type,
|
viodev->name = viodev->dev.bus_id;
|
||||||
unit_num, &vio_iommu_table);
|
viodev->type = type;
|
||||||
|
viodev->unit_address = unit_num;
|
||||||
|
viodev->iommu_table = &vio_iommu_table;
|
||||||
|
if (vio_register_device(viodev) == NULL) {
|
||||||
|
kfree(viodev);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return viodev;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __init probe_bus_iseries(void)
|
void __init probe_bus_iseries(void)
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <linux/kobject.h>
|
#include <linux/kobject.h>
|
||||||
#include <asm/iommu.h>
|
#include <asm/iommu.h>
|
||||||
#include <asm/dma.h>
|
#include <asm/dma.h>
|
||||||
|
#include <asm/prom.h>
|
||||||
#include <asm/vio.h>
|
#include <asm/vio.h>
|
||||||
#include <asm/hvcall.h>
|
#include <asm/hvcall.h>
|
||||||
|
|
||||||
|
@ -181,11 +182,13 @@ struct vio_dev * __devinit vio_register_device_node(struct device_node *of_node)
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%x", *unit_address);
|
snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%x", *unit_address);
|
||||||
|
viodev->name = of_node->name;
|
||||||
|
viodev->type = of_node->type;
|
||||||
|
viodev->unit_address = *unit_address;
|
||||||
|
viodev->iommu_table = vio_build_iommu_table(viodev);
|
||||||
|
|
||||||
/* register with generic device framework */
|
/* register with generic device framework */
|
||||||
if (vio_register_device_common(viodev, of_node->name, of_node->type,
|
if (vio_register_device(viodev) == NULL) {
|
||||||
*unit_address, vio_build_iommu_table(viodev))
|
|
||||||
== NULL) {
|
|
||||||
/* XXX free TCE table */
|
/* XXX free TCE table */
|
||||||
kfree(viodev);
|
kfree(viodev);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -171,14 +171,8 @@ static ssize_t viodev_show_name(struct device *dev,
|
||||||
}
|
}
|
||||||
DEVICE_ATTR(name, S_IRUSR | S_IRGRP | S_IROTH, viodev_show_name, NULL);
|
DEVICE_ATTR(name, S_IRUSR | S_IRGRP | S_IROTH, viodev_show_name, NULL);
|
||||||
|
|
||||||
struct vio_dev * __devinit vio_register_device_common(
|
struct vio_dev * __devinit vio_register_device(struct vio_dev *viodev)
|
||||||
struct vio_dev *viodev, char *name, char *type,
|
|
||||||
uint32_t unit_address, struct iommu_table *iommu_table)
|
|
||||||
{
|
{
|
||||||
viodev->name = name;
|
|
||||||
viodev->type = type;
|
|
||||||
viodev->unit_address = unit_address;
|
|
||||||
viodev->iommu_table = iommu_table;
|
|
||||||
/* init generic 'struct device' fields: */
|
/* init generic 'struct device' fields: */
|
||||||
viodev->dev.parent = &vio_bus_device.dev;
|
viodev->dev.parent = &vio_bus_device.dev;
|
||||||
viodev->dev.bus = &vio_bus_type;
|
viodev->dev.bus = &vio_bus_type;
|
||||||
|
|
|
@ -56,9 +56,7 @@ const void * vio_get_attribute(struct vio_dev *vdev, void* which, int* length);
|
||||||
int vio_get_irq(struct vio_dev *dev);
|
int vio_get_irq(struct vio_dev *dev);
|
||||||
int vio_enable_interrupts(struct vio_dev *dev);
|
int vio_enable_interrupts(struct vio_dev *dev);
|
||||||
int vio_disable_interrupts(struct vio_dev *dev);
|
int vio_disable_interrupts(struct vio_dev *dev);
|
||||||
extern struct vio_dev * __devinit vio_register_device_common(
|
extern struct vio_dev * __devinit vio_register_device(struct vio_dev *viodev);
|
||||||
struct vio_dev *viodev, char *name, char *type,
|
|
||||||
uint32_t unit_address, struct iommu_table *iommu_table);
|
|
||||||
|
|
||||||
extern struct dma_mapping_ops vio_dma_ops;
|
extern struct dma_mapping_ops vio_dma_ops;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue