aboutsummaryrefslogtreecommitdiff
path: root/samples/vfio-mdev/mbochs.c
diff options
context:
space:
mode:
authorGravatar Jason Gunthorpe <jgg@nvidia.com> 2021-04-06 16:40:41 -0300
committerGravatar Alex Williamson <alex.williamson@redhat.com> 2021-04-12 10:36:00 -0600
commit9169cff168ff262b4b78597f542e23843d0c494a (patch)
tree155864655184ce669e38b27e412fb1bfae02b79a /samples/vfio-mdev/mbochs.c
parentvfio/mdev: Remove kobj from mdev_parent_ops->create() (diff)
downloadlinux-9169cff168ff262b4b78597f542e23843d0c494a.tar.gz
linux-9169cff168ff262b4b78597f542e23843d0c494a.tar.bz2
linux-9169cff168ff262b4b78597f542e23843d0c494a.zip
vfio/mdev: Correct the function signatures for the mdev_type_attributes
The driver core standard is to pass in the properly typed object, the properly typed attribute and the buffer data. It stems from the root kobject method: ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,..) Each subclass of kobject should provide their own function with the same signature but more specific types, eg struct device uses: ssize_t (*show)(struct device *dev, struct device_attribute *attr,..) In this case the existing signature is: ssize_t (*show)(struct kobject *kobj, struct device *dev,..) Where kobj is a 'struct mdev_type *' and dev is 'mdev_type->parent->dev'. Change the mdev_type related sysfs attribute functions to: ssize_t (*show)(struct mdev_type *mtype, struct mdev_type_attribute *attr,..) In order to restore type safety and match the driver core standard There are no current users of 'attr', but if it is ever needed it would be hard to add in retroactively, so do it now. Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Message-Id: <18-v2-d36939638fc6+d54-vfio2_jgg@nvidia.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'samples/vfio-mdev/mbochs.c')
-rw-r--r--samples/vfio-mdev/mbochs.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c
index ac4d0dc24907..861c76914e76 100644
--- a/samples/vfio-mdev/mbochs.c
+++ b/samples/vfio-mdev/mbochs.c
@@ -1330,37 +1330,41 @@ static const struct attribute_group *mdev_dev_groups[] = {
NULL,
};
-static ssize_t
-name_show(struct kobject *kobj, struct device *dev, char *buf)
+static ssize_t name_show(struct mdev_type *mtype,
+ struct mdev_type_attribute *attr, char *buf)
{
- return sprintf(buf, "%s\n", kobj->name);
+ const struct mbochs_type *type =
+ &mbochs_types[mtype_get_type_group_id(mtype)];
+
+ return sprintf(buf, "%s\n", type->name);
}
static MDEV_TYPE_ATTR_RO(name);
-static ssize_t
-description_show(struct kobject *kobj, struct device *dev, char *buf)
+static ssize_t description_show(struct mdev_type *mtype,
+ struct mdev_type_attribute *attr, char *buf)
{
const struct mbochs_type *type =
- &mbochs_types[mtype_get_type_group_id(kobj)];
+ &mbochs_types[mtype_get_type_group_id(mtype)];
return sprintf(buf, "virtual display, %d MB video memory\n",
type ? type->mbytes : 0);
}
static MDEV_TYPE_ATTR_RO(description);
-static ssize_t
-available_instances_show(struct kobject *kobj, struct device *dev, char *buf)
+static ssize_t available_instances_show(struct mdev_type *mtype,
+ struct mdev_type_attribute *attr,
+ char *buf)
{
const struct mbochs_type *type =
- &mbochs_types[mtype_get_type_group_id(kobj)];
+ &mbochs_types[mtype_get_type_group_id(mtype)];
int count = (max_mbytes - mbochs_used_mbytes) / type->mbytes;
return sprintf(buf, "%d\n", count);
}
static MDEV_TYPE_ATTR_RO(available_instances);
-static ssize_t device_api_show(struct kobject *kobj, struct device *dev,
- char *buf)
+static ssize_t device_api_show(struct mdev_type *mtype,
+ struct mdev_type_attribute *attr, char *buf)
{
return sprintf(buf, "%s\n", VFIO_DEVICE_API_PCI_STRING);
}