Merge branches 'for-4.4/upstream-fixes', 'for-4.5/async-suspend', 'for-4.5/container...
[cascardo/linux.git] / drivers / vfio / platform / vfio_platform_private.h
index 1c9b3d5..42816dd 100644 (file)
@@ -56,6 +56,10 @@ struct vfio_platform_device {
        u32                             num_irqs;
        int                             refcnt;
        struct mutex                    igate;
+       struct module                   *parent_module;
+       const char                      *compat;
+       struct module                   *reset_module;
+       struct device                   *device;
 
        /*
         * These fields should be filled by the bus specific binder
@@ -70,10 +74,13 @@ struct vfio_platform_device {
        int     (*reset)(struct vfio_platform_device *vdev);
 };
 
-struct vfio_platform_reset_combo {
-       const char *compat;
-       const char *reset_function_name;
-       const char *module_name;
+typedef int (*vfio_platform_reset_fn_t)(struct vfio_platform_device *vdev);
+
+struct vfio_platform_reset_node {
+       struct list_head link;
+       char *compat;
+       struct module *owner;
+       vfio_platform_reset_fn_t reset;
 };
 
 extern int vfio_platform_probe_common(struct vfio_platform_device *vdev,
@@ -89,4 +96,29 @@ extern int vfio_platform_set_irqs_ioctl(struct vfio_platform_device *vdev,
                                        unsigned start, unsigned count,
                                        void *data);
 
+extern void __vfio_platform_register_reset(struct vfio_platform_reset_node *n);
+extern void vfio_platform_unregister_reset(const char *compat,
+                                          vfio_platform_reset_fn_t fn);
+#define vfio_platform_register_reset(__compat, __reset)                \
+static struct vfio_platform_reset_node __reset ## _node = {    \
+       .owner = THIS_MODULE,                                   \
+       .compat = __compat,                                     \
+       .reset = __reset,                                       \
+};                                                             \
+__vfio_platform_register_reset(&__reset ## _node)
+
+#define module_vfio_reset_handler(compat, reset)               \
+MODULE_ALIAS("vfio-reset:" compat);                            \
+static int __init reset ## _module_init(void)                  \
+{                                                              \
+       vfio_platform_register_reset(compat, reset);            \
+       return 0;                                               \
+};                                                             \
+static void __exit reset ## _module_exit(void)                 \
+{                                                              \
+       vfio_platform_unregister_reset(compat, reset);          \
+};                                                             \
+module_init(reset ## _module_init);                            \
+module_exit(reset ## _module_exit)
+
 #endif /* VFIO_PLATFORM_PRIVATE_H */