summaryrefslogtreecommitdiffstats
path: root/drivers/vfio/mdev
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2022-09-23 11:26:50 +0200
committerAlex Williamson <alex.williamson@redhat.com>2022-10-04 20:06:58 +0200
commitf2fbc72e6da4f8e01fe5fe3d6871a791e76271c3 (patch)
treeee1b8729387da228a9f23f5a2d7be303cad86155 /drivers/vfio/mdev
parentvfio/mdev: consolidate all the name sysfs into the core code (diff)
downloadlinux-f2fbc72e6da4f8e01fe5fe3d6871a791e76271c3.tar.xz
linux-f2fbc72e6da4f8e01fe5fe3d6871a791e76271c3.zip
vfio/mdev: consolidate all the available_instance sysfs into the core code
Every driver just print a number, simply add a method to the mdev_driver to return it and provide a standard sysfs show function. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Kirti Wankhede <kwankhede@nvidia.com> Reviewed-by: Eric Farman <farman@linux.ibm.com> Link: https://lore.kernel.org/r/20220923092652.100656-13-hch@lst.de Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/vfio/mdev')
-rw-r--r--drivers/vfio/mdev/mdev_sysfs.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/vfio/mdev/mdev_sysfs.c b/drivers/vfio/mdev/mdev_sysfs.c
index 34583e6a97f2..b7f87c3eda5e 100644
--- a/drivers/vfio/mdev/mdev_sysfs.c
+++ b/drivers/vfio/mdev/mdev_sysfs.c
@@ -90,10 +90,21 @@ static ssize_t name_show(struct mdev_type *mtype,
static MDEV_TYPE_ATTR_RO(name);
+static ssize_t available_instances_show(struct mdev_type *mtype,
+ struct mdev_type_attribute *attr,
+ char *buf)
+{
+ struct mdev_driver *drv = mtype->parent->mdev_driver;
+
+ return sysfs_emit(buf, "%u\n", drv->get_available(mtype));
+}
+static MDEV_TYPE_ATTR_RO(available_instances);
+
static struct attribute *mdev_types_core_attrs[] = {
&mdev_type_attr_create.attr,
&mdev_type_attr_device_api.attr,
&mdev_type_attr_name.attr,
+ &mdev_type_attr_available_instances.attr,
NULL,
};