aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2007-12-17 14:54:39 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-01-24 23:40:26 -0500
commit35be0681983752116a8161ad3b30e830963108a4 (patch)
tree6eb3fe7dcc4ec690d8062912eb4b1e3ce17ad5b5 /drivers/infiniband
parent901195ed7f4b2f30dc5a36271887939c5d7bfb9f (diff)
Kobject: change drivers/infiniband to use kobject_init_and_add
Stop using kobject_register, as this way we can control the sending of the uevent properly, after everything is properly initialized. Cc: Roland Dreier <rolandd@cisco.com> Cc: Sean Hefty <mshefty@ichips.intel.com> Cc: Hal Rosenstock <hal.rosenstock@gmail.com> Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/core/sysfs.c35
1 files changed, 9 insertions, 26 deletions
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 3d4050681325..aa81129704cf 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -508,19 +508,10 @@ static int add_port(struct ib_device *device, int port_num)
508 508
509 p->ibdev = device; 509 p->ibdev = device;
510 p->port_num = port_num; 510 p->port_num = port_num;
511 p->kobj.ktype = &port_type;
512 511
513 p->kobj.parent = kobject_get(&device->ports_parent); 512 ret = kobject_init_and_add(&p->kobj, &port_type,
514 if (!p->kobj.parent) { 513 kobject_get(device->ports_parent),
515 ret = -EBUSY; 514 "%d", port_num);
516 goto err;
517 }
518
519 ret = kobject_set_name(&p->kobj, "%d", port_num);
520 if (ret)
521 goto err_put;
522
523 ret = kobject_register(&p->kobj);
524 if (ret) 515 if (ret)
525 goto err_put; 516 goto err_put;
526 517
@@ -549,6 +540,7 @@ static int add_port(struct ib_device *device, int port_num)
549 540
550 list_add_tail(&p->kobj.entry, &device->port_list); 541 list_add_tail(&p->kobj.entry, &device->port_list);
551 542
543 kobject_uevent(&p->kobj, KOBJ_ADD);
552 return 0; 544 return 0;
553 545
554err_free_pkey: 546err_free_pkey:
@@ -570,9 +562,7 @@ err_remove_pma:
570 sysfs_remove_group(&p->kobj, &pma_group); 562 sysfs_remove_group(&p->kobj, &pma_group);
571 563
572err_put: 564err_put:
573 kobject_put(&device->ports_parent); 565 kobject_put(device->ports_parent);
574
575err:
576 kfree(p); 566 kfree(p);
577 return ret; 567 return ret;
578} 568}
@@ -694,16 +684,9 @@ int ib_device_register_sysfs(struct ib_device *device)
694 goto err_unregister; 684 goto err_unregister;
695 } 685 }
696 686
697 device->ports_parent.parent = kobject_get(&class_dev->kobj); 687 device->ports_parent = kobject_create_and_add("ports",
698 if (!device->ports_parent.parent) { 688 kobject_get(&class_dev->kobj));
699 ret = -EBUSY; 689 if (!device->ports_parent)
700 goto err_unregister;
701 }
702 ret = kobject_set_name(&device->ports_parent, "ports");
703 if (ret)
704 goto err_put;
705 ret = kobject_register(&device->ports_parent);
706 if (ret)
707 goto err_put; 690 goto err_put;
708 691
709 if (device->node_type == RDMA_NODE_IB_SWITCH) { 692 if (device->node_type == RDMA_NODE_IB_SWITCH) {
@@ -758,7 +741,7 @@ void ib_device_unregister_sysfs(struct ib_device *device)
758 kobject_unregister(p); 741 kobject_unregister(p);
759 } 742 }
760 743
761 kobject_unregister(&device->ports_parent); 744 kobject_unregister(device->ports_parent);
762 class_device_unregister(&device->class_dev); 745 class_device_unregister(&device->class_dev);
763} 746}
764 747