diff options
-rw-r--r-- | drivers/infiniband/core/sysfs.c | 35 | ||||
-rw-r--r-- | include/rdma/ib_verbs.h | 2 |
2 files changed, 10 insertions, 27 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 | ||
554 | err_free_pkey: | 546 | err_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 | ||
572 | err_put: | 564 | err_put: |
573 | kobject_put(&device->ports_parent); | 565 | kobject_put(device->ports_parent); |
574 | |||
575 | err: | ||
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 | ||
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 11f39606e7d9..cfbd38fe2998 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h | |||
@@ -1026,7 +1026,7 @@ struct ib_device { | |||
1026 | 1026 | ||
1027 | struct module *owner; | 1027 | struct module *owner; |
1028 | struct class_device class_dev; | 1028 | struct class_device class_dev; |
1029 | struct kobject ports_parent; | 1029 | struct kobject *ports_parent; |
1030 | struct list_head port_list; | 1030 | struct list_head port_list; |
1031 | 1031 | ||
1032 | enum { | 1032 | enum { |