staging: unisys: add acpi pnp driver
authorPrarit Bhargava <prarit@redhat.com>
Tue, 5 May 2015 22:37:02 +0000 (18:37 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 May 2015 13:27:31 +0000 (15:27 +0200)
According to Unisys, another OS detects the PNP0A07 as the auto load
device.  We can also do this in the linux kernel by simply converting the
driver over to the ACPI driver model.

Notes: This changes the usage of __init and it had to be removed from some
functions to avoid a !__init function calling an __init function.
Additionally I also cleaned up the headers in visorchipset.c since I was
adding a header file.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/visorbus/visorbus_main.c
drivers/staging/unisys/visorbus/visorbus_private.h
drivers/staging/unisys/visorbus/visorchipset.c

index f7976ca76f1778e8d0ab13cb8a9d863e3e4f6515..b522ea4d2c2dada6fed19036459dcadaa86c4f69 100644 (file)
@@ -2034,7 +2034,7 @@ struct channel_size_info {
        unsigned long max_size;
 };
 
-int __init
+int
 visorbus_init(void)
 {
        int rc = 0;
index f9a5e015e21df12ad4b675b998d7853753223f0b..1153c99e813f8ab6356ef9bad45483eece9017db 100644 (file)
@@ -155,6 +155,6 @@ bool visorchipset_get_device_info(u32 bus_no, u32 dev_no,
 bool visorchipset_set_bus_context(u32 bus_no, void *context);
 
 /* visorbus init and exit functions */
-int __init visorbus_init(void);
+int visorbus_init(void);
 void visorbus_exit(void);
 #endif
index 76923bf45de1215d712164d84fc36e5897a758ea..fde89938cee52f63f0ccf882ffe377ec90188e84 100644 (file)
  * details.
  */
 
-#include "controlvmchannel.h"
-#include "version.h"
-#include "procobjecttree.h"
-#include "visorbus.h"
-#include "periodic_work.h"
-#include "uisutils.h"
-#include "controlvmcompletionstatus.h"
-#include "guestlinuxdebug.h"
-#include "visorbus_private.h"
-
+#include <linux/acpi.h>
 #include <linux/ctype.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
 #include <linux/uuid.h>
 #include <linux/crash_dump.h>
 
+#include "controlvmchannel.h"
+#include "controlvmcompletionstatus.h"
+#include "guestlinuxdebug.h"
+#include "periodic_work.h"
+#include "procobjecttree.h"
+#include "uisutils.h"
+#include "version.h"
+#include "visorbus.h"
+#include "visorbus_private.h"
+
 #define CURRENT_FILE_PC VISOR_CHIPSET_PC_visorchipset_main_c
 
 #define MAX_NAME_SIZE 128
@@ -2637,17 +2638,12 @@ visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel)
        return 0;
 }
 
-
-
-static int __init
-visorchipset_init(void)
+static int
+visorchipset_init(struct acpi_device *acpi_device)
 {
        int rc = 0;
        HOSTADDRESS addr;
 
-       if (!unisys_spar_platform)
-               return -ENODEV;
-
        memset(&busdev_notifiers, 0, sizeof(busdev_notifiers));
        memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info));
        memset(&livedump_info, 0, sizeof(livedump_info));
@@ -2733,8 +2729,8 @@ visorchipset_file_cleanup(dev_t major_dev)
        unregister_chrdev_region(major_dev, 1);
 }
 
-static void
-visorchipset_exit(void)
+static int
+visorchipset_exit(struct acpi_device *acpi_device)
 {
        POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO);
 
@@ -2754,6 +2750,45 @@ visorchipset_exit(void)
 
        visorchipset_file_cleanup(visorchipset_platform_device.dev.devt);
        POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO);
+
+       return 0;
+}
+
+static const struct acpi_device_id unisys_device_ids[] = {
+       {"PNP0A07", 0},
+       {"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, unisys_device_ids);
+
+static struct acpi_driver unisys_acpi_driver = {
+       .name = "unisys_acpi",
+       .class = "unisys_acpi_class",
+       .owner = THIS_MODULE,
+       .ids = unisys_device_ids,
+       .ops = {
+               .add = visorchipset_init,
+               .remove = visorchipset_exit,
+               },
+};
+
+static int init_unisys(void)
+{
+       int result;
+
+       if (!unisys_spar_platform)
+               return -ENODEV;
+
+       result = acpi_bus_register_driver(&unisys_acpi_driver);
+       if (result)
+               return -ENODEV;
+
+       pr_info("Unisys Visorchipset Driver Loaded.\n");
+       return 0;
+};
+
+static void exit_unisys(void)
+{
+       acpi_bus_unregister_driver(&unisys_acpi_driver);
 }
 
 module_param_named(major, visorchipset_major, int, S_IRUGO);
@@ -2767,8 +2802,8 @@ module_param_named(holdchipsetready, visorchipset_holdchipsetready,
 MODULE_PARM_DESC(visorchipset_holdchipsetready,
                 "1 to hold response to CHIPSET_READY");
 
-module_init(visorchipset_init);
-module_exit(visorchipset_exit);
+module_init(init_unisys);
+module_exit(exit_unisys);
 
 MODULE_AUTHOR("Unisys");
 MODULE_LICENSE("GPL");