]> git.baikalelectronics.ru Git - kernel.git/commit
RDMA/core: Simplify how the gid_attrs sysfs is created
authorJason Gunthorpe <jgg@nvidia.com>
Fri, 11 Jun 2021 16:00:24 +0000 (19:00 +0300)
committerJason Gunthorpe <jgg@nvidia.com>
Wed, 16 Jun 2021 23:58:29 +0000 (20:58 -0300)
commit641a15edd46f28ba2d7759aecabbc2dcff52af99
treefdf8ca07541dac4169d5befaeb0e54e2c1bb3469
parent7ab5fac47b18369070cd730084d32fb7d65cd365
RDMA/core: Simplify how the gid_attrs sysfs is created

Instead of having an whole bunch of different allocations to create the
gid_attr kobjects reduce it to three, one for the kobj struct plus the
attributes, and one for the attribute list for each of the two
groups.

Move the freeing of all allocations to the release function.

Reorder the operations so all the allocations happen first then the
kobject & sysfs operations are last.

This removes the majority of the complicated error unwind since the
release function will always undo all the memory allocations. Freeing the
memory is also much simpler since there is a lot less of it.

Consolidate creating the "group of array indexes" pattern into one helper
function. Ensure kobject_del is used.

Link: https://lore.kernel.org/r/f4149d379db7178d37d11d75e3026bf550f818a1.1623427137.git.leonro@nvidia.com
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/core/sysfs.c