RDMA: Introduce and use rdma_device_to_ibdev()
Introduce and use rdma_device_to_ibdev() API for those drivers which are registering one sysfs group and also use in ib_core. In subsequent patch, device->provider_ibdev one-to-one mapping is no longer holds true during accessing sysfs entries. Therefore, introduce an API rdma_device_to_ibdev() that provides such information. Signed-off-by: Parav Pandit <parav@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:

committed by
Jason Gunthorpe

parent
ea4baf7f11
commit
5474723115
@@ -4241,4 +4241,27 @@ rdma_set_device_sysfs_group(struct ib_device *dev,
|
||||
dev->groups[1] = group;
|
||||
}
|
||||
|
||||
/**
|
||||
* rdma_device_to_ibdev - Get ib_device pointer from device pointer
|
||||
*
|
||||
* @device: device pointer for which ib_device pointer to retrieve
|
||||
*
|
||||
* rdma_device_to_ibdev() retrieves ib_device pointer from device.
|
||||
*
|
||||
*/
|
||||
static inline struct ib_device *rdma_device_to_ibdev(struct device *device)
|
||||
{
|
||||
return container_of(device, struct ib_device, dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* rdma_device_to_drv_device - Helper macro to reach back to driver's
|
||||
* ib_device holder structure from device pointer.
|
||||
*
|
||||
* NOTE: New drivers should not make use of this API; This API is only for
|
||||
* existing drivers who have exposed sysfs entries using
|
||||
* rdma_set_device_sysfs_group().
|
||||
*/
|
||||
#define rdma_device_to_drv_device(dev, drv_dev_struct, ibdev_member) \
|
||||
container_of(rdma_device_to_ibdev(dev), drv_dev_struct, ibdev_member)
|
||||
#endif /* IB_VERBS_H */
|
||||
|
Reference in New Issue
Block a user