vfio: platform: add compat in vfio_platform_device
authorEric Auger <eric.auger@linaro.org>
Tue, 3 Nov 2015 18:12:16 +0000 (18:12 +0000)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 3 Nov 2015 19:55:02 +0000 (12:55 -0700)
Let's retrieve the compatibility string on probe and store it
in the vfio_platform_device struct

Signed-off-by: Eric Auger <eric.auger@linaro.org>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/platform/vfio_platform_common.c
drivers/vfio/platform/vfio_platform_private.h

index 7decc50ccf30c87cdfcac730d1b0adf465af364f..d8df8a4318daae0b1f243465582338dc2bb6636a 100644 (file)
@@ -41,16 +41,11 @@ static const struct vfio_platform_reset_combo reset_lookup_table[] = {
 static void vfio_platform_get_reset(struct vfio_platform_device *vdev,
                                    struct device *dev)
 {
-       const char *compat;
        int (*reset)(struct vfio_platform_device *);
-       int ret, i;
-
-       ret = device_property_read_string(dev, "compatible", &compat);
-       if (ret)
-               return;
+       int i;
 
        for (i = 0 ; i < ARRAY_SIZE(reset_lookup_table); i++) {
-               if (!strcmp(reset_lookup_table[i].compat, compat)) {
+               if (!strcmp(reset_lookup_table[i].compat, vdev->compat)) {
                        request_module(reset_lookup_table[i].module_name);
                        reset = __symbol_get(
                                reset_lookup_table[i].reset_function_name);
@@ -544,6 +539,12 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
        if (!vdev)
                return -EINVAL;
 
+       ret = device_property_read_string(dev, "compatible", &vdev->compat);
+       if (ret) {
+               pr_err("VFIO: cannot retrieve compat for %s\n", vdev->name);
+               return -EINVAL;
+       }
+
        group = iommu_group_get(dev);
        if (!group) {
                pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
index fd262be2a443d5fa2b0083a5be9609efcdeb47f6..415310f62b06cc4a8a76153c15b00b45e7c09279 100644 (file)
@@ -57,6 +57,7 @@ struct vfio_platform_device {
        int                             refcnt;
        struct mutex                    igate;
        struct module                   *parent_module;
+       const char                      *compat;
 
        /*
         * These fields should be filled by the bus specific binder