vfio/mdev: Add mdev/mtype_get_type_group_id()
This returns the index in the supported_type_groups array that is associated with the mdev_type attached to the struct mdev_device or its containing struct kobject. Each mdev_device can be spawned from exactly one mdev_type, which in turn originates from exactly one supported_type_group. Drivers are using weird string calculations to try and get back to this index, providing a direct access to the index removes a bunch of wonky driver code. mdev_type->group can be deleted as the group is obtained using the type_group_id. Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Message-Id: <11-v2-d36939638fc6+d54-vfio2_jgg@nvidia.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
parent
fbea432390
commit
15fcc44be0
4 changed files with 33 additions and 7 deletions
|
|
@ -33,6 +33,26 @@ struct device *mdev_parent_dev(struct mdev_device *mdev)
|
|||
}
|
||||
EXPORT_SYMBOL(mdev_parent_dev);
|
||||
|
||||
/*
|
||||
* Return the index in supported_type_groups that this mdev_device was created
|
||||
* from.
|
||||
*/
|
||||
unsigned int mdev_get_type_group_id(struct mdev_device *mdev)
|
||||
{
|
||||
return mdev->type->type_group_id;
|
||||
}
|
||||
EXPORT_SYMBOL(mdev_get_type_group_id);
|
||||
|
||||
/*
|
||||
* Used in mdev_type_attribute sysfs functions to return the index in the
|
||||
* supported_type_groups that the sysfs is called from.
|
||||
*/
|
||||
unsigned int mtype_get_type_group_id(struct kobject *mtype_kobj)
|
||||
{
|
||||
return container_of(mtype_kobj, struct mdev_type, kobj)->type_group_id;
|
||||
}
|
||||
EXPORT_SYMBOL(mtype_get_type_group_id);
|
||||
|
||||
/* Should be called holding parent_list_lock */
|
||||
static struct mdev_parent *__find_parent_device(struct device *dev)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue