Skip to content

Commit

Permalink
[POWERPC] ibmebus: Move to of_device and of_platform_driver, match eH…
Browse files Browse the repository at this point in the history
…CA and eHEA drivers

Replace struct ibmebus_dev and struct ibmebus_driver with struct of_device
and struct of_platform_driver, respectively.  Match the external ibmebus
interface and drivers using it.

Signed-off-by: Joachim Fenkes <fenkes@de.ibm.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Roland Dreier <rolandd@cisco.com>
Acked-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Joachim Fenkes authored and Paul Mackerras committed Oct 17, 2007
1 parent 55347cc commit 6b08f3a
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 101 deletions.
28 changes: 15 additions & 13 deletions arch/powerpc/kernel/ibmebus.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,34 +193,38 @@ static int ibmebus_create_devices(const struct of_device_id *matches)
return ret;
}

int ibmebus_register_driver(struct ibmebus_driver *drv)
int ibmebus_register_driver(struct of_platform_driver *drv)
{
return 0;
/* If the driver uses devices that ibmebus doesn't know, add them */
ibmebus_create_devices(drv->match_table);

drv->driver.name = drv->name;
drv->driver.bus = &ibmebus_bus_type;

return driver_register(&drv->driver);
}
EXPORT_SYMBOL(ibmebus_register_driver);

void ibmebus_unregister_driver(struct ibmebus_driver *drv)
void ibmebus_unregister_driver(struct of_platform_driver *drv)
{
driver_unregister(&drv->driver);
}
EXPORT_SYMBOL(ibmebus_unregister_driver);

