vfio/mdev: Correct the function signatures for the mdev_type_attributes
[linux-2.6-microblaze.git] / drivers / gpu / drm / i915 / gvt / gvt.c
index d1d8ee4..3703814 100644 (file)
@@ -46,32 +46,23 @@ static const char * const supported_hypervisors[] = {
        [INTEL_GVT_HYPERVISOR_KVM] = "KVM",
 };
 
-static struct intel_vgpu_type *intel_gvt_find_vgpu_type(struct intel_gvt *gvt,
-               const char *name)
+static struct intel_vgpu_type *
+intel_gvt_find_vgpu_type(struct intel_gvt *gvt, unsigned int type_group_id)
 {
-       const char *driver_name =
-               dev_driver_string(&gvt->gt->i915->drm.pdev->dev);
-       int i;
-
-       name += strlen(driver_name) + 1;
-       for (i = 0; i < gvt->num_types; i++) {
-               struct intel_vgpu_type *t = &gvt->types[i];
-
-               if (!strncmp(t->name, name, sizeof(t->name)))
-                       return t;
-       }
-
-       return NULL;
+       if (WARN_ON(type_group_id >= gvt->num_types))
+               return NULL;
+       return &gvt->types[type_group_id];
 }
 
-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)
 {
        struct intel_vgpu_type *type;
        unsigned int num = 0;
-       void *gvt = kdev_to_i915(dev)->gvt;
+       void *gvt = kdev_to_i915(mtype_get_parent_dev(mtype))->gvt;
 
-       type = intel_gvt_find_vgpu_type(gvt, kobject_name(kobj));
+       type = intel_gvt_find_vgpu_type(gvt, mtype_get_type_group_id(mtype));
        if (!type)
                num = 0;
        else
@@ -80,19 +71,19 @@ static ssize_t available_instances_show(struct kobject *kobj,
        return sprintf(buf, "%u\n", num);
 }
 
-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);
 }
 
-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)
 {
        struct intel_vgpu_type *type;
-       void *gvt = kdev_to_i915(dev)->gvt;
+       void *gvt = kdev_to_i915(mtype_get_parent_dev(mtype))->gvt;
 
-       type = intel_gvt_find_vgpu_type(gvt, kobject_name(kobj));
+       type = intel_gvt_find_vgpu_type(gvt, mtype_get_type_group_id(mtype));
        if (!type)
                return 0;