diff options
-rw-r--r-- | drivers/infiniband/core/sysfs.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 68fa798c007d..cbd0383f622e 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c | |||
@@ -816,6 +816,22 @@ static struct attribute_group iw_stats_group = { | |||
816 | .attrs = iw_proto_stats_attrs, | 816 | .attrs = iw_proto_stats_attrs, |
817 | }; | 817 | }; |
818 | 818 | ||
819 | static void free_port_list_attributes(struct ib_device *device) | ||
820 | { | ||
821 | struct kobject *p, *t; | ||
822 | |||
823 | list_for_each_entry_safe(p, t, &device->port_list, entry) { | ||
824 | struct ib_port *port = container_of(p, struct ib_port, kobj); | ||
825 | list_del(&p->entry); | ||
826 | sysfs_remove_group(p, &pma_group); | ||
827 | sysfs_remove_group(p, &port->pkey_group); | ||
828 | sysfs_remove_group(p, &port->gid_group); | ||
829 | kobject_put(p); | ||
830 | } | ||
831 | |||
832 | kobject_put(device->ports_parent); | ||
833 | } | ||
834 | |||
819 | int ib_device_register_sysfs(struct ib_device *device, | 835 | int ib_device_register_sysfs(struct ib_device *device, |
820 | int (*port_callback)(struct ib_device *, | 836 | int (*port_callback)(struct ib_device *, |
821 | u8, struct kobject *)) | 837 | u8, struct kobject *)) |
@@ -869,19 +885,7 @@ int ib_device_register_sysfs(struct ib_device *device, | |||
869 | return 0; | 885 | return 0; |
870 | 886 | ||
871 | err_put: | 887 | err_put: |
872 | { | 888 | free_port_list_attributes(device); |
873 | struct kobject *p, *t; | ||
874 | struct ib_port *port; | ||
875 | |||
876 | list_for_each_entry_safe(p, t, &device->port_list, entry) { | ||
877 | list_del(&p->entry); | ||
878 | port = container_of(p, struct ib_port, kobj); | ||
879 | sysfs_remove_group(p, &pma_group); | ||
880 | sysfs_remove_group(p, &port->pkey_group); | ||
881 | sysfs_remove_group(p, &port->gid_group); | ||
882 | kobject_put(p); | ||
883 | } | ||
884 | } | ||
885 | 889 | ||
886 | err_unregister: | 890 | err_unregister: |
887 | device_unregister(class_dev); | 891 | device_unregister(class_dev); |
@@ -892,22 +896,18 @@ err: | |||
892 | 896 | ||
893 | void ib_device_unregister_sysfs(struct ib_device *device) | 897 | void ib_device_unregister_sysfs(struct ib_device *device) |
894 | { | 898 | { |
895 | struct kobject *p, *t; | ||
896 | struct ib_port *port; | ||
897 | |||
898 | /* Hold kobject until ib_dealloc_device() */ | 899 | /* Hold kobject until ib_dealloc_device() */ |
899 | kobject_get(&device->dev.kobj); | 900 | struct kobject *kobj_dev = kobject_get(&device->dev.kobj); |
901 | int i; | ||
900 | 902 | ||
901 | list_for_each_entry_safe(p, t, &device->port_list, entry) { | 903 | if (device->node_type == RDMA_NODE_RNIC && device->get_protocol_stats) |
902 | list_del(&p->entry); | 904 | sysfs_remove_group(kobj_dev, &iw_stats_group); |
903 | port = container_of(p, struct ib_port, kobj); | 905 | |
904 | sysfs_remove_group(p, &pma_group); | 906 | free_port_list_attributes(device); |
905 | sysfs_remove_group(p, &port->pkey_group); | 907 | |
906 | sysfs_remove_group(p, &port->gid_group); | 908 | for (i = 0; i < ARRAY_SIZE(ib_class_attributes); ++i) |
907 | kobject_put(p); | 909 | device_remove_file(&device->dev, ib_class_attributes[i]); |
908 | } | ||
909 | 910 | ||
910 | kobject_put(device->ports_parent); | ||
911 | device_unregister(&device->dev); | 911 | device_unregister(&device->dev); |
912 | } | 912 | } |
913 | 913 | ||