int ibmebus_request_irq(struct ibmebus_dev *dev,
u32 ist,
irq_handler_t handler,
unsigned long irq_flags, const char * devname,
int ibmebus_request_irq(u32 ist, irq_handler_t handler,
unsigned long irq_flags, const char *devname,
void *dev_id)
{
unsigned int irq = irq_create_mapping(NULL, ist);

if (irq == NO_IRQ)
return -EINVAL;

return request_irq(irq, handler,
irq_flags, devname, dev_id);
return request_irq(irq, handler, irq_flags, devname, dev_id);
}
EXPORT_SYMBOL(ibmebus_request_irq);

void ibmebus_free_irq(struct ibmebus_dev *dev, u32 ist, void *dev_id)
void ibmebus_free_irq(u32 ist, void *dev_id)
{
unsigned int irq = irq_find_mapping(NULL, ist);

Expand All @@ -231,9 +235,7 @@ EXPORT_SYMBOL(ibmebus_free_irq);
static ssize_t name_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ibmebus_dev *ebus_dev = to_ibmebus_dev(dev);
const char *name = of_get_property(ebus_dev->ofdev.node, "name", NULL);
return sprintf(buf, "%s\n", name);
return sprintf(buf, "%s\n", to_of_device(dev)->node->name);
}

static struct device_attribute ibmebus_dev_attrs[] = {
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/hw/ehca/ehca_classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ struct ehca_sport {

struct ehca_shca {
struct ib_device ib_device;
struct ibmebus_dev *ibmebus_dev;
struct of_device *ofdev;
u8 num_ports;
int hw_level;
struct list_head shca_list;
Expand Down
6 changes: 3 additions & 3 deletions drivers/infiniband/hw/ehca/ehca_eq.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ int ehca_create_eq(struct ehca_shca *shca,

/* register interrupt handlers and initialize work queues */
if (type == EHCA_EQ) {
ret = ibmebus_request_irq(NULL, eq->ist, ehca_interrupt_eq,
ret = ibmebus_request_irq(eq->ist, ehca_interrupt_eq,
IRQF_DISABLED, "ehca_eq",
(void *)shca);
if (ret < 0)
ehca_err(ib_dev, "Can't map interrupt handler.");

tasklet_init(&eq->interrupt_task, ehca_tasklet_eq, (long)shca);
} else if (type == EHCA_NEQ) {
ret = ibmebus_request_irq(NULL, eq->ist, ehca_interrupt_neq,
ret = ibmebus_request_irq(eq->ist, ehca_interrupt_neq,
IRQF_DISABLED, "ehca_neq",
(void *)shca);
if (ret < 0)
Expand Down Expand Up @@ -171,7 +171,7 @@ int ehca_destroy_eq(struct ehca_shca *shca, struct ehca_eq *eq)
u64 h_ret;

spin_lock_irqsave(&eq->spinlock, flags);
ibmebus_free_irq(NULL, eq->ist, (void *)shca);
ibmebus_free_irq(eq->ist, (void *)shca);

h_ret = hipz_h_destroy_eq(shca->ipz_hca_handle, eq);

Expand Down
32 changes: 16 additions & 16 deletions drivers/infiniband/hw/ehca/ehca_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ int ehca_init_device(struct ehca_shca *shca)
shca->ib_device.node_type = RDMA_NODE_IB_CA;
shca->ib_device.phys_port_cnt = shca->num_ports;
shca->ib_device.num_comp_vectors = 1;
shca->ib_device.dma_device = &shca->ibmebus_dev->ofdev.dev;
shca->ib_device.dma_device = &shca->ofdev->dev;
shca->ib_device.query_device = ehca_query_device;
shca->ib_device.query_port = ehca_query_port;
shca->ib_device.query_gid = ehca_query_gid;
Expand Down Expand Up @@ -658,24 +658,24 @@ static struct attribute_group ehca_dev_attr_grp = {
.attrs = ehca_dev_attrs
};

static int __devinit ehca_probe(struct ibmebus_dev *dev,
static int __devinit ehca_probe(struct of_device *dev,
const struct of_device_id *id)
{
struct ehca_shca *shca;
const u64 *handle;
struct ib_pd *ibpd;
int ret;

handle = of_get_property(dev->ofdev.node, "ibm,hca-handle", NULL);
handle = of_get_property(dev->node, "ibm,hca-handle", NULL);
if (!handle) {
ehca_gen_err("Cannot get eHCA handle for adapter: %s.",
dev->ofdev.node->full_name);
dev->node->full_name);
return -ENODEV;
}

if (!(*handle)) {
ehca_gen_err("Wrong eHCA handle for adapter: %s.",
dev->ofdev.node->full_name);
dev->node->full_name);
return -ENODEV;
}

Expand All @@ -686,9 +686,9 @@ static int __devinit ehca_probe(struct ibmebus_dev *dev,
}
mutex_init(&shca->modify_mutex);

shca->ibmebus_dev = dev;
shca->ofdev = dev;
shca->ipz_hca_handle.handle = *handle;
dev->ofdev.dev.driver_data = shca;
dev->dev.driver_data = shca;

ret = ehca_sense_attributes(shca);
if (ret < 0) {
Expand Down Expand Up @@ -764,7 +764,7 @@ static int __devinit ehca_probe(struct ibmebus_dev *dev,
}
}

ret = sysfs_create_group(&dev->ofdev.dev.kobj, &ehca_dev_attr_grp);
ret = sysfs_create_group(&dev->dev.kobj, &ehca_dev_attr_grp);
if (ret) /* only complain; we can live without attributes */
ehca_err(&shca->ib_device,
"Cannot create device attributes ret=%d", ret);
Expand Down Expand Up @@ -814,12 +814,12 @@ static int __devinit ehca_probe(struct ibmebus_dev *dev,
return -EINVAL;
}

static int __devexit ehca_remove(struct ibmebus_dev *dev)
static int __devexit ehca_remove(struct of_device *dev)
{
struct ehca_shca *shca = dev->ofdev.dev.driver_data;
struct ehca_shca *shca = dev->dev.driver_data;
int ret;

sysfs_remove_group(&dev->ofdev.dev.kobj, &ehca_dev_attr_grp);
sysfs_remove_group(&dev->dev.kobj, &ehca_dev_attr_grp);

if (ehca_open_aqp1 == 1) {
int i;
Expand Down Expand Up @@ -870,11 +870,11 @@ static struct of_device_id ehca_device_table[] =
{},
};

static struct ibmebus_driver ehca_driver = {
.name = "ehca",
.id_table = ehca_device_table,
.probe = ehca_probe,
.remove = ehca_remove,
static struct of_platform_driver ehca_driver = {
.name = "ehca",
.match_table = ehca_device_table,
.probe = ehca_probe,
.remove = ehca_remove,
};

void ehca_poll_eqs(unsigned long data)
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ehea/ehea.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ struct ehea_port_res {
#define EHEA_MAX_PORTS 16
struct ehea_adapter {
u64 handle;
struct ibmebus_dev *ebus_dev;
struct of_device *ofdev;
struct ehea_port *port[EHEA_MAX_PORTS];
struct ehea_eq *neq; /* notification event queue */
struct tasklet_struct neq_tasklet;
Expand Down
Loading

0 comments on commit 6b08f3a

Please sign in to comment.