RDMA/core: Simplify how the port sysfs is created
authorJason Gunthorpe <jgg@nvidia.com>
Fri, 11 Jun 2021 16:00:25 +0000 (19:00 +0300)
committerJason Gunthorpe <jgg@nvidia.com>
Wed, 16 Jun 2021 23:58:30 +0000 (20:58 -0300)
commit2ca1cca4352ed50a363159aa9b8eeb6182446580
tree5bdda221f52634071e90c42c9713328758e1d763
parenta4676388e2e21215b32f33b42ac5725e315a6680
RDMA/core: Simplify how the port sysfs is created

Use the same technique as gid_attrs now uses to manage the port
sysfs. Bundle everything into three allocations and use a single
sysfs_create_groups() to build everything in one shot.

All the memory is always freed in the kobj release function, removing most
of the error unwinding.

The gid_attr technique and the hw_counters are very similar, merge the two
together and combine the sysfs_create_group() call for hw_counters with
the single sysfs group setup.

Link: https://lore.kernel.org/r/b688f3340694c59f7b44b1bde40e25559ef43cf3.